style95 commented on a change in pull request #4954:
URL: https://github.com/apache/openwhisk/pull/4954#discussion_r478800183
##########
File path:
core/invoker/src/main/scala/org/apache/openwhisk/core/invoker/InvokerReactive.scala
##########
@@ -164,6 +164,62 @@ class InvokerReactive(
private val pool =
actorSystem.actorOf(ContainerPool.props(childFactory, poolConfig,
activationFeed, prewarmingConfigs))
+ def handleActivationMessage(msg: ActivationMessage)(implicit transid:
TransactionId): Future[Unit] = {
+ val namespace = msg.action.path
+ val name = msg.action.name
+ val actionid = FullyQualifiedEntityName(namespace,
name).toDocId.asDocInfo(msg.revision)
+ val subject = msg.user.subject
+
+ logging.debug(this, s"${actionid.id} $subject ${msg.activationId}")
+
+ // caching is enabled since actions have revision id and an updated
+ // action will not hit in the cache due to change in the revision id;
+ // if the doc revision is missing, then bypass cache
+ if (actionid.rev == DocRevision.empty) logging.warn(this, s"revision was
not provided for ${actionid.id}")
+
+ WhiskAction
+ .get(entityStore, actionid.id, actionid.rev, fromCache = actionid.rev !=
DocRevision.empty)
+ .flatMap(action => {
+ action.toExecutableWhiskAction match {
+ case Some(executable) =>
+ val newMsg = msg.copy(revision = executable.rev, action =
action.fullyQualifiedName(true))
+ pool ! Run(executable, newMsg)
+ Future.successful(())
+ case None =>
+ logging.error(this, s"non-executable action reached the invoker
${action.fullyQualifiedName(false)}")
+ Future.failed(new IllegalStateException("non-executable action
reached the invoker"))
+ }
+ })
+ .recoverWith {
+ case DocumentRevisionMismatchException(_) =>
+ // if revision is mismatched, the action may have been updated,
+ // so try again with the latest code
+ handleActivationMessage(msg.copy(revision = DocRevision.empty))
Review comment:
This can be controversial but I think the system should take care of
this.
This is to handle the case where the underlying actions are updated while a
sequence action is invoked.
If we consider the sequence as just a coordinator for underlying actions, it
would be fine for it to always invoke the latest code. Once a sequence action
is defined with some actions, we don't need to update the sequence action
whenever the underlying actions are updated. It means the sequence action
itself does not care about the version of actions in it but just focuses on the
relation and the execution order of them.
So I think it is reasonable to invoke the latest codes all the time.
And regarding the implementation, while this is great, can we differentiate
the sequence case with the others?
I feel like there can be some side effects.
For example, if any activation sent to Kafka arrives at the invoker side
late, it could happen.
In such a case the activation is intended for the old codes but the latest
code will be invoked with this change.
I did not look into code deeply yet, but can we make the controller setup
subsequent activations with the latest codes while invoking a sequence action?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]