Repository navigation
Include output of failed exec in error message. - #4161
Merged
Merged
Conversation
sipsma
force-pushed
the
exec-error
branch
2 times, most recently
from
December 12, 2022 20:50
c7f4ce5 to
f614de1
Compare
Signed-off-by: Erik Sipsma <[email protected]>
sipsma
marked this pull request as ready for review
December 12, 2022 21:00
vito
approved these changes
Dec 12, 2022
Comment on lines
+91
to
+106
| stdoutFile, err := os.Open(stdoutPath) | ||
| if err != nil && !os.IsNotExist(err) { | ||
| panic(err) | ||
| } | ||
| _, err = io.Copy(os.Stdout, stdoutFile) | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
| stderrFile, err := os.Open(stderrPath) | ||
| if err != nil && !os.IsNotExist(err) { | ||
| panic(err) | ||
| } | ||
| _, err = io.Copy(os.Stderr, stderrFile) | ||
| if err != nil { | ||
| panic(err) | ||
| } |
Contributor
There was a problem hiding this comment.
If/when we do #3496 it might be a good idea to use the "combined" stream so the user sees how the output would have looked in a terminal. 🤔
Comment on lines
+74
to
+87
| var se *errdefs.SolveError | ||
| if errors.As(returnErr, &se) { | ||
| // Ensure we don't get blocked trying to return an error by enforcing a timeout | ||
| ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) | ||
| defer cancel() | ||
|
|
||
| op := se.Op | ||
| if op == nil || op.Op == nil { | ||
| return | ||
| } | ||
| execOp, ok := se.Op.Op.(*pb.Op_Exec) | ||
| if !ok { | ||
| return | ||
| } |
Contributor
Author
Contributor
|
Just want to say: 🤯 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Signed-off-by: Erik Sipsma [email protected]
Fixes #3025
I looked a bit into the upcoming build history API in buildkit v0.11 but realized the way its implemented makes it very hard to use for this case (it's all the progress for the whole build, not just one exec), so I think the approach in this pr, while inherently ugly, to be the only viable way.
We use a secret feature of buildkit that lets you obtain the mounts of a failed exec and use them in
NewContainercalls. We then create a NewContainer with the meta mount of the failed exec and tell our shim to just output the contents of it.Example error message:
Important cleanups needed before merge: