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)

Cherry-pick of: cri-o#6517

Signed-off-by: Sascha Grunert <[email protected]>
Cherry-picked: 260dfc0
  • Loading branch information
saschagrunert committed Jan 24, 2023
1 parent 66af2f6 commit 3a94499
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 3a94499

Please sign in to comment.