dubee commented on a change in pull request #3799: Display proper error when 
sequence invocation fails due to missing component
URL: 
https://github.com/apache/incubator-openwhisk/pull/3799#discussion_r201907571
 
 

 ##########
 File path: 
core/controller/src/main/scala/whisk/core/controller/actions/SequenceActions.scala
 ##########
 @@ -247,40 +245,47 @@ protected[actions] trait SequenceActions {
     //
     // This action/parameter resolution is done in futures; the execution 
starts as soon as the first component
     // is resolved.
-    val resolvedFutureActions = resolveDefaultNamespace(components, user) map 
{ c =>
+    val resolvedFutureActions: Seq[Future[WhiskActionMetaData]] = 
resolveDefaultNamespace(components, user) map { c =>
       WhiskActionMetaData.resolveActionAndMergeParameters(entityStore, c)
     }
 
     // this holds the initial value of the accounting structure, including the 
input boxed as an ActivationResponse
-    val initialAccounting = Future.successful {
-      SequenceAccounting(atomicActionCnt, 
ActivationResponse.payloadPlaceholder(inputPayload))
-    }
-
-    // execute the actions in sequential blocking fashion
-    resolvedFutureActions
-      .foldLeft(initialAccounting) { (accountingFuture, futureAction) =>
-        accountingFuture.flatMap { accounting =>
-          if (accounting.atomicActionCnt < actionSequenceLimit) {
-            invokeNextAction(user, futureAction, accounting, cause).flatMap { 
accounting =>
-              if (!accounting.shortcircuit) {
-                Future.successful(accounting)
-              } else {
-                // this is to short circuit the fold
-                Future.failed(FailedSequenceActivation(accounting)) // 
terminates the fold
-              }
+    val initialAccounting = SequenceAccounting(atomicActionCnt, 
ActivationResponse.payloadPlaceholder(inputPayload))
+
+    Future
+      .sequence(resolvedFutureActions)
+      .flatMap(actions =>
 
 Review comment:
   Gave refactoring a shot. Turned `resolvedFutureActions` into a 
`Future[List[resolvedFutureActions]]`. My understanding is that the `flapMap` 
block won't be executed if one or more of the actions does not exist and 
instead execution will jump to the second `recoverWith` on line 283.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to