diff options
author | Matthew Heon <mheon@redhat.com> | 2020-05-14 09:39:41 -0400 |
---|---|---|
committer | Matthew Heon <mheon@redhat.com> | 2020-05-14 09:39:41 -0400 |
commit | 83a1e2e5d22761ad62de8e202938bbdb4896f236 (patch) | |
tree | 847b1016f1ce02f6bbd10e8c17c0fd039f5019d2 | |
parent | 3c58e4fc76d35c098b039b407291b35f66c7cae1 (diff) | |
download | podman-83a1e2e5d22761ad62de8e202938bbdb4896f236.tar.gz podman-83a1e2e5d22761ad62de8e202938bbdb4896f236.tar.bz2 podman-83a1e2e5d22761ad62de8e202938bbdb4896f236.zip |
Cleanup OCI runtime before storage
Some runtimes (e.g. Kata containers) seem to object to having us
unmount storage before the container is removed from the runtime.
This is an easy fix (change the order of operations in cleanup)
and seems to make more sense than the way we were doing things.
Signed-off-by: Matthew Heon <mheon@redhat.com>
-rw-r--r-- | libpod/container_internal.go | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go index 3fcf687ec..5baa5fc1c 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -1562,21 +1562,24 @@ func (c *Container) cleanup(ctx context.Context) error { lastError = errors.Wrapf(err, "error removing container %s network", c.ID()) } - // Unmount storage - if err := c.cleanupStorage(); err != nil { + // Remove the container from the runtime, if necessary. + // Do this *before* unmounting storage - some runtimes (e.g. Kata) + // apparently object to having storage removed while the container still + // exists. + if err := c.cleanupRuntime(ctx); err != nil { if lastError != nil { - logrus.Errorf("Error unmounting container %s storage: %v", c.ID(), err) + logrus.Errorf("Error removing container %s from OCI runtime: %v", c.ID(), err) } else { - lastError = errors.Wrapf(err, "error unmounting container %s storage", c.ID()) + lastError = err } } - // Remove the container from the runtime, if necessary - if err := c.cleanupRuntime(ctx); err != nil { + // Unmount storage + if err := c.cleanupStorage(); err != nil { if lastError != nil { - logrus.Errorf("Error removing container %s from OCI runtime: %v", c.ID(), err) + logrus.Errorf("Error unmounting container %s storage: %v", c.ID(), err) } else { - lastError = err + lastError = errors.Wrapf(err, "error unmounting container %s storage", c.ID()) } } |