From 89766a90274b67f7ef417a439b6dc55db480abde 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 Cherry-pick of: https://github.com/cri-o/cri-o/pull/6517 Signed-off-by: Sascha Grunert Cherry-picked: 260dfc0b1b1339a310b044b3b049c46b8a6fadd0 --- internal/storage/runtime.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/internal/storage/runtime.go b/internal/storage/runtime.go index 5225d5cc4ff..c5e86ccea11 100644 --- a/internal/storage/runtime.go +++ b/internal/storage/runtime.go @@ -453,14 +453,26 @@ func (r *runtimeService) StopContainer(idOrName string) error { } container, err := r.storageImageServer.GetStore().Container(idOrName) if err != nil { + if errors.Is(err, storage.ErrContainerUnknown) { + logrus.Infof("Container %s not known, assuming it got already removed", idOrName) + return nil + } + + logrus.Warnf("Failed to get container %s: %v", idOrName, err) 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.ErrLayerUnknown) { + logrus.Infof("Layer for container %s not known", container.ID) + return nil + } + + logrus.Warnf("Failed to unmount container %s: %v", container.ID, err) return err } - logrus.Debugf("Unmounted container %q", container.ID) + + logrus.Debugf("Unmounted container %s", container.ID) return nil }