GoogleContainerTools / GoogleContainerTools/skaffold

ShowAIError unwraps and discards additional error information

Open
#6,909 0 comments 0 reactions 0 assignees View on GitHub
area/errors kind/bug
Dominant language
Go
Stars
15.9k
Forks
1.7k
Avg merge
3d 9h
Merged PRs (30d)
10

Description

#6126 involves a build failure occurring during a concurrent multi-artifact build, and the final error message does not indicate which artifact failed. I changed our build code to wrap the build error with the failing artifact name intending that it should be emitted as part of the final error output from Skaffold:
```diff
--- pkg/skaffold/build/scheduler.go
+++ pkg/skaffold/build/scheduler.go
@@ -112,19 +112,22 @@ func (s *scheduler) build(ctx context.Context, tags tag.ImageTags, i int) error
finalTag, err := performBuild(ctx, w, tags, a, s.artifactBuilder)
if err != nil {
event.BuildFailed(a.ImageName, err)
+ endTrace(instrumentation.TraceEndError(err))
if errors.Is(ctx.Err(), context.Canceled) {
output.Yellow.Fprintf(w, "Canceled build for %s\n", a.ImageName)
eventV2.BuildCanceled(a.ImageName, err)
+ return err
- } else {
- eventV2.BuildFailed(a.ImageName, err)
}
- endTrace(instrumentation.TraceEndError(err))
- return err
+ output.Red.Fprintf(w, "Build [%s] failed\n", a.ImageName) // the error is reported at the end
+ eventV2.BuildFailed(a.ImageName, err)
+ return fmt.Errorf("build [%s] failed: %w", a.ImageName, err)
}
```

To my susprise the "`build [%s] failed: `" text was discarded in the final output text from Skaffold (the failure was in `leeroy-web`):
```
Canceled build for [leeroy-app]
unable to stream build output: The command '/bin/sh -c exit 1' returned a non-zero code: 1. Please fix the Dockerfile and try again..
```

It turns out that `ShowAIError()` unwraps a single-level of the error looking for an actionable error. If found, it discards the original error:
https://github.com/GoogleContainerTools/skaffold/blob/6e95e61c14607df62fbed0133d716160345d39d6/pkg/skaffold/errors/errors.go#L90-L94

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.