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

utils: improve error message if path not executable #1672

Merged

Conversation

giuseppe
Copy link
Member

improve the error returned when the specified path is not executable.

Return the reason why the lookup failed when the path is not a regular file, or has no executable bit set.

Closes: #1671

Copy link

podman system tests failed. @containers/packit-build please check.

{
*out = xstrdup (executable_path);
return 0;
}
Copy link
Member

Choose a reason for hiding this comment

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

There seems to be no return here anymore which means even in the absolute path you fall back to looking up PATH. That seems wrong? should this set last_error = ret and then have en else branch for the PATH lookup?

@giuseppe giuseppe force-pushed the improve-error-message-path-not-executable branch from 39abc01 to 8f3e370 Compare February 14, 2025 11:43
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

2025-02-14T12:04:23.5782745Z Summarizing 8 Failures:
2025-02-14T12:04:23.5783188Z   [FAIL] Podman exec [It] podman exec cannot be invoked
2025-02-14T12:04:23.5783867Z   /root/go/src/github.com/containers/podman/test/e2e/exec_test.go:436
2025-02-14T12:04:23.5784630Z   [FAIL] Podman run [It] podman run --rm failed container should delete itself
2025-02-14T12:04:23.5785117Z   /root/go/src/github.com/containers/podman/test/e2e/run_test.go:1453
2025-02-14T12:04:23.5785606Z   [FAIL] Podman run [It] podman run failed container should NOT delete itself
2025-02-14T12:04:23.5786107Z   /root/go/src/github.com/containers/podman/test/e2e/run_test.go:1465
2025-02-14T12:04:23.5786731Z   [FAIL] Podman run exit [It] podman run exit ExecErrorCodeCannotInvoke
2025-02-14T12:04:23.5787542Z   /root/go/src/github.com/containers/podman/test/e2e/run_exit_test.go:25
2025-02-14T12:04:23.5789852Z   [FAIL] Podman run exit [It] podman run exit ExecErrorCodeNotFound
2025-02-14T12:04:23.5790572Z   /root/go/src/github.com/containers/podman/test/e2e/run_exit_test.go:31
2025-02-14T12:04:23.5791262Z   [FAIL] Podman start [It] podman start --rm removed on failure
2025-02-14T12:04:23.5791928Z   /root/go/src/github.com/containers/podman/test/e2e/start_test.go:41
2025-02-14T12:04:23.5792629Z   [FAIL] Podman start [It] podman start --rm --attach removed on failure
2025-02-14T12:04:23.5793331Z   /root/go/src/github.com/containers/podman/test/e2e/start_test.go:54
2025-02-14T12:04:23.5794023Z   [FAIL] Podman run entrypoint [It] podman run no command, entrypoint, or cmd
2025-02-14T12:04:23.5794747Z   /root/go/src/github.com/containers/podman/test/e2e/run_entrypoint_test.go:21

That is not blocker of course but something we should fix ahead of time in podman I think, though one thing I noticed in "podman run failed container should NOT delete itself"

$ bin/podman --runtime /home/pholzing/CODE/crun/crun run --rm quay.io/libpod/testimage:20241011 blah
Error: /home/pholzing/CODE/crun/crun: cannot find executable `blah`: No such file or directory: OCI runtime attempted to invoke a command that was not found

# with current crun
$ bin/podman --runtime crun run --rm quay.io/libpod/testimage:20241011 blah
Error: crun: executable file `blah` not found in $PATH: No such file or directory: OCI runtime attempted to invoke a command that was not found

The not found in $PATH is missing now and I think that has some value to know that crun checks PATH so maybe consider keeping it?
Aside from that LGTM, I agree that the new message is overall better

@giuseppe giuseppe force-pushed the improve-error-message-path-not-executable branch 2 times, most recently from 072dba0 to 3bf019e Compare February 14, 2025 12:54
@giuseppe giuseppe force-pushed the improve-error-message-path-not-executable branch from 3bf019e to 2cd3915 Compare February 14, 2025 15:34
@eriksjolund
Copy link
Contributor

eriksjolund commented Feb 14, 2025

