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

Allow passing the OCI runtime an empty command #21312

Merged
merged 1 commit into from
Jan 23, 2024

Conversation

albertofaria
Copy link
Member

Some OCI runtimes (cf. [1]) may tolerate container images that don't specify an entrypoint together with no entrypoint being specified in the command line. In those cases, it's annoying for the user to have to pass a "" argument to podman.

[1] https://github.com/containers/crun-vm

Does this PR introduce a user-facing change?

podman-create and podman-run no longer require specifying an entrypoint on the command line when the container image does not define one. In this case, an empty command will be passed to the OCI runtime, and the resulting behavior is runtime-specific.

@rhatdan
Copy link
Member

rhatdan commented Jan 20, 2024

You need to add [NO NEW TESTS NEEDED] or add a test to allow tests to run.

What does crun report if you don't have an entrypoint or cmd in the image?

@rhatdan
Copy link
Member

rhatdan commented Jan 20, 2024

/approve
LGTM

@vrothberg
Copy link
Member

You need to add [NO NEW TESTS NEEDED] or add a test to allow tests to run.

Since it's a new behavior, we really need a test.

@giuseppe PTAL

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

I am not sure how the runtimes would deal with it. Assuming we go forward, a debug log may be appropriate to leave some breadcrumbs.

@giuseppe
Copy link
Member

could we just use a dummy entrypoint for the image?

With this change, the error code is more difficult to understand:

$ bin/podman --runtime crun run --entrypoint="" --rm -ti alpine 
{"msg":"executable path not specified","level":"error","time":"2024-01-22T11:20:52.470646Z"}
$ bin/podman --runtime runc run --entrypoint="" --rm -ti alpine 
Error: OCI runtime error: runc: runc create failed: args must not be empty

The nice thing about catching it early in Podman is that we can give a suggestion about either the CMD or ENTRYPOINT being empty, which is not known to the OCI runtime:

$ podman run --entrypoint="" --rm -ti alpine 
Error: no command or entrypoint provided, and no CMD or ENTRYPOINT from image

@rhatdan
Copy link
Member

rhatdan commented Jan 22, 2024

Would it make sense to default the entrypoint to "/bin/sh -c" for this case rather then failing, with a Debug message stating the default?

@vrothberg
Copy link
Member

Would it make sense to default the entrypoint to "/bin/sh -c" for this case rather then failing, with a Debug message stating the default?

Let's figure out what Docker does. We aim at being compatible but for sure can punch some holes where needed.

@albertofaria
Copy link
Member Author

Would it make sense to default the entrypoint to "/bin/sh -c" for this case rather then failing, with a Debug message stating the default?

Let's figure out what Docker does. We aim at being compatible but for sure can punch some holes where needed.

Docker also complains when there is no entrypoint: docker: Error response from daemon: No command specified.

@rhatdan
Copy link
Member

rhatdan commented Jan 22, 2024

I think it is fine to be compatibile with Docker, but we can do better in this case. Bottom line, I don't want a failure if running an OCI Runtime that does not require a command and a command makes little sense when running a image.

podman run --runtime crun-vm --rootfs PATHTOQCOW "" sucks.
podman run --runtime crun-vm --rootfs PATHTOQCOW is much better.
If I have to do
docker run --runtime crun-vm --rootfs PATHTOQCOW codx not work.

@albertofaria
Copy link
Member Author

You need to add [NO NEW TESTS NEEDED] or add a test to allow tests to run.

Since it's a new behavior, we really need a test.

Are we talking of unit tests or integration tests? Where should this test go?

@rhatdan
Copy link
Member

rhatdan commented Jan 22, 2024

I would test with system tests.
tests/system ...

Basically build an image with Command="" and Entrypoint="" then try to run it.

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 22, 2024
@albertofaria
Copy link
Member Author

This new version passes the OCI runtime an empty string entrypoint instead of no entrypoint at all, so that the resulting error message is the same as if an inexistent entrypoint was set.

@TomSweeneyRedHat
Copy link
Member

Changes LGTM, but the tests are very red.

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

LGTM

pkg/specgen/generate/oci.go Show resolved Hide resolved
Copy link
Contributor

openshift-ci bot commented Jan 23, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: albertofaria, rhatdan, vrothberg

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

Some OCI runtimes (cf. [1]) may tolerate container images that don't
specify an entrypoint even if no entrypoint is given on the command
line. In those cases, it's annoying for the user to have to pass a ""
argument to podman.

If no entrypoint is given, make the behavior the same as if an empty ""
entrypoint was given.

[1] https://github.com/containers/crun-vm

Signed-off-by: Alberto Faria <afaria@redhat.com>
@albertofaria
Copy link
Member Author

The single test failure seems to be transient.

@vrothberg
Copy link
Member

The single test failure seems to be transient.

Yes, that job flakes a lot at the moment. I restarted it ✔️

@rhatdan
Copy link
Member

rhatdan commented Jan 23, 2024

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 23, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit fcac504 into containers:main Jan 23, 2024
91 of 92 checks passed
@albertofaria albertofaria deleted the no-entrypoint branch January 23, 2024 12:53
@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 Apr 23, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 23, 2024
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. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants