summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authoropenshift-ci[bot] <75433959+openshift-ci[bot]@users.noreply.github.com>2022-06-29 19:51:53 +0000
committerGitHub <noreply@github.com>2022-06-29 19:51:53 +0000
commit2cc3f127f4f419c107c0b92c6f6457f5faad2e1d (patch)
treee4c3272cd93eb10ea39c9bc4f0f0f72fce2e389f /libpod
parentd6cdb996bce10eb050e41b2050aaf52d9bfd3bd0 (diff)
parent3619f0be9514cd7a2cbdddc6cfb8bc8b7a94485d (diff)
downloadpodman-2cc3f127f4f419c107c0b92c6f6457f5faad2e1d.tar.gz
podman-2cc3f127f4f419c107c0b92c6f6457f5faad2e1d.tar.bz2
podman-2cc3f127f4f419c107c0b92c6f6457f5faad2e1d.zip
Merge pull request #14720 from sstosh/rm-option
Fix: Prevent OCI runtime directory remain
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_api.go9
-rw-r--r--libpod/container_internal.go3
-rw-r--r--libpod/runtime_ctr.go4
3 files changed, 15 insertions, 1 deletions
diff --git a/libpod/container_api.go b/libpod/container_api.go
index c14fe95b0..f35cce772 100644
--- a/libpod/container_api.go
+++ b/libpod/container_api.go
@@ -666,6 +666,15 @@ func (c *Container) Cleanup(ctx context.Context) error {
defer c.lock.Unlock()
if err := c.syncContainer(); err != nil {
+ switch errors.Cause(err) {
+ // When the container has already been removed, the OCI runtime directory remain.
+ case define.ErrNoSuchCtr, define.ErrCtrRemoved:
+ if err := c.cleanupRuntime(ctx); err != nil {
+ return errors.Wrapf(err, "error cleaning up container %s from OCI runtime", c.ID())
+ }
+ default:
+ logrus.Errorf("Syncing container %s status: %v", c.ID(), err)
+ }
return err
}
}
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index 64696cc27..3b01ee6c8 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -1289,8 +1289,9 @@ func (c *Container) stop(timeout uint) error {
if err := c.syncContainer(); err != nil {
switch errors.Cause(err) {
// If the container has already been removed (e.g., via
- // the cleanup process), there's nothing left to do.
+ // the cleanup process), set the container state to "stopped".
case define.ErrNoSuchCtr, define.ErrCtrRemoved:
+ c.state.State = define.ContainerStateStopped
return stopErr
default:
if stopErr != nil {
diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go
index fafec5e12..4d34c6a08 100644
--- a/libpod/runtime_ctr.go
+++ b/libpod/runtime_ctr.go
@@ -715,6 +715,10 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, force, remo
// Do a quick ping of the database to check if the container
// still exists.
if ok, _ := r.state.HasContainer(c.ID()); !ok {
+ // When the container has already been removed, the OCI runtime directory remain.
+ if err := c.cleanupRuntime(ctx); err != nil {
+ return errors.Wrapf(err, "error cleaning up container %s from OCI runtime", c.ID())
+ }
return nil
}
}