not mounted layers should be reported as info not error

There is a potential race condition we are seeing where
we are seeing a message about a removed container which
could be caused by a non mounted container, this change
should clarify which is causing it.

Also if the container does not exists, just warn the user
instead of reporting an error, not much the user can do.

Fixes: https://github.com/containers/podman/issues/19702

[NO NEW TESTS NEEDED]

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh
2023-10-23 15:20:47 -04:00
parent 19c870da0d
commit 8876380af9

View File

@ -1942,9 +1942,12 @@ func (c *Container) cleanupStorage() error {
// error
// We still want to be able to kick the container out of the
// state
if errors.Is(err, storage.ErrNotAContainer) || errors.Is(err, storage.ErrContainerUnknown) || errors.Is(err, storage.ErrLayerNotMounted) {
logrus.Errorf("Storage for container %s has been removed", c.ID())
} else {
switch {
case errors.Is(err, storage.ErrLayerNotMounted):
logrus.Infof("Storage for container %s is not mounted: %v", c.ID(), err)
case errors.Is(err, storage.ErrNotAContainer) || errors.Is(err, storage.ErrContainerUnknown):
logrus.Warnf("Storage for container %s has been removed: %v", c.ID(), err)
default:
reportErrorf("cleaning up container %s storage: %w", c.ID(), err)
}
}