style95 commented on a change in pull request #5205:
URL: https://github.com/apache/openwhisk/pull/5205#discussion_r833838783
##########
File path:
core/invoker/src/main/scala/org/apache/openwhisk/core/invoker/InvokerReactive.scala
##########
@@ -293,18 +292,38 @@ class InvokerReactive(
}
private val healthProducer = msgProvider.getProducer(config)
- Scheduler.scheduleWaitAtMost(1.seconds)(() => {
- healthProducer.send(s"${Invoker.topicPrefix}health",
PingMessage(instance)).andThen {
- case Failure(t) => logging.error(this, s"failed to ping the controller:
$t")
- }
- })
+
+ def getHealthScheduler: ActorRef =
+ Scheduler.scheduleWaitAtMost(1.seconds)(() => {
+ healthProducer.send(s"${Invoker.topicPrefix}health",
PingMessage(instance)).andThen {
+ case Failure(t) => logging.error(this, s"failed to ping the
controller: $t")
+ }
+ })
+
+ var healthScheduler: Option[ActorRef] = Some(getHealthScheduler)
Review comment:
should this be private var?
##########
File path:
core/invoker/src/main/scala/org/apache/openwhisk/core/invoker/InvokerReactive.scala
##########
@@ -293,18 +292,38 @@ class InvokerReactive(
}
private val healthProducer = msgProvider.getProducer(config)
- Scheduler.scheduleWaitAtMost(1.seconds)(() => {
- healthProducer.send(s"${Invoker.topicPrefix}health",
PingMessage(instance)).andThen {
- case Failure(t) => logging.error(this, s"failed to ping the controller:
$t")
- }
- })
+
+ def getHealthScheduler: ActorRef =
+ Scheduler.scheduleWaitAtMost(1.seconds)(() => {
+ healthProducer.send(s"${Invoker.topicPrefix}health",
PingMessage(instance)).andThen {
+ case Failure(t) => logging.error(this, s"failed to ping the
controller: $t")
+ }
+ })
+
+ var healthScheduler: Option[ActorRef] = Some(getHealthScheduler)
override def enable(): Route = {
+ if (healthScheduler.isEmpty) {
+ healthScheduler = Some(getHealthScheduler)
+ complete(s"${instance.toString} is now enabled.")
+ } else {
+ complete(s"${instance.toString} is already enabled.")
+ }
complete("not supported")
}
override def disable(): Route = {
- complete("not supported")
+ if (healthScheduler.nonEmpty) {
+ actorSystem.stop(healthScheduler.get)
+ healthScheduler = None
Review comment:
JFYI.
While it would be effective, invokers in my downstream are sending a certain
message to controllers so that they can make invokers unhealthy immediately to
avoid a long-running activation coming to a disabled invoker during the timeout.
But I think this is just a minor tweak.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]