Skip to content

Commit

Permalink
fix(executor): Improve artifact error messages. Fixes #6070 (#6086)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Collins <[email protected]>
  • Loading branch information
alexec committed Jun 8, 2021
1 parent d37f748 commit 0e37f66
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
6 changes: 3 additions & 3 deletions workflow/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,12 @@ func (we *WorkflowExecutor) LoadArtifacts(ctx context.Context) error {
log.Warnf("Ignoring optional artifact '%s' which was not supplied", art.Name)
continue
} else {
return errors.Errorf("required artifact %s not supplied", art.Name)
return errors.Errorf(errors.CodeNotFound, "required artifact '%s' not supplied", art.Name)
}
}
driverArt, err := we.newDriverArt(&art)
if err != nil {
return err
return fmt.Errorf("failed to load artifact '%s': %w", art.Name, err)
}
artDriver, err := we.InitDriver(ctx, driverArt)
if err != nil {
Expand Down Expand Up @@ -189,7 +189,7 @@ func (we *WorkflowExecutor) LoadArtifacts(ctx context.Context) error {
log.Infof("Skipping optional input artifact that was not found: %s", art.Name)
continue
}
return err
return fmt.Errorf("artifact %s failed to load: %w", art.Name, err)
}

isTar := false
Expand Down
40 changes: 40 additions & 0 deletions workflow/executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,46 @@ const (
fakeContainerName = "main"
)

func TestWorkflowExecutor_LoadArtifacts(t *testing.T) {
tests := []struct {
name string
artifact wfv1.Artifact
error string
}{
{"ErrNotSupplied", wfv1.Artifact{Name: "foo"}, "required artifact 'foo' not supplied"},
{"ErrFailedToLoad", wfv1.Artifact{
Name: "foo",
ArtifactLocation: wfv1.ArtifactLocation{
S3: &wfv1.S3Artifact{
Key: "my-key",
},
},
}, "failed to load artifact 'foo': template artifact location not set"},
{"ErrNoPath", wfv1.Artifact{
Name: "foo",
ArtifactLocation: wfv1.ArtifactLocation{
S3: &wfv1.S3Artifact{
S3Bucket: wfv1.S3Bucket{Endpoint: "my-endpoint", Bucket: "my-bucket"},
Key: "my-key",
},
},
}, "Artifact foo did not specify a path"},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
we := WorkflowExecutor{
Template: wfv1.Template{
Inputs: wfv1.Inputs{
Artifacts: []wfv1.Artifact{test.artifact},
},
},
}
err := we.LoadArtifacts(context.Background())
assert.EqualError(t, err, test.error)
})
}
}

func TestSaveParameters(t *testing.T) {
fakeClientset := fake.NewSimpleClientset()
mockRuntimeExecutor := mocks.ContainerRuntimeExecutor{}
Expand Down

0 comments on commit 0e37f66

Please sign in to comment.