From 3d3743c17786914e09daa3cdaba74ae1d4d47866 Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Wed, 11 Jan 2023 11:43:35 +0100 Subject: [PATCH] Make storage unmount less strict There are cases where the container storage unmount has been already (partially) done. This would cause `StopContainer()` in `server/container_stop.go:76` fail and therefore make containers get stuck in recreation, making their pods stuck in `NotReady`. We now double check the two c/stroage errors `ErrContainerUnknown` and `ErrLayerUnknown` Somehow related to: https://github.com/containers/podman/issues/11207#issuecomment-920768804 Signed-off-by: Sascha Grunert --- internal/storage/runtime.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/internal/storage/runtime.go b/internal/storage/runtime.go index 5225d5cc4ff3..5dc26e7806a9 100644 --- a/internal/storage/runtime.go +++ b/internal/storage/runtime.go @@ -455,11 +455,22 @@ func (r *runtimeService) StopContainer(idOrName string) error { if err != nil { return err } - _, err = r.storageImageServer.GetStore().Unmount(container.ID, false) - if err != nil { - logrus.Debugf("Failed to unmount container %q: %v", container.ID, err) + + if _, err := r.storageImageServer.GetStore().Unmount(container.ID, true); err != nil { + if errors.Is(err, storage.ErrContainerUnknown) { + logrus.Infof("Storage for container %s already removed", container.ID) + return nil + } + + if errors.Is(err, storage.ErrLayerUnknown) { + logrus.Infof("Layer for container %s not known", container.ID) + return nil + } + + logrus.Warnf("Failed to unmount container %q: %v", container.ID, err) return err } + logrus.Debugf("Unmounted container %q", container.ID) return nil }