Repository navigation
Enhanced debugging errors for context cancelled from Buildkit - #8553
Merged
Merged
Conversation
sipsma
force-pushed
the
more-ctx-cancel
branch
from
September 23, 2024 22:04
e807ac6 to
7b0c219
Compare
jedevc
approved these changes
Sep 24, 2024
Previously we started logging buildkit solve errors with a `%+v` in order to reveal the stack traces embedded in the errors by buildkit's usage of github.com/pkg/errors, which in many places in buildkit is the only way to get any extra information on where an error is actually coming from (needed for debugging "context cancelled" errors specifically). This did not quite work for a pretty dumb reason: it turns out that if you wrap an error from github.com/pkg/errors using fmt.Errorf (i.e. the standard library) then the trick for extracting the stack trace from the github.com/pkg/errors annotated error doesn't work anymore. This is all quite silly, but in the interest of being able to debug these context cancelled errors the change in this commit moves the log statements of the errors with `%+v` to places *before* we do any wrapping with the standard library, allowing us to see the stack traces. I tested this by modifying buildkit locally to return errors from the compute cache key step where we see this flake in CI and then verifying the logs actually reveal the stack trace now. Signed-off-by: Erik Sipsma <[email protected]>
There's reluctance upstream in buildkit to include messages in each context cancel cause error, so instead we have to extract out the embedded stack trace in each error, attempt to parse a line number from the stack trace and include that in the user facing error message. This keeps the user facing error somewhat succinct (i.e. not a huge stack trace) while still making it a bit easier to debug this if users hit this and can't/won't send us their full engine logs. Signed-off-by: Erik Sipsma <[email protected]>
sipsma
force-pushed
the
more-ctx-cancel
branch
from
September 24, 2024 17:41
7b0c219 to
55e31cd
Compare
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.
Related to #7699
Two related commits here:
engine: log buildkit errors in right place to reveal stack traces
Previously we started logging buildkit solve errors with a
%+vinorder to reveal the stack traces embedded in the errors by buildkit's
usage of github.com/pkg/errors, which in many places in buildkit is the
only way to get any extra information on where an error is actually
coming from (needed for debugging "context cancelled" errors
specifically).
This did not quite work for a pretty dumb reason: it turns out that if
you wrap an error from github.com/pkg/errors using fmt.Errorf (i.e. the
standard library) then the trick for extracting the stack trace from
the github.com/pkg/errors annotated error doesn't work anymore.
This is all quite silly, but in the interest of being able to debug
these context cancelled errors the change in this commit moves the log
statements of the errors with
%+vto places before we do anywrapping with the standard library, allowing us to see the stack traces.
I tested this by modifying buildkit locally to return errors from the
compute cache key step where we see this flake in CI and then verifying
the logs actually reveal the stack trace now.
Signed-off-by: Erik Sipsma [email protected]
engine: extract buildkit error stack trace lines into err msgs
There's reluctance upstream in buildkit to include messages in each
context cancel cause error, so instead we have to extract out the
embedded stack trace in each error, attempt to parse a line number from
the stack trace and include that in the user facing error message.
This keeps the user facing error somewhat succinct (i.e. not a huge
stack trace) while still making it a bit easier to debug this if users
hit this and can't/won't send us their full engine logs.
Signed-off-by: Erik Sipsma [email protected]