Merge pull request #19413 from vrothberg/fix-19368

API: kill: return 409 on invalid state
This commit is contained in:
OpenShift Merge Robot 2023-07-31 21:37:21 +02:00 committed by GitHub
commit 3ddde2023a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -243,6 +243,11 @@ func KillContainer(w http.ResponseWriter, r *http.Request) {
}
if len(report) > 0 && report[0].Err != nil {
if errors.Is(report[0].Err, define.ErrCtrStateInvalid) ||
errors.Is(report[0].Err, define.ErrCtrStopped) {
utils.Error(w, http.StatusConflict, report[0].Err)
return
}
utils.InternalServerError(w, report[0].Err)
return
}

View File

@ -32,7 +32,10 @@ t POST "containers/foo/attach?logs=true&stream=false" 200 \
$'\001\031'$mytext
t POST "containers/foo/kill" 204
podman run -v /tmp:/tmp $IMAGE true
podman run --replace --name=foo -v /tmp:/tmp $IMAGE true
# cannot kill non-running container
t POST "containers/foo/kill" 409
t POST "libpod/containers/foo/kill" 409
t GET libpod/containers/json 200 length=0