Merge pull request #23258 from Luap99/start-error

fix race conditions in start/attach logic
This commit is contained in:
openshift-merge-bot[bot]
2024-07-15 12:11:56 +00:00
committed by GitHub
7 changed files with 78 additions and 124 deletions

View File

@ -1,6 +1,7 @@
package compat
import (
"errors"
"net/http"
api "github.com/containers/podman/v5/pkg/api/types"
@ -33,16 +34,11 @@ func StartContainer(w http.ResponseWriter, r *http.Request) {
utils.ContainerNotFound(w, name, err)
return
}
state, err := con.State()
if err != nil {
utils.InternalServerError(w, err)
return
}
if state == define.ContainerStateRunning {
utils.WriteResponse(w, http.StatusNotModified, nil)
return
}
if err := con.Start(r.Context(), true); err != nil {
if errors.Is(err, define.ErrCtrStateRunning) {
utils.WriteResponse(w, http.StatusNotModified, nil)
return
}
utils.InternalServerError(w, err)
return
}