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 <sgrunert@redhat.com>
  • Loading branch information
saschagrunert committed Jan 11, 2023
1 parent d12c284 commit 3d3743c
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions internal/storage/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 _, err := r.storageImageServer.GetStore().Unmount(container.ID, true); err != nil {
if errors.Is(err, storage.ErrContainerUnknown) {
logrus.Infof("Storage for container %s already removed", container.ID)
return 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
}
Expand Down

0 comments on commit 3d3743c

Please sign in to comment.