Skip to content

Commit

Permalink
Always use layerStore.Delete when recovering from failures
Browse files Browse the repository at this point in the history
... so that we also remove the layer from layerStore.layers
and the like.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
  • Loading branch information
mtrmac committed Feb 22, 2022
1 parent 27aeff4 commit 3c90a9a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions layers.go
Expand Up @@ -798,9 +798,10 @@ func (r *layerStore) Put(id string, parentLayer *Layer, names []string, mountLab
layer.Flags[incompleteFlag] = true
err = r.Save()
if err != nil {
// We don't have a record of this layer, but at least
// try to clean it up underneath us.
if err2 := r.driver.Remove(id); err2 != nil {
// We don't have a presistent record of this layer, but
// try to remove both the driver’s data as well as
// the in-memory layer record.
if err2 := r.Delete(layer.ID); err2 != nil {
logrus.Errorf("While recovering from a failure saving incomplete layer metadata, error deleting layer %#v: %v", id, err2)
}
return nil, -1, err
Expand Down

0 comments on commit 3c90a9a

Please sign in to comment.