Skip to content

Enhanced debugging errors for context cancelled from Buildkit - #8553

Merged
sipsma merged 2 commits into
dagger:mainfrom
sipsma:more-ctx-cancel
Sep 24, 2024
Merged

sipsma merged 2 commits into
dagger:mainfrom
sipsma:more-ctx-cancel

Conversation

@sipsma

@sipsma sipsma commented Sep 23, 2024

Copy link
Copy Markdown
Contributor

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 %+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]


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]

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
sipsma merged commit c7f8244 into dagger:main Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants