-
Notifications
You must be signed in to change notification settings - Fork 503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
monitor: add debug-shell
and on-error
#1640
Conversation
Ready for review about codes but it seems that documents didn't pass CI but |
3328ff8
to
f2f69fb
Compare
e62de33
to
bdd643d
Compare
4d73bc7
to
f2f69fb
Compare
f2f69fb
to
f18bd40
Compare
f18bd40
to
df16bae
Compare
CI failure seems unrelated to the change. https://github.com/docker/buildx/actions/runs/4301437650/jobs/7498699046#step:10:63
|
df16bae
to
0ac64b8
Compare
All green 🎉 |
0ac64b8
to
c7f16e3
Compare
@jedevc @tonistiigi @crazy-max Rebased, PTAL 🙏 |
c7f16e3
to
7beb3c2
Compare
Could we move this PR and related ones forward? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I had some pending comments and forgot to post them - I'll try and take a more in-depth look asap.
case "on-error": | ||
// NOTE: we overwrite the command to run because the original one should fail on the failed step. | ||
// TODO: make this configurable. | ||
cfg.Cmd = []string{"/bin/sh"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fact that we don't have any idea what the shell at this point during execution is kinda sad 😢
For some reason, this feels familiar, like I've had this discussion before somewhere - but can't remember where 🤔 Regardless, I think we should follow-up with a buildkit patch to somehow store the current shell into the LLB? That way, when attaching a debugger, we can always find the right shell configuration to use. I guess this applies to trying to find the working directory and similar (if we try and invoke at a vertex that isn't a ExecOp).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM
switch op := solveErr.Solve.Op.GetOp().(type) { | ||
case *pb.Op_Exec: | ||
return op.Exec, nil | ||
default: | ||
return nil, errors.Errorf("invoke: unsupported error type") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to support this on other OpTypes? e.g. if a copy fails, would we want to be able to break there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM. It looks like that the error doesn't propagates the execution information (e.g. args,usr,cwd,envvar,...) on non-exec steps so we need to modify BuildKit maybe. We also need to think about the UI for how to make COPY's source and/or destination visible to the user.
152318d
to
ea63f48
Compare
Thanks for the comment. Created separate commits for changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for splitting up commits a bit more, it's significantly easier to look through a review 🎉 Looks like the split has a few chunks in the wrong commits though, each commit should be self-contained and compile by itself.
Aside from that, just a couple minor comments, otherwise I'm happy 🎉
Signed-off-by: Kohei Tokunaga <[email protected]>
ea63f48
to
0e60410
Compare
Signed-off-by: Kohei Tokunaga <[email protected]>
Signed-off-by: Kohei Tokunaga <[email protected]>
Signed-off-by: Kohei Tokunaga <[email protected]>
Signed-off-by: Kohei Tokunaga <[email protected]>
Signed-off-by: Kohei Tokunaga <[email protected]>
Signed-off-by: Kohei Tokunaga <[email protected]>
0e60410
to
fd5d90c
Compare
I would say that before we merge #1656, I'd like to see a couple follow-ups to this:
|
Thank you for the suggestion. SGTM. |
@ktock I quickly hit a couple of issues just now (though this seems to be an issue before this PR tbf):
|
Another thing, we seem to keep getting tripped up here: Line 32 in ba6e5cd
If the result is empty, because we did a This doesn't just break for |
Related to #1104
debug-shell
subcommandThis directly starts the monitor without performing the build.
Users can also attach to other sessions (if any) and perform reload, rollback, etc... in that session.
On terminal 1:
On terminal 2:
--invoke=debug-shell
This directly starts the monitor without performing the build.
Users can also attach to other sessions (if any) and perform reload, rollback, etc... in that session.
The difference between this and
debug-shell
subcommand is that--invoke=debug-shell
allows performingreload
with the specified arguments of thebuildx build
and starting a new session based on that result.--invoke=on-error
The container is invoked based on the state of the error returned by BuildKit.
Buildx controller saves that state and returns a typed error that contains the reference to that state and the client(monitor) uses it for starting containers/processes. For the typed error, we use the same logic as BuildKit does in
errdefs.SolveError
etc.rollback --init
command allows to start the container on the initial state of the failed step instead of the result state.