Skip to content

Commit

Permalink
Merge pull request #5196 from Iceber/fix-rootfs
Browse files Browse the repository at this point in the history
rootfs: fix the error handling of the snapshotter.Commit
  • Loading branch information
estesp committed Mar 15, 2021
2 parents 6b410ba + 4e8b2f3 commit 5461fa3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rootfs/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func InitRootFS(ctx context.Context, name string, parent digest.Digest, readonly
return snapshotter.Prepare(ctx, name, parentS)
}

func createInitLayer(ctx context.Context, parent, initName string, initFn func(string) error, snapshotter snapshots.Snapshotter, mounter Mounter) (string, error) {
func createInitLayer(ctx context.Context, parent, initName string, initFn func(string) error, snapshotter snapshots.Snapshotter, mounter Mounter) (_ string, retErr error) {
initS := fmt.Sprintf("%s %s", parent, initName)
if _, err := snapshotter.Stat(ctx, initS); err == nil {
return initS, nil
Expand All @@ -87,7 +87,7 @@ func createInitLayer(ctx context.Context, parent, initName string, initFn func(s
}

defer func() {
if err != nil {
if retErr != nil {
if rerr := snapshotter.Remove(ctx, td); rerr != nil {
log.G(ctx).Errorf("Failed to remove snapshot %s: %v", td, rerr)
}
Expand Down

0 comments on commit 5461fa3

Please sign in to comment.