mirror of
https://github.com/containers/podman.git
synced 2025-10-18 03:33:32 +08:00
Merge pull request #24275 from Luap99/wait-condition
libpod API: only return exit code without conditions
This commit is contained in:
@ -137,9 +137,11 @@ func WaitContainerLibpod(w http.ResponseWriter, r *http.Request) {
|
|||||||
// However we keep the exit code around for longer than the container so
|
// However we keep the exit code around for longer than the container so
|
||||||
// we can just look it up here. Of course this only works when we get a
|
// we can just look it up here. Of course this only works when we get a
|
||||||
// full id as param but podman-remote will do that
|
// full id as param but podman-remote will do that
|
||||||
if code, err := runtime.GetContainerExitCode(name); err == nil {
|
if len(opts.Conditions) == 0 {
|
||||||
WriteResponse(w, http.StatusOK, strconv.Itoa(int(code)))
|
if code, err := runtime.GetContainerExitCode(name); err == nil {
|
||||||
return
|
WriteResponse(w, http.StatusOK, strconv.Itoa(int(code)))
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ContainerNotFound(w, name, err)
|
ContainerNotFound(w, name, err)
|
||||||
return
|
return
|
||||||
|
@ -15,6 +15,12 @@ t POST "containers/nonExistent/wait?condition=next-exit" 404
|
|||||||
# Make sure to test a non-zero exit code (see #18889)
|
# Make sure to test a non-zero exit code (see #18889)
|
||||||
podman create --name "${CTR}" "${IMAGE}" sh -c "exit 3"
|
podman create --name "${CTR}" "${IMAGE}" sh -c "exit 3"
|
||||||
|
|
||||||
|
t GET libpod/containers/${CTR}/json 200 \
|
||||||
|
.Id~[0-9a-f]\\{64\\}
|
||||||
|
|
||||||
|
# We need the cid for the wait test at the end
|
||||||
|
cid=$(jq -r '.Id' <<<"$output")
|
||||||
|
|
||||||
t POST "containers/${CTR}/wait?condition=non-existent-cond" 400
|
t POST "containers/${CTR}/wait?condition=non-existent-cond" 400
|
||||||
|
|
||||||
t POST "containers/${CTR}/wait?condition=not-running" 200
|
t POST "containers/${CTR}/wait?condition=not-running" 200
|
||||||
@ -49,3 +55,12 @@ t POST "containers/${CTR}/wait?condition=removed" 200 \
|
|||||||
# work correctly.
|
# work correctly.
|
||||||
t POST "containers/${CTR}/wait?condition=next-exit" 404
|
t POST "containers/${CTR}/wait?condition=next-exit" 404
|
||||||
wait "${child_pid}"
|
wait "${child_pid}"
|
||||||
|
|
||||||
|
t POST "libpod/containers/${CTR}/wait?condition=running" 404
|
||||||
|
t POST "libpod/containers/${cid}/wait?condition=running" 404
|
||||||
|
# The container no longer exists but we want to ensure the remote client
|
||||||
|
# can still fetch the exit code correctly until the exit code is pruned
|
||||||
|
# (after 5 mins) but only by the container id and not the name.
|
||||||
|
t POST "libpod/containers/${CTR}/wait" 404
|
||||||
|
t POST "libpod/containers/${cid}/wait" 200 \
|
||||||
|
"3"
|
||||||
|
Reference in New Issue
Block a user