From 69a6cb255ca98bc7a9e6d47c7a0ccaacab895a25 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Mon, 14 May 2018 10:17:24 -0400 Subject: Gracefully handle containers removed from c/storage Allow containers that no longer exist in storage to be evicted from the state instead of erroring. Signed-off-by: Matthew Heon Closes: #764 Approved by: rhatdan --- libpod/container_internal.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libpod/container_internal.go b/libpod/container_internal.go index 1c0bcb07f..b0f39fec8 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -277,7 +277,7 @@ func (c *Container) teardownStorage() error { // error - we wanted it gone, it is already gone. // Potentially another tool using containers/storage already // removed it? - if err == storage.ErrNotAContainer { + if err == storage.ErrNotAContainer || err == storage.ErrContainerUnknown { logrus.Warnf("Storage for container %s already removed", c.ID()) return nil } @@ -791,6 +791,15 @@ func (c *Container) cleanupStorage() error { // Also unmount storage if err := c.runtime.storageService.UnmountContainerImage(c.ID()); err != nil { + // If the container has already been removed, warn but don't + // error + // We still want to be able to kick the container out of the + // state + if err == storage.ErrNotAContainer || err == storage.ErrContainerUnknown { + logrus.Errorf("Storage for container %s has been removed", c.ID()) + return nil + } + return errors.Wrapf(err, "error unmounting container %s root filesystem", c.ID()) } -- cgit v1.2.3-54-g00ecf