Skip to content

Commit

Permalink
fix: Mark resource && data template report-outputs-completed true (#1…
Browse files Browse the repository at this point in the history
…2544)

Signed-off-by: shuangkun <tsk2013uestc@163.com>
  • Loading branch information
shuangkun committed Jan 26, 2024
1 parent 8d27a9f commit a155877
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 5 deletions.
29 changes: 25 additions & 4 deletions cmd/argoexec/commands/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,39 @@ package commands
import (
"context"

log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)

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()

// Don't allow cancellation to impact capture of results, parameters, artifacts, or defers.
bgCtx := context.Background()
// Create a new empty (placeholder) task result with LabelKeyReportOutputsCompleted set to false.
wfExecutor.InitializeOutput(bgCtx)
defer wfExecutor.HandleError(bgCtx)
defer wfExecutor.FinalizeOutput(bgCtx) //Ensures the LabelKeyReportOutputsCompleted is set to true.

err := wfExecutor.Data(ctx)
if err != nil {
wfExecutor.AddError(err)
return err
}
return nil
}
9 changes: 8 additions & 1 deletion cmd/argoexec/commands/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,19 @@ func NewResourceCommand() *cobra.Command {

func execResource(ctx context.Context, action string) error {
wfExecutor := initExecutor()
defer wfExecutor.HandleError(ctx)

// Don't allow cancellation to impact capture of results, parameters, artifacts, or defers.
bgCtx := context.Background()

wfExecutor.InitializeOutput(bgCtx)
defer wfExecutor.HandleError(bgCtx)
defer wfExecutor.FinalizeOutput(bgCtx) //Ensures the LabelKeyReportOutputsCompleted is set to true.
err := wfExecutor.StageFiles()
if err != nil {
wfExecutor.AddError(err)
return err
}

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")
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/functional_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})
}

Expand Down
3 changes: 3 additions & 0 deletions test/e2e/resource_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})
}

Expand Down

0 comments on commit a155877

Please sign in to comment.