-
Notifications
You must be signed in to change notification settings - Fork 615
remote controller: Fix entrypoint interaction bugs #1970
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
Conversation
| args = append(args, img.Config.Entrypoint...) | ||
| } | ||
| if cfg.Cmd != nil { | ||
| if !cfg.NoCmd { |
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.
Just wondering, would it be possible to just change this to len(cfg.Cmd) != 0 for a simpler fix?
Can a user actually specify an empty cmd? I'm not sure if this has a parallel with docker run (cc @tianon)
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.
This logic was hard for me to reason about, so I'm going to give some examples of docker run behavior in the hopes that it helps make things more clear. 😅
Given an image with ENTRYPOINT set to a and CMD set to b (keeping these intentionally simple and including the obvious ones too -- let's not get into shell form vs JSON form because that gets nasty and doesn't really change this basic operation very much 😂):
docker run img-> runsa bdocker run img c-> runsa cdocker run --entrypoint c img-> runsc(noa, but more importantly nobalso!)docker run --entrypoint c img d->c d
In other words, the behavior is similar to that of ENTRYPOINT within a Dockerfile - if it's specified, it resets CMD (so we have to detect command from the CLI separate from command from the image).
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 the explanation! Based on the examples, len(cfg.Cmd) != 0 doesn't look like a solution here because it doesn't implement the behaviour of docker run --entrypoint c img (--invoke entrypoint=c on buildx) that specifies an empty cmd and needs to ignore the image's default.
controller/pb/controller.proto
Outdated
| bool Tty = 8; | ||
| bool Rollback = 9; // Kill all process in the container and recreate it. | ||
| bool Initial = 10; // Run container from the initial state of that stage (supported only on the failed step) | ||
| bool NoCmd = 11; // Do not set cmd but use the image's default |
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.
Can we put this after the Cmd field? We can keep the number the same, but would be good to group them together.
Signed-off-by: Kohei Tokunaga <[email protected]>
|
CI failure doesn't seem to be related to this PR ? 🤔 |
Following-up: #1870
This commit tries to fix the same issue as #1870 for remote controller mode as well. For remote controller, the root cause of this issue is that buildx can't distinguish
InvokeConfig.Cmdbeing unset(nil) and zero-length([]string{}) over protobuf.This commit fixes this by introducing a new field
InvokeConfig.NoCmd(bool) for explicitly separating the above cases.In the future, we can upgrade protoc to the recent version and use optional fields but I'm not sure we can safely do this now because proto files in buildx heavily import buildkit's assets.
Testing with Dockerifle
On master version,
--invoke entrypoint=shandexec shreturn the following because it tries to runsh shand this PR fixes this error.