Skip to content
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

Do not use image CMD if user gave ENTRYPOINT #7256

Merged

Conversation

mheon
Copy link
Member

@mheon mheon commented Aug 7, 2020

This matches Docker behavior, and seems to make sense - the CMD may have been specific to the original entrypoint and probably does not make sense if it was changed.

While we're in here, greatly simplify the logic for populating the SpecGen's Command. We create the full command when making the OCI spec, so the client should not be doing any more than setting it to the Command the user passed in, and completely ignoring ENTRYPOINT.

Fixes #7115

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mheon

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 7, 2020
@zhangguanzhang
Copy link
Collaborator

zhangguanzhang commented Aug 8, 2020

https://github.com/containers/podman/pull/7256/checks?check_run_id=959383018

[+0215s] # $ /var/tmp/go/src/github.com/containers/podman/bin/podman-remote --url unix:/tmp/podman.nUsXlU exec f99281f82ea12b5d50e5374a5925dd48f96f09e4f42c4bb50df939c3860f6b13 /no/such/command
[+0215s] # executable file not found in $PATH: No such file or directory: OCI runtime command not found error
[+0215s] # [ rc=127 (expected) ]
[+0215s] # $ /var/tmp/go/src/github.com/containers/podman/bin/podman-remote --url unix:/tmp/podman.nUsXlU exec f99281f82ea12b5d50e5374a5925dd48f96f09e4f42c4bb50df939c3860f6b13 rm -f /IsumOdgf06ffBkW1SwMJ
[+0215s] # $ /var/tmp/go/src/github.com/containers/podman/bin/podman-remote --url unix:/tmp/podman.nUsXlU wait f99281f82ea12b5d50e5374a5925dd48f96f09e4f42c4bb50df939c3860f6b13
[+0215s] # timeout: sending signal TERM to command ‘/var/tmp/go/src/github.com/containers/podman/bin/podman-remote’
[+0215s] # [ rc=124 (** EXPECTED 0 **) ]

These lines did not work as expected for some reason https://github.com/containers/podman/blob/master/test/system/075-exec.bats#L31-L33
can come here to discuss this issue #7241

This matches Docker behavior, and seems to make sense - the CMD
may have been specific to the original entrypoint and probably
does not make sense if it was changed.

While we're in here, greatly simplify the logic for populating
the SpecGen's Command. We create the full command when making the
OCI spec, so the client should not be doing any more than setting
it to the Command the user passed in, and completely ignoring
ENTRYPOINT.

Fixes containers#7115

Signed-off-by: Matthew Heon <[email protected]>
@mheon mheon force-pushed the fix_cmd_with_entrypoint branch from 927467d to 39c493b Compare August 10, 2020 14:18
@mheon
Copy link
Member Author

mheon commented Aug 10, 2020

Rebased, should go green now

@mheon
Copy link
Member Author

mheon commented Aug 10, 2020

@edsantiago
Copy link
Member

LGTM. Thank you for adding a test - the BATS test that caught this is actually blocked by #7116, which may not actually be a bug, so we currently have no system-test coverage for this. If #7116 never gets fixed I'll find a way to re-add that coverage.

@TomSweeneyRedHat
Copy link
Member

LGTM
I thought this wasn't going to work right for some Dockerfiles, but I tested a number that I have and they all worked fine.

command := s.Command
if command == nil && img != nil {
if command == nil && img != nil && s.Entrypoint == nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if image has a entrypoint and the command is not nil? Isn't it supposed to still be
entrypoint + command?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, we will append command to entrypoint as normal. This block only handles getting CMD from the image if the user didn't give us a command.

@rhatdan
Copy link
Member

rhatdan commented Aug 10, 2020

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 10, 2020
@openshift-merge-robot openshift-merge-robot merged commit 75d2fe6 into containers:master Aug 10, 2020
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 24, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

podman-remote: run --entrypoint: extra /bin/sh somewhere
7 participants