Skip to content

Commit

Permalink
layerStore.Put(): always check for Create() errors
Browse files Browse the repository at this point in the history
If we needed to try to update the ID mappings on a just-created layer,
we were inadvertently failing to check that the layer had been
successfully created.

Signed-off-by: Nalin Dahyabhai <[email protected]>
  • Loading branch information
nalind committed Sep 21, 2018
1 parent 02db7cb commit 2805a43
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 13 additions & 4 deletions layers.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,13 +558,22 @@ func (r *layerStore) Put(id string, parentLayer *Layer, names []string, mountLab
StorageOpt: options,
}
if writeable {
err = r.driver.CreateReadWrite(id, parent, &opts)
if err = r.driver.CreateReadWrite(id, parent, &opts); err != nil {
if id != "" {
return nil, -1, errors.Wrapf(err, "error creating read-write layer with ID %q", id)
}
return nil, -1, errors.Wrapf(err, "error creating read-write layer")
}
} else {
err = r.driver.Create(id, parent, &opts)
if err = r.driver.Create(id, parent, &opts); err != nil {
if id != "" {
return nil, -1, errors.Wrapf(err, "error creating layer with ID %q", id)
}
return nil, -1, errors.Wrapf(err, "error creating layer")
}
}
if !reflect.DeepEqual(parentMappings.UIDs(), idMappings.UIDs()) || !reflect.DeepEqual(parentMappings.GIDs(), idMappings.GIDs()) {
err = r.driver.UpdateLayerIDMap(id, parentMappings, idMappings, mountLabel)
if err != nil {
if err = r.driver.UpdateLayerIDMap(id, parentMappings, idMappings, mountLabel); err != nil {
// We don't have a record of this layer, but at least
// try to clean it up underneath us.
r.driver.Remove(id)
Expand Down
2 changes: 1 addition & 1 deletion layers_ffjson.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2805a43

Please sign in to comment.