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 19, 2023
1 parent d12c284 commit 260dfc0
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions internal/storage/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 260dfc0

Please sign in to comment.