Support launching shell on a build step for debugging #2813
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.
It would be great if BuildKit supports interactive debugging of each step of a build by launching shell via
buildctl
. This patch is an initial PoC toward that feature. Any feedback about the current design and implementation are very welcome.plain
is supported as of now).--debug-build
option ofbuildctl build
defers the cleanup of resources related to the build job until the user explicitly runsbuildctl debug close <JOB-ID>
.buildctl debug shell
allows the user launching shell on an arbitrary vertex as long as its op supports process execution (only execOp is supported as of now).The following is an example of debugging a failed build.
This build can be debugged using the ID printed in the above log (
oywfw5gz2f2avxvtmk4b18mru
).For example, we debug
RUN cat /non-existing-file
.In the above log, this RUN execution is printed as the following:
This prints the digest of the vertex where the RUN is executed. We can use it for
buildctl debug shell
command to launch a shell on that vertex.Finally, job-related resouces needs to be released using
buildctl debug close oywfw5gz2f2avxvtmk4b18mru
.Some considerations
github.com/moby/buildkit/frontend/gateway
package for launching a shell process. Maybe we should move the process-execution-related logic into a separated common package.TODOs
Future works