From 50f385bcc860b8c04648386e7331695c5432caa4 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..cdebfb98f1b9 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 errors.Is(err, storage.ErrContainerUnknown) { + logrus.Infof("Container %s not known, assuming it got already removed", container.ID) + return nil + } + + if _, err := r.storageImageServer.GetStore().Unmount(container.ID, true); err != 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 }