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

Ensure pod REST API endpoints include ctr errors #7428

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions pkg/api/handlers/libpod/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ func PodStop(w http.ResponseWriter, r *http.Request) {
}
}
var errs []error //nolint
for _, err := range responses {
errs = append(errs, err)
for id, err := range responses {
errs = append(errs, errors.Wrapf(err, "error stopping container %s", id))
}
report := entities.PodStopReport{
Errs: errs,
Expand Down Expand Up @@ -164,12 +164,12 @@ func PodStart(w http.ResponseWriter, r *http.Request) {
return
}
responses, err := pod.Start(r.Context())
if err != nil {
if err != nil && errors.Cause(err) != define.ErrPodPartialFail {
utils.Error(w, "Something went wrong", http.StatusInternalServerError, err)
return
}
for _, err := range responses {
errs = append(errs, err)
for id, err := range responses {
errs = append(errs, errors.Wrapf(err, "error starting container %s", id))
}
report := entities.PodStartReport{
Errs: errs,
Expand Down Expand Up @@ -220,12 +220,12 @@ func PodRestart(w http.ResponseWriter, r *http.Request) {
return
}
responses, err := pod.Restart(r.Context())
if err != nil {
if err != nil && errors.Cause(err) != define.ErrPodPartialFail {
utils.Error(w, "Something went wrong", http.StatusInternalServerError, err)
return
}
for _, err := range responses {
errs = append(errs, err)
for id, err := range responses {
errs = append(errs, errors.Wrapf(err, "error restarting container %s", id))
}
report := entities.PodRestartReport{
Errs: errs,
Expand Down Expand Up @@ -271,12 +271,12 @@ func PodPause(w http.ResponseWriter, r *http.Request) {
return
}
responses, err := pod.Pause()
if err != nil {
if err != nil && errors.Cause(err) != define.ErrPodPartialFail {
utils.Error(w, "Something went wrong", http.StatusInternalServerError, err)
return
}
for _, v := range responses {
errs = append(errs, v)
for id, v := range responses {
errs = append(errs, errors.Wrapf(v, "error pausing container %s", id))
}
report := entities.PodPauseReport{
Errs: errs,
Expand All @@ -295,12 +295,12 @@ func PodUnpause(w http.ResponseWriter, r *http.Request) {
return
}
responses, err := pod.Unpause()
if err != nil {
if err != nil && errors.Cause(err) != define.ErrPodPartialFail {
utils.Error(w, "failed to pause pod", http.StatusInternalServerError, err)
return
}
for _, v := range responses {
errs = append(errs, v)
for id, v := range responses {
errs = append(errs, errors.Wrapf(v, "error unpausing container %s", id))
}
report := entities.PodUnpauseReport{
Errs: errs,
Expand Down Expand Up @@ -403,7 +403,7 @@ func PodKill(w http.ResponseWriter, r *http.Request) {
}

responses, err := pod.Kill(uint(sig))
if err != nil {
if err != nil && errors.Cause(err) != define.ErrPodPartialFail {
utils.Error(w, "failed to kill pod", http.StatusInternalServerError, err)
return
}
Expand Down