From cf7280c26515795b462db789abdc95090304f1a7 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 3d46765cab61..2a06866e93ec 100644 --- a/internal/storage/runtime.go +++ b/internal/storage/runtime.go @@ -460,11 +460,22 @@ func (r *runtimeService) StopContainer(ctx context.Context, idOrName string) err if err != nil { return err } - _, err = r.storageImageServer.GetStore().Unmount(container.ID, false) - if err != nil { - log.Debugf(ctx, "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) { + log.Infof(ctx, "Storage for container %s already removed", container.ID) + return nil + } + + if errors.Is(err, storage.ErrLayerUnknown) { + log.Infof(ctx, "Layer for container %s not known", container.ID) + return nil + } + + log.Warnf(ctx, "Failed to unmount container %q: %v", container.ID, err) return err } + log.Debugf(ctx, "Unmounted container %q", container.ID) return nil }