[GitHub] rabbah commented on a change in pull request #3704: Provide graceful shutdown for invoker

2018-06-07 Thread GitBox
rabbah commented on a change in pull request #3704: Provide graceful shutdown 
for invoker
URL: 
https://github.com/apache/incubator-openwhisk/pull/3704#discussion_r193853597
 
 

 ##
 File path: 
common/scala/src/main/scala/whisk/core/connector/MessageConsumer.scala
 ##
 @@ -163,6 +171,26 @@ class MessageFeed(description: String,
 goto(FillingPipeline)
   } else stay
 
+case Event(GracefulShutdown, _) =>
+  goto(GracefulShutdownDrain)
+
+case _ => stay
+  }
+
+  when(GracefulShutdownDrain) {
+case Event(Processed, _) =>
+  updateHandlerCapacity()
+  sendOutstandingMessages()
+  stay
+
+case Event(FillCompleted(messages), _) =>
 
 Review comment:
   right - if filling, you need to wait.
   you'll also need to prevent a further fill.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] rabbah commented on a change in pull request #3704: Provide graceful shutdown for invoker

2018-06-05 Thread GitBox
rabbah commented on a change in pull request #3704: Provide graceful shutdown 
for invoker
URL: 
https://github.com/apache/incubator-openwhisk/pull/3704#discussion_r193255126
 
 

 ##
 File path: core/invoker/src/main/scala/whisk/core/invoker/InvokerReactive.scala
 ##
 @@ -284,4 +290,84 @@ class InvokerReactive(
   })
   }
 
+  val healthScheduler = Scheduler.scheduleWaitAtMost(1.seconds)(() => {
+producer.send("health", PingMessage(instance)).andThen {
+  case Failure(t) => logging.error(this, s"failed to ping the controller: 
$t")
 
 Review comment:
   the controller -> controllers


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] rabbah commented on a change in pull request #3704: Provide graceful shutdown for invoker

2018-06-05 Thread GitBox
rabbah commented on a change in pull request #3704: Provide graceful shutdown 
for invoker
URL: 
https://github.com/apache/incubator-openwhisk/pull/3704#discussion_r193255025
 
 

 ##
 File path: 
core/invoker/src/main/scala/whisk/core/containerpool/ContainerPool.scala
 ##
 @@ -178,6 +178,9 @@ class ContainerPool(childFactory: ActorRefFactory => 
ActorRef,
 case RescheduleJob =>
   freePool = freePool - sender()
   busyPool = busyPool - sender()
+
+case Busy =>
+  sender ! (!busyPool.isEmpty)
 
 Review comment:
   busyPool.nonEmpty?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] rabbah commented on a change in pull request #3704: Provide graceful shutdown for invoker

2018-06-05 Thread GitBox
rabbah commented on a change in pull request #3704: Provide graceful shutdown 
for invoker
URL: 
https://github.com/apache/incubator-openwhisk/pull/3704#discussion_r193254857
 
 

 ##
 File path: core/invoker/src/main/scala/whisk/core/invoker/InvokerReactive.scala
 ##
 @@ -284,4 +290,50 @@ class InvokerReactive(
   })
   }
 
+  val healthScheduler = Scheduler.scheduleWaitAtMost(1.seconds)(() => {
+producer.send("health", PingMessage(instance)).andThen {
+  case Failure(t) => logging.error(this, s"failed to ping the controller: 
$t")
+}
+  })
+
+  private def gracefulShutdown: Unit = {
+logging.info(this, s"Starting graceful shutdown")
+
+try {
+  Await.result(gracefulStop(healthScheduler, 5.seconds), 6.seconds)
+} catch {
+  case e: akka.pattern.AskTimeoutException =>
+logging.info(this, "Health communication failed to shutdown 
gracefully")
+}
+
+try {
+  Await.result(gracefulStop(activationFeed, 5.seconds), 6.seconds)
+} catch {
+  case e: akka.pattern.AskTimeoutException => logging.info(this, 
"Activation feed failed to shutdown gracefully")
+}
+
+implicit val timeout = Timeout(5 seconds)
+
+while (Await.result(pool ? Busy, timeout.duration).asInstanceOf[Boolean] 
== true) {
+  logging.info(this, s"Container pool is busy")
+  Thread.sleep(1000)
+}
 
 Review comment:
   Can you emit a log message while waiting for quiescence?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services