summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorMatthew Heon <mheon@redhat.com>2020-08-17 11:04:26 -0400
committerMatthew Heon <mheon@redhat.com>2020-08-24 11:31:37 -0400
commitc5723785b71bd8ccff9f98a604676a3f3a604cc2 (patch)
tree3422dd7eff7f5a36dbc3abaab0fb7650581825e5 /pkg
parent484bd0af1dc90848be4bb4d729d5913b65fa7bc6 (diff)
downloadpodman-c5723785b71bd8ccff9f98a604676a3f3a604cc2.tar.gz
podman-c5723785b71bd8ccff9f98a604676a3f3a604cc2.tar.bz2
podman-c5723785b71bd8ccff9f98a604676a3f3a604cc2.zip
Clean up pods before returning from Pod Stop API call
This should help alleviate races where the pod is not fully cleaned up before subsequent API calls happen. Signed-off-by: Matthew Heon <mheon@redhat.com>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/api/handlers/libpod/pods.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/pkg/api/handlers/libpod/pods.go b/pkg/api/handlers/libpod/pods.go
index dee5a7d33..7e3f00472 100644
--- a/pkg/api/handlers/libpod/pods.go
+++ b/pkg/api/handlers/libpod/pods.go
@@ -123,10 +123,17 @@ func PodStop(w http.ResponseWriter, r *http.Request) {
} else {
responses, stopError = pod.Stop(r.Context(), false)
}
- if stopError != nil {
+ if stopError != nil && errors.Cause(stopError) != define.ErrPodPartialFail {
utils.Error(w, "Something went wrong", http.StatusInternalServerError, err)
return
}
+ // Try to clean up the pod - but only warn on failure, it's nonfatal.
+ if cleanupCtrs, cleanupErr := pod.Cleanup(r.Context()); cleanupErr != nil {
+ logrus.Errorf("Error cleaning up pod %s: %v", pod.ID(), cleanupErr)
+ for id, err := range cleanupCtrs {
+ logrus.Errorf("Error cleaning up pod %s container %s: %v", pod.ID(), id, err)
+ }
+ }
var errs []error //nolint
for _, err := range responses {
errs = append(errs, err)