From 38403ba4eba6cf7ae5958e8ef91321a8ebb1def5 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 | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/internal/storage/runtime.go b/internal/storage/runtime.go index 3d46765cab61..5152d3e86652 100644 --- a/internal/storage/runtime.go +++ b/internal/storage/runtime.go @@ -458,14 +458,26 @@ func (r *runtimeService) StopContainer(ctx context.Context, idOrName string) err } container, err := r.storageImageServer.GetStore().Container(idOrName) if err != nil { + if errors.Is(err, storage.ErrContainerUnknown) { + log.Infof(ctx, "Container %s not known, assuming it got already removed", idOrName) + return nil + } + + log.Warnf(ctx, "Failed to get container %s: %v", idOrName, err) 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.ErrLayerUnknown) { + log.Infof(ctx, "Layer for container %s not known", container.ID) + return nil + } + + log.Warnf(ctx, "Failed to unmount container %s: %v", container.ID, err) return err } - log.Debugf(ctx, "Unmounted container %q", container.ID) + + log.Debugf(ctx, "Unmounted container %s", container.ID) return nil }