Skip to content

Commit

Permalink
podman rmi: handle corrupted storage better
Browse files Browse the repository at this point in the history
The storage can easily be corrupted when a build or pull process (or any
process *writing* to the storage) has been killed.  The corruption
surfaces in Podman reporting that a given layer could not be found in
the layer tree.  Those errors must not be fatal but only logged, such
that the image removal may continue.  Otherwise, a user may be unable to
remove an image.

[NO TESTS NEEDED] as I do not yet have a reliable way to cause such a
storage corruption.

Reported-in: containers#8148 (comment)
Signed-off-by: Valentin Rothberg <[email protected]>
  • Loading branch information
vrothberg committed Mar 1, 2021
1 parent b154c51 commit 3752016
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions libpod/image/layer_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"

ociv1 "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -188,7 +187,12 @@ func (t *layerTree) parent(ctx context.Context, child *Image) (*Image, error) {

node, exists := t.nodes[child.TopLayer()]
if !exists {
return nil, errors.Errorf("layer not found in layer tree: %q", child.TopLayer())
// Note: erroring out in this case has turned out having been a
// mistake. Users may not be able to recover, so we're now
// throwing a warning to guide them to resolve the issue and
// turn the errors non-fatal.
logrus.Warnf("Layer %s not found in layer. The storage may be corrupted, consider running `podman system reset`.", child.TopLayer())
return nil, nil
}

childOCI, err := t.toOCI(ctx, child)
Expand Down

0 comments on commit 3752016

Please sign in to comment.