@@ -425,6 +425,8 @@ func (wflow *Workflow) savePartialDataForReadyTasks(requestId ReqId, progress *P
425425// Invoke schedules each function of the workflow and invokes them
426426func (wflow * Workflow ) Invoke (r * Request ) error {
427427
428+ alwaysSaveProgress := config .GetBool (config .WORKFLOW_ALWAYS_SAVE_PROGRESS , false )
429+
428430 var err error
429431 requestId := ReqId (r .Id )
430432
@@ -437,9 +439,11 @@ func (wflow *Workflow) Invoke(r *Request) error {
437439 dataMap := make (map [TaskId ]* TaskData )
438440
439441 if len (progress .ReadyToExecute ) == 0 {
440- return fmt .Errorf ("wflow resumed but no task is ready for execution: %v " , requestId )
442+ return fmt .Errorf ("[Rq-%v] wflow resumed but no task is ready for execution" , requestId )
441443 }
442444
445+ log .Printf ("[Rq-%v] Starting/resuming execution (%d to executed)" , requestId , len (progress .ReadyToExecute ))
446+
443447 for len (progress .ReadyToExecute ) > 0 {
444448 t0 := time .Now ()
445449 decision , err := offloadingPolicy .Evaluate (r , progress )
@@ -450,7 +454,7 @@ func (wflow *Workflow) Invoke(r *Request) error {
450454 return fmt .Errorf ("an error occurred in policy evaluation: %v" , err )
451455 }
452456
453- if decision .Offload {
457+ if decision .Offload || alwaysSaveProgress {
454458 err := progress .Save ()
455459 if err != nil {
456460 return fmt .Errorf ("Could not save progress: %v" , err )
@@ -462,24 +466,26 @@ func (wflow *Workflow) Invoke(r *Request) error {
462466 return fmt .Errorf ("Could not save partial data: %v" , err )
463467 }
464468
465- log . Printf ( "Offloading request: %v" , requestId )
469+ }
466470
471+ if decision .Offload {
467472 err = offload (r , & decision )
468473 if err != nil {
469474 return err
470475 }
471476
472477 if r .ExecReport .Result != nil {
473478 // Workflow execution has completed on remote node
474- break
479+ log .Printf ("[Rq-%v] Workflow has completed on remote node" , requestId )
480+ return nil
475481 }
476482
477483 progress , err = RetrieveProgress (requestId )
478484 if err != nil {
479485 return fmt .Errorf ("Could not retrieve progress after offloading: %v" , err )
480486 }
481487
482- log .Printf ("Ready to execute after offloading: %v" , progress .ReadyToExecute )
488+ log .Printf ("[Rq-%v] Ready to execute after offloading: %v" , requestId , progress .ReadyToExecute )
483489 } else {
484490 // pick next executable task
485491 var taskToExecute TaskId = ""
@@ -489,9 +495,12 @@ func (wflow *Workflow) Invoke(r *Request) error {
489495 }
490496 }
491497 if taskToExecute == "" {
498+ log .Printf ("[Rq-%v] Workflow has not completed but there is nothing left to execute in the plan" , requestId )
492499 break
493500 }
494501
502+ log .Printf ("[Rq-%v] Now going to execute %s" , requestId , taskToExecute )
503+
495504 // Prepare input for taskToExecute
496505 var input * TaskData
497506 if wflow .Tasks [taskToExecute ].GetType () == Start {
@@ -530,11 +539,15 @@ func (wflow *Workflow) Invoke(r *Request) error {
530539 }
531540 }
532541
542+ log .Printf ("[Rq-%v] Executed %s" , requestId , taskToExecute )
543+
533544 dataMap [taskToExecute ] = output
534545
535546 if len (progress .ReadyToExecute ) == 0 && output != nil {
536547 r .ExecReport .Result = output .Data
537548
549+ log .Printf ("[Rq-%v] Workflow completed" , requestId )
550+
538551 if isProgressOnEtcd {
539552 err = DeleteProgress (requestId )
540553 if err != nil {
@@ -568,7 +581,7 @@ func (wflow *Workflow) Invoke(r *Request) error {
568581
569582func offload (r * Request , policyDecision * OffloadingDecision ) error {
570583
571- log .Printf ("Offloading decision: %v" , policyDecision )
584+ log .Printf ("[Rq-%v] Offloading decision: %v" , r . Id , policyDecision )
572585
573586 request := WorkflowInvocationResumeRequest {
574587 ReqId : r .Id ,
0 commit comments