diff --git a/cmd/argoexec/commands/data.go b/cmd/argoexec/commands/data.go index c25daf08645d..5a24d9d0a7ca 100644 --- a/cmd/argoexec/commands/data.go +++ b/cmd/argoexec/commands/data.go @@ -3,6 +3,7 @@ package commands import ( "context" + log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -10,11 +11,29 @@ func NewDataCommand() *cobra.Command { command := cobra.Command{ Use: "data", Short: "Process data", - RunE: func(cmd *cobra.Command, args []string) error { - ctx := context.Background() - wfExecutor := initExecutor() - return wfExecutor.Data(ctx) + Run: func(cmd *cobra.Command, args []string) { + ctx := cmd.Context() + err := execData(ctx) + if err != nil { + log.Fatalf("%+v", err) + } }, } return &command } + +func execData(ctx context.Context) error { + wfExecutor := initExecutor() + defer wfExecutor.HandleError(ctx) + + // Create a new empty (placeholder) task result with LabelKeyReportOutputsCompleted set to false. + wfExecutor.InitializeOutput(ctx) + defer wfExecutor.FinalizeOutput(ctx) //Ensures the LabelKeyReportOutputsCompleted is set to true. + + err := wfExecutor.Data(ctx) + if err != nil { + wfExecutor.AddError(err) + return err + } + return nil +} diff --git a/cmd/argoexec/commands/resource.go b/cmd/argoexec/commands/resource.go index e5d8fcf32328..c54c97544bb3 100644 --- a/cmd/argoexec/commands/resource.go +++ b/cmd/argoexec/commands/resource.go @@ -39,6 +39,11 @@ func execResource(ctx context.Context, action string) error { wfExecutor.AddError(err) return err } + + // Create a new empty (placeholder) task result with LabelKeyReportOutputsCompleted set to false. + wfExecutor.InitializeOutput(ctx) + defer wfExecutor.FinalizeOutput(ctx) //Ensures the LabelKeyReportOutputsCompleted is set to true. + isDelete := action == "delete" if isDelete && (wfExecutor.Template.Resource.SuccessCondition != "" || wfExecutor.Template.Resource.FailureCondition != "" || len(wfExecutor.Template.Outputs.Parameters) > 0) { err = fmt.Errorf("successCondition, failureCondition and outputs are not supported for delete action") diff --git a/test/e2e/functional_test.go b/test/e2e/functional_test.go index 30a522287876..76b270394fb1 100644 --- a/test/e2e/functional_test.go +++ b/test/e2e/functional_test.go @@ -908,6 +908,9 @@ func (s *FunctionalSuite) TestDataTransformation() { } assert.NotNil(t, status.Nodes.FindByDisplayName("process-artifact(0:foo/script.py)")) assert.NotNil(t, status.Nodes.FindByDisplayName("process-artifact(1:script.py)")) + for _, value := range status.TaskResultsCompletionStatus { + assert.True(t, value) + } }) } diff --git a/test/e2e/resource_template_test.go b/test/e2e/resource_template_test.go index 2a4916f85b2d..e8f2bbb49e9d 100644 --- a/test/e2e/resource_template_test.go +++ b/test/e2e/resource_template_test.go @@ -159,6 +159,9 @@ func (s *ResourceTemplateSuite) TestResourceTemplateWithOutputs() { assert.Equal(t, "my-pod", parameters[1].Value.String(), "metadata.name is capture for jq") } } + for _, value := range status.TaskResultsCompletionStatus { + assert.True(t, value) + } }) }