$ podman --runtime  ~/cruninstall/bin/crun   run --rm docker.io/library/alpine blah/blah
Error: /var/home/core/cruninstall/bin/crun: executable file `//blah/blah` not found: No such file or directory: OCI runtime attempted to invoke a command that was not found

not important but a small improvement would be changing // to /

update

or show the error in runc style:

$ podman --runtime runc  run --rm docker.io/library/alpine blah/blah
Error: runc: runc create failed: unable to start container process: error during container init: exec: "blah/blah": stat blah/blah: no such file or directory: OCI runtime attempted to invoke a command that was not found

@giuseppe giuseppe force-pushed the improve-error-message-path-not-executable branch from 2cd3915 to ec6e413 Compare February 14, 2025 16:01
@giuseppe
Copy link
Member Author

$ podman --runtime  ~/cruninstall/bin/crun   run --rm docker.io/library/alpine blah/blah
Error: /var/home/core/cruninstall/bin/crun: executable file `//blah/blah` not found: No such file or directory: OCI runtime attempted to invoke a command that was not found

not important but a small improvement would be changing // to /

what do you think of the new version?

@eriksjolund
Copy link
Contributor

what do you think of the new version?

$ podman --runtime  ~/cruninstall/bin/crun run --rm docker.io/library/alpine blah/blah
Error: /var/home/core/cruninstall/bin/crun: executable file `/blah/blah` not found: No such file or directory: OCI runtime attempted to invoke a command that was not found

lgtm

@giuseppe giuseppe force-pushed the improve-error-message-path-not-executable branch 2 times, most recently from 0dfca41 to 9ada14f Compare February 14, 2025 16:46
@giuseppe
Copy link
Member Author

how do we move forward with the Podman tests?

I think we should just drop that checks, there is no guarantee about the error messages and makes testing of different versions more difficult than it should be.

@Luap99
Copy link
Member

Luap99 commented Feb 14, 2025

I think we should just drop that checks, there is no guarantee about the error messages and makes testing of different versions more difficult than it should be.

We should not drop error message checks, the reason we must do that is because people keep adding tests for errors that caused a totally different error and if you don't check the message you will never find out.
containers/podman#18188

The way to move forward is to change the string we match, if there is a partial overlap between the old and new error we can use that (assuming it is still useful and not just "error")
If there is no way to do a meaningful match we need to match both new or old message, given these are only a few test cases I don't think it is a big deal. If you don't want to deal with that part I can do that on Monday.

@giuseppe
Copy link
Member Author

We should not drop error message checks, the reason we must do that is because people keep adding tests for errors that caused a totally different error and if you don't check the message you will never find out. containers/podman#18188

The way to move forward is to change the string we match, if there is a partial overlap between the old and new error we can use that (assuming it is still useful and not just "error") If there is no way to do a meaningful match we need to match both new or old message, given these are only a few test cases I don't think it is a big deal. If you don't want to deal with that part I can do that on Monday.

sorry for bothering you so late on a Friday night.

I know the rationale behind these checks, but I still disagree with that because it is not possible to test with different OCI runtimes.

In any case, I'll take care of these incompatibilities, since I am introducing them :-)

@giuseppe giuseppe force-pushed the improve-error-message-path-not-executable branch from 9ada14f to 12bd6a8 Compare February 14, 2025 20:19
@giuseppe giuseppe marked this pull request as draft February 15, 2025 12:04
giuseppe added a commit to giuseppe/libpod that referenced this pull request Feb 17, 2025
@giuseppe giuseppe force-pushed the improve-error-message-path-not-executable branch from 12bd6a8 to 1437baa Compare February 17, 2025 08:15
@giuseppe
Copy link
Member Author

@Luap99 opened a PR for Podman: containers/podman#25340

