Skip to content

Commit

Permalink
Make storage unmount less strict
Browse files Browse the repository at this point in the history
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:
containers/podman#11207 (comment)

Signed-off-by: Sascha Grunert <[email protected]>
  • Loading branch information
saschagrunert committed Jan 11, 2023
1 parent 7fbf54b commit 81f513c
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions internal/storage/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
return 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 fmt.Errorf("unmount storage: %w", err)
}

log.Debugf(ctx, "Unmounted container %q", container.ID)
return nil
}
Expand Down

0 comments on commit 81f513c

Please sign in to comment.