From 4553f2914c94f7095b3ae9b3724bd67a1347b87f Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Sat, 31 Mar 2018 21:27:28 -0400 Subject: More gracefully handle unexpected storage deletion We have other tools using containers/storage. They can delete our containers in c/storage without us knowing. Try and handle this better by warning instead of erroring when delete our storage and it is already gone. This does not handle cases where libpod thinks the container is mounted, but it is not. This is harder to check for, because c/storage Mount() and Unmount() take a layer, image, or container and that complicates our "container no longer exists" question. Further work is needed here. Signed-off-by: Matthew Heon Closes: #571 Approved by: rhatdan --- libpod/container_internal.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libpod/container_internal.go b/libpod/container_internal.go index 4bfdfae9d..efeb1fa77 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -223,6 +223,15 @@ func (c *Container) teardownStorage() error { } if err := c.runtime.storageService.DeleteContainer(c.ID()); err != nil { + // If the container has already been removed, warn but do not + // error - we wanted it gone, it is already gone. + // Potentially another tool using containers/storage already + // removed it? + if err == storage.ErrNotAContainer { + logrus.Errorf("Storage for container %s already removed", c.ID()) + return nil + } + return errors.Wrapf(err, "error removing container %s root filesystem", c.ID()) } -- cgit v1.2.3-54-g00ecf