@giuseppe giuseppe force-pushed the improve-error-message-path-not-executable branch from 1437baa to 9fdb879 Compare February 17, 2025 08:41
giuseppe added a commit to giuseppe/libpod that referenced this pull request Feb 17, 2025
giuseppe added a commit to giuseppe/libpod that referenced this pull request Feb 17, 2025
giuseppe added a commit to giuseppe/libpod that referenced this pull request Feb 17, 2025
giuseppe added a commit to giuseppe/libpod that referenced this pull request Feb 17, 2025
@giuseppe giuseppe force-pushed the improve-error-message-path-not-executable branch from 9fdb879 to 8f9d583 Compare February 18, 2025 07:16
giuseppe added a commit to giuseppe/libpod that referenced this pull request Feb 18, 2025
unify the error codes returned by runc and crun.

Fix the tests to work with both runtimes, as well as the
containers/crun#1672 changes in progress for
crun.

Follow-up for containers#25340

Signed-off-by: Giuseppe Scrivano <[email protected]>
@giuseppe giuseppe force-pushed the improve-error-message-path-not-executable branch from 8f9d583 to 4f0333b Compare February 18, 2025 10:20
giuseppe added a commit to giuseppe/libpod that referenced this pull request Feb 18, 2025
unify the error codes returned by runc and crun.

Fix the tests to work with both runtimes, as well as the
containers/crun#1672 changes in progress for
crun.

Follow-up for containers#25340

Signed-off-by: Giuseppe Scrivano <[email protected]>
giuseppe added a commit to giuseppe/libpod that referenced this pull request Feb 18, 2025
unify the error codes returned by runc and crun.

Fix the tests to work with both runtimes, as well as the
containers/crun#1672 changes in progress for
crun.

Follow-up for containers#25340

Signed-off-by: Giuseppe Scrivano <[email protected]>
@giuseppe giuseppe force-pushed the improve-error-message-path-not-executable branch from 4f0333b to 5c7dca7 Compare February 18, 2025 11:53
@giuseppe giuseppe marked this pull request as ready for review February 18, 2025 12:24
@giuseppe giuseppe marked this pull request as draft February 18, 2025 12:24
@giuseppe giuseppe force-pushed the improve-error-message-path-not-executable branch from 5c7dca7 to 013f69c Compare February 18, 2025 12:38
Signed-off-by: Giuseppe Scrivano <[email protected]>
if a handler is specified, do not return an early error if the
executable path could not be found.

Signed-off-by: Giuseppe Scrivano <[email protected]>
Signed-off-by: Giuseppe Scrivano <[email protected]>
improve the error returned when the specified path is not executable.

Return the reason why the lookup failed when the path is not a regular
file, or has no executable bit set.

Closes: containers#1671

Signed-off-by: Giuseppe Scrivano <[email protected]>
@giuseppe giuseppe force-pushed the improve-error-message-path-not-executable branch from 013f69c to 5393867 Compare February 18, 2025 14:10
giuseppe added a commit to giuseppe/libpod that referenced this pull request Feb 18, 2025
unify the error codes returned by runc and crun.

Fix the tests to work with both runtimes, as well as the
containers/crun#1672 changes in progress for
crun.

Follow-up for containers#25340

Signed-off-by: Giuseppe Scrivano <[email protected]>
giuseppe added a commit to giuseppe/libpod that referenced this pull request Feb 18, 2025
unify the error codes returned by runc and crun.

Fix the tests to work with both runtimes, as well as the
containers/crun#1672 changes in progress for
crun.

Follow-up for containers#25340

Signed-off-by: Giuseppe Scrivano <[email protected]>
@giuseppe giuseppe force-pushed the improve-error-message-path-not-executable branch from 5393867 to d92b070 Compare February 18, 2025 20:54
giuseppe added a commit to giuseppe/libpod that referenced this pull request Feb 18, 2025
unify the error codes returned by runc and crun.

Fix the tests to work with both runtimes, as well as the
containers/crun#1672 changes in progress for
crun.

Follow-up for containers#25340

Signed-off-by: Giuseppe Scrivano <[email protected]>
@giuseppe giuseppe force-pushed the improve-error-message-path-not-executable branch from d92b070 to 3721355 Compare February 19, 2025 15:03
@giuseppe giuseppe marked this pull request as ready for review February 19, 2025 15:03
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

LGTM

@giuseppe giuseppe merged commit 6da2b1b into containers:main Feb 19, 2025
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pod containers are instantly terminated without errors
3 participants