Skip to content

Commit

Permalink
fix: Mark resource && data report-outputs-completed true
Browse files Browse the repository at this point in the history
Signed-off-by: shuangkun <tsk2013uestc@163.com>
  • Loading branch information
shuangkun committed Jan 18, 2024
1 parent 2bb770e commit de7fb0c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
27 changes: 23 additions & 4 deletions cmd/argoexec/commands/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,37 @@ 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()
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
}
5 changes: 5 additions & 0 deletions cmd/argoexec/commands/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
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 de7fb0c

Please sign in to comment.