Merge pull request #22347 from rhatdan/exec

podman exec CID without command should exit 125
This commit is contained in:
openshift-merge-bot[bot]
2024-04-12 12:51:35 +00:00
committed by GitHub
3 changed files with 8 additions and 5 deletions

View File

@ -29,6 +29,10 @@ func TranslateExecErrorToExitCode(originalEC int, err error) int {
if errors.Is(err, ErrOCIRuntimeNotFound) {
return ExecErrorCodeNotFound
}
if errors.Is(err, ErrInvalidArg) {
return ExecErrorCodeGeneric
}
return originalEC
}

View File

@ -32,11 +32,7 @@ var _ = Describe("Podman exec", func() {
// With no command
session = podmanTest.Podman([]string{"exec", "test1"})
session.WaitWithDefaultTimeout()
expectedStatus := 255
if IsRemote() {
expectedStatus = 125
}
Expect(session).Should(ExitWithError(expectedStatus, "must provide a non-empty command to start an exec session: invalid argument"))
Expect(session).Should(ExitWithError(125, "must provide a non-empty command to start an exec session: invalid argument"))
})
It("podman container exec simple command", func() {

View File

@ -33,6 +33,9 @@ load helpers
run_podman 127 exec $cid /no/such/command
is "$output" ".*such file or dir" "podman exec /no/such/command"
run_podman 125 exec $cid
is "$output" ".*must provide a non-empty command to start an exec session" "podman exec must include a command"
# Done. Tell the container to stop.
# The '-d' is because container exit is racy: the exec process itself
# could get caught and killed by cleanup, causing this step to exit 137