diff --git a/snapshots/overlay/overlay.go b/snapshots/overlay/overlay.go index 494790c27..a37f412d1 100644 --- a/snapshots/overlay/overlay.go +++ b/snapshots/overlay/overlay.go @@ -287,9 +287,9 @@ func (o *snapshotter) createSnapshot(ctx context.Context, kind snapshots.Kind, k if err != nil { return nil, err } - isRollback := true + rollback := true defer func() { - if isRollback { + if rollback { if rerr := t.Rollback(); rerr != nil { log.G(ctx).WithError(rerr).Warn("failed to rollback transaction") } @@ -317,9 +317,9 @@ func (o *snapshotter) createSnapshot(ctx context.Context, kind snapshots.Kind, k if err = os.Rename(td, path); err != nil { return nil, errors.Wrap(err, "failed to rename") } - isRollback = false td = "" + rollback = false if err = t.Commit(); err != nil { return nil, errors.Wrap(err, "commit failed") } diff --git a/snapshots/storage/bolt.go b/snapshots/storage/bolt.go index b120548dc..18e219a16 100644 --- a/snapshots/storage/bolt.go +++ b/snapshots/storage/bolt.go @@ -341,16 +341,16 @@ func CommitActive(ctx context.Context, key, name string, usage snapshots.Usage, } sbkt := bkt.Bucket([]byte(key)) if sbkt == nil { - return errors.Wrap(errdefs.ErrNotFound, "failed to get active snapshot") + return errors.Wrapf(errdefs.ErrNotFound, "failed to get active snapshot %q", key) } var si snapshots.Info if err := readSnapshot(sbkt, &id, &si); err != nil { - return errors.Wrap(err, "failed to read snapshot") + return errors.Wrapf(err, "failed to read active snapshot %q", key) } if si.Kind != snapshots.KindActive { - return errors.Wrapf(errdefs.ErrFailedPrecondition, "snapshot %v is not active", name) + return errors.Wrapf(errdefs.ErrFailedPrecondition, "snapshot %q is not active", key) } si.Kind = snapshots.KindCommitted si.Created = time.Now().UTC() @@ -366,18 +366,18 @@ func CommitActive(ctx context.Context, key, name string, usage snapshots.Usage, return err } if err := bkt.DeleteBucket([]byte(key)); err != nil { - return errors.Wrap(err, "failed to delete active") + return errors.Wrapf(err, "failed to delete active snapshot %q", key) } if si.Parent != "" { spbkt := bkt.Bucket([]byte(si.Parent)) if spbkt == nil { - return errors.Wrap(errdefs.ErrNotFound, "missing parent") + return errors.Wrapf(errdefs.ErrNotFound, "missing parent snapshot of %q", key) } pid := readID(spbkt) // Updates parent back link to use new key if err := pbkt.Put(parentKey(pid, id), []byte(name)); err != nil { - return errors.Wrap(err, "failed to update parent link") + return errors.Wrapf(err, "failed to update parent link from %q to %q", key, name) } } @@ -394,11 +394,11 @@ func withSnapshotBucket(ctx context.Context, key string, fn func(context.Context if !ok { return ErrNoTransaction } - bkt := tx.Bucket(bucketKeyStorageVersion) - if bkt == nil { + vbkt := tx.Bucket(bucketKeyStorageVersion) + if vbkt == nil { return errors.Wrap(errdefs.ErrNotFound, "bucket does not exist") } - bkt = bkt.Bucket(bucketKeySnapshot) + bkt := vbkt.Bucket(bucketKeySnapshot) if bkt == nil { return errors.Wrap(errdefs.ErrNotFound, "snapshots bucket does not exist") } @@ -407,7 +407,7 @@ func withSnapshotBucket(ctx context.Context, key string, fn func(context.Context return errors.Wrap(errdefs.ErrNotFound, "snapshot does not exist") } - return fn(ctx, bkt, bkt.Bucket(bucketKeyParents)) + return fn(ctx, bkt, vbkt.Bucket(bucketKeyParents)) } func withBucket(ctx context.Context, fn func(context.Context, *bolt.Bucket, *bolt.Bucket) error) error {