summaryrefslogtreecommitdiff
path: root/libpod/runtime_ctr.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-05-14 12:51:39 -0700
committerGitHub <noreply@github.com>2020-05-14 12:51:39 -0700
commit0d9625152b9acf1dc7662e38f56aa5b106c4dfcd (patch)
treed94b1fc1a778144348e85abf1fd4b61da4f54823 /libpod/runtime_ctr.go
parent32268eaa6239057b82445172bf8128dabec0fe14 (diff)
parent892d81685c9fc213b0e9d444f953577ebb89593b (diff)
downloadpodman-0d9625152b9acf1dc7662e38f56aa5b106c4dfcd.tar.gz
podman-0d9625152b9acf1dc7662e38f56aa5b106c4dfcd.tar.bz2
podman-0d9625152b9acf1dc7662e38f56aa5b106c4dfcd.zip
Merge pull request #6229 from mheon/small_kata_fix
Cleanup OCI runtime before storage
Diffstat (limited to 'libpod/runtime_ctr.go')
-rw-r--r--libpod/runtime_ctr.go19
1 files changed, 12 insertions, 7 deletions
diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go
index 1d880531e..c670822a0 100644
--- a/libpod/runtime_ctr.go
+++ b/libpod/runtime_ctr.go
@@ -488,20 +488,25 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, force bool,
}
}
+ var cleanupErr error
+
+ // Clean up network namespace, cgroups, mounts.
+ // Do this before we set ContainerStateRemoving, to ensure that we can
+ // actually remove from the OCI runtime.
+ if err := c.cleanup(ctx); err != nil {
+ cleanupErr = errors.Wrapf(err, "error cleaning up container %s", c.ID())
+ }
+
// Set ContainerStateRemoving
c.state.State = define.ContainerStateRemoving
if err := c.save(); err != nil {
+ if cleanupErr != nil {
+ logrus.Errorf(err.Error())
+ }
return errors.Wrapf(err, "unable to set container %s removing state in database", c.ID())
}
- var cleanupErr error
-
- // Clean up network namespace, cgroups, mounts
- if err := c.cleanup(ctx); err != nil {
- cleanupErr = errors.Wrapf(err, "error cleaning up container %s", c.ID())
- }
-
// Stop the container's storage
if err := c.teardownStorage(); err != nil {
if cleanupErr == nil {