Update snapshot and content related log messages
Make the tense and casing consistent. Add useful log messages in image service. Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
		| @@ -138,7 +138,7 @@ func (m *DB) Init(ctx context.Context) error { | |||||||
| 				if err := m.migrate(tx); err != nil { | 				if err := m.migrate(tx); err != nil { | ||||||
| 					return errors.Wrapf(err, "failed to migrate to %s.%d", m.schema, m.version) | 					return errors.Wrapf(err, "failed to migrate to %s.%d", m.schema, m.version) | ||||||
| 				} | 				} | ||||||
| 				log.G(ctx).WithField("d", time.Now().Sub(t0)).Debugf("database migration to %s.%d finished", m.schema, m.version) | 				log.G(ctx).WithField("d", time.Now().Sub(t0)).Debugf("finished database migration to %s.%d", m.schema, m.version) | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| @@ -269,7 +269,7 @@ func (m *DB) GarbageCollect(ctx context.Context) (stats GCStats, err error) { | |||||||
| 		stats.SnapshotD = map[string]time.Duration{} | 		stats.SnapshotD = map[string]time.Duration{} | ||||||
| 		wg.Add(len(m.dirtySS)) | 		wg.Add(len(m.dirtySS)) | ||||||
| 		for snapshotterName := range m.dirtySS { | 		for snapshotterName := range m.dirtySS { | ||||||
| 			log.G(ctx).WithField("snapshotter", snapshotterName).Debug("scheduling snapshotter cleanup") | 			log.G(ctx).WithField("snapshotter", snapshotterName).Debug("schedule snapshotter cleanup") | ||||||
| 			go func(snapshotterName string) { | 			go func(snapshotterName string) { | ||||||
| 				st1 := time.Now() | 				st1 := time.Now() | ||||||
| 				m.cleanupSnapshotter(snapshotterName) | 				m.cleanupSnapshotter(snapshotterName) | ||||||
| @@ -286,7 +286,7 @@ func (m *DB) GarbageCollect(ctx context.Context) (stats GCStats, err error) { | |||||||
|  |  | ||||||
| 	if m.dirtyCS { | 	if m.dirtyCS { | ||||||
| 		wg.Add(1) | 		wg.Add(1) | ||||||
| 		log.G(ctx).Debug("scheduling content cleanup") | 		log.G(ctx).Debug("schedule content cleanup") | ||||||
| 		go func() { | 		go func() { | ||||||
| 			ct1 := time.Now() | 			ct1 := time.Now() | ||||||
| 			m.cleanupContent() | 			m.cleanupContent() | ||||||
|   | |||||||
| @@ -301,7 +301,7 @@ func remove(ctx context.Context, tx *bolt.Tx, node gc.Node) error { | |||||||
| 			cbkt = cbkt.Bucket(bucketKeyObjectBlob) | 			cbkt = cbkt.Bucket(bucketKeyObjectBlob) | ||||||
| 		} | 		} | ||||||
| 		if cbkt != nil { | 		if cbkt != nil { | ||||||
| 			log.G(ctx).WithField("key", node.Key).Debug("delete content") | 			log.G(ctx).WithField("key", node.Key).Debug("remove content") | ||||||
| 			return cbkt.DeleteBucket([]byte(node.Key)) | 			return cbkt.DeleteBucket([]byte(node.Key)) | ||||||
| 		} | 		} | ||||||
| 	case ResourceSnapshot: | 	case ResourceSnapshot: | ||||||
| @@ -313,7 +313,7 @@ func remove(ctx context.Context, tx *bolt.Tx, node gc.Node) error { | |||||||
| 			} | 			} | ||||||
| 			ssbkt := sbkt.Bucket([]byte(parts[0])) | 			ssbkt := sbkt.Bucket([]byte(parts[0])) | ||||||
| 			if ssbkt != nil { | 			if ssbkt != nil { | ||||||
| 				log.G(ctx).WithField("key", parts[1]).WithField("snapshotter", parts[0]).Debug("delete snapshot") | 				log.G(ctx).WithField("key", parts[1]).WithField("snapshotter", parts[0]).Debug("remove snapshot") | ||||||
| 				return ssbkt.DeleteBucket([]byte(parts[1])) | 				return ssbkt.DeleteBucket([]byte(parts[1])) | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|   | |||||||
| @@ -723,7 +723,7 @@ func (s *snapshotter) pruneBranch(ctx context.Context, node *treeNode) error { | |||||||
| 			if !errdefs.IsFailedPrecondition(err) { | 			if !errdefs.IsFailedPrecondition(err) { | ||||||
| 				return err | 				return err | ||||||
| 			} | 			} | ||||||
| 			logger.WithError(err).WithField("key", node.info.Name).Warnf("snapshot removal failed") | 			logger.WithError(err).WithField("key", node.info.Name).Warnf("failed to remove snapshot") | ||||||
| 		} else { | 		} else { | ||||||
| 			logger.WithField("key", node.info.Name).Debug("removed snapshot") | 			logger.WithField("key", node.info.Name).Debug("removed snapshot") | ||||||
| 		} | 		} | ||||||
|   | |||||||
| @@ -141,6 +141,7 @@ func (s *service) List(req *api.ListContentRequest, session api.Content_ListServ | |||||||
| } | } | ||||||
|  |  | ||||||
| func (s *service) Delete(ctx context.Context, req *api.DeleteContentRequest) (*ptypes.Empty, error) { | func (s *service) Delete(ctx context.Context, req *api.DeleteContentRequest) (*ptypes.Empty, error) { | ||||||
|  | 	log.G(ctx).WithField("digest", req.Digest).Debugf("delete content") | ||||||
| 	if err := req.Digest.Validate(); err != nil { | 	if err := req.Digest.Validate(); err != nil { | ||||||
| 		return nil, status.Errorf(codes.InvalidArgument, err.Error()) | 		return nil, status.Errorf(codes.InvalidArgument, err.Error()) | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -9,6 +9,7 @@ import ( | |||||||
| 	"github.com/containerd/containerd/errdefs" | 	"github.com/containerd/containerd/errdefs" | ||||||
| 	"github.com/containerd/containerd/events" | 	"github.com/containerd/containerd/events" | ||||||
| 	"github.com/containerd/containerd/images" | 	"github.com/containerd/containerd/images" | ||||||
|  | 	"github.com/containerd/containerd/log" | ||||||
| 	"github.com/containerd/containerd/metadata" | 	"github.com/containerd/containerd/metadata" | ||||||
| 	"github.com/containerd/containerd/plugin" | 	"github.com/containerd/containerd/plugin" | ||||||
| 	ptypes "github.com/gogo/protobuf/types" | 	ptypes "github.com/gogo/protobuf/types" | ||||||
| @@ -94,6 +95,7 @@ func (s *service) List(ctx context.Context, req *imagesapi.ListImagesRequest) (* | |||||||
| } | } | ||||||
|  |  | ||||||
| func (s *service) Create(ctx context.Context, req *imagesapi.CreateImageRequest) (*imagesapi.CreateImageResponse, error) { | func (s *service) Create(ctx context.Context, req *imagesapi.CreateImageRequest) (*imagesapi.CreateImageResponse, error) { | ||||||
|  | 	log.G(ctx).WithField("name", req.Image.Name).WithField("target", req.Image.Target.Digest).Debugf("create image") | ||||||
| 	if req.Image.Name == "" { | 	if req.Image.Name == "" { | ||||||
| 		return nil, status.Errorf(codes.InvalidArgument, "Image.Name required") | 		return nil, status.Errorf(codes.InvalidArgument, "Image.Name required") | ||||||
| 	} | 	} | ||||||
| @@ -164,6 +166,7 @@ func (s *service) Update(ctx context.Context, req *imagesapi.UpdateImageRequest) | |||||||
| } | } | ||||||
|  |  | ||||||
| func (s *service) Delete(ctx context.Context, req *imagesapi.DeleteImageRequest) (*ptypes.Empty, error) { | func (s *service) Delete(ctx context.Context, req *imagesapi.DeleteImageRequest) (*ptypes.Empty, error) { | ||||||
|  | 	log.G(ctx).WithField("name", req.Name).Debugf("delete image") | ||||||
| 	if err := s.withStoreUpdate(ctx, func(ctx context.Context, store images.Store) error { | 	if err := s.withStoreUpdate(ctx, func(ctx context.Context, store images.Store) error { | ||||||
| 		return errdefs.ToGRPC(store.Delete(ctx, req.Name)) | 		return errdefs.ToGRPC(store.Delete(ctx, req.Name)) | ||||||
| 	}); err != nil { | 	}); err != nil { | ||||||
|   | |||||||
| @@ -66,7 +66,7 @@ func (s *service) Register(gs *grpc.Server) error { | |||||||
| } | } | ||||||
|  |  | ||||||
| func (s *service) Prepare(ctx context.Context, pr *snapshotsapi.PrepareSnapshotRequest) (*snapshotsapi.PrepareSnapshotResponse, error) { | func (s *service) Prepare(ctx context.Context, pr *snapshotsapi.PrepareSnapshotRequest) (*snapshotsapi.PrepareSnapshotResponse, error) { | ||||||
| 	log.G(ctx).WithField("parent", pr.Parent).WithField("key", pr.Key).Debugf("Preparing snapshot") | 	log.G(ctx).WithField("parent", pr.Parent).WithField("key", pr.Key).Debugf("prepare snapshot") | ||||||
| 	sn, err := s.getSnapshotter(pr.Snapshotter) | 	sn, err := s.getSnapshotter(pr.Snapshotter) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| @@ -93,7 +93,7 @@ func (s *service) Prepare(ctx context.Context, pr *snapshotsapi.PrepareSnapshotR | |||||||
| } | } | ||||||
|  |  | ||||||
| func (s *service) View(ctx context.Context, pr *snapshotsapi.ViewSnapshotRequest) (*snapshotsapi.ViewSnapshotResponse, error) { | func (s *service) View(ctx context.Context, pr *snapshotsapi.ViewSnapshotRequest) (*snapshotsapi.ViewSnapshotResponse, error) { | ||||||
| 	log.G(ctx).WithField("parent", pr.Parent).WithField("key", pr.Key).Debugf("Preparing view snapshot") | 	log.G(ctx).WithField("parent", pr.Parent).WithField("key", pr.Key).Debugf("prepare view snapshot") | ||||||
| 	sn, err := s.getSnapshotter(pr.Snapshotter) | 	sn, err := s.getSnapshotter(pr.Snapshotter) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| @@ -112,7 +112,7 @@ func (s *service) View(ctx context.Context, pr *snapshotsapi.ViewSnapshotRequest | |||||||
| } | } | ||||||
|  |  | ||||||
| func (s *service) Mounts(ctx context.Context, mr *snapshotsapi.MountsRequest) (*snapshotsapi.MountsResponse, error) { | func (s *service) Mounts(ctx context.Context, mr *snapshotsapi.MountsRequest) (*snapshotsapi.MountsResponse, error) { | ||||||
| 	log.G(ctx).WithField("key", mr.Key).Debugf("Getting snapshot mounts") | 	log.G(ctx).WithField("key", mr.Key).Debugf("get snapshot mounts") | ||||||
| 	sn, err := s.getSnapshotter(mr.Snapshotter) | 	sn, err := s.getSnapshotter(mr.Snapshotter) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| @@ -128,7 +128,7 @@ func (s *service) Mounts(ctx context.Context, mr *snapshotsapi.MountsRequest) (* | |||||||
| } | } | ||||||
|  |  | ||||||
| func (s *service) Commit(ctx context.Context, cr *snapshotsapi.CommitSnapshotRequest) (*ptypes.Empty, error) { | func (s *service) Commit(ctx context.Context, cr *snapshotsapi.CommitSnapshotRequest) (*ptypes.Empty, error) { | ||||||
| 	log.G(ctx).WithField("key", cr.Key).WithField("name", cr.Name).Debugf("Committing snapshot") | 	log.G(ctx).WithField("key", cr.Key).WithField("name", cr.Name).Debugf("commit snapshot") | ||||||
| 	sn, err := s.getSnapshotter(cr.Snapshotter) | 	sn, err := s.getSnapshotter(cr.Snapshotter) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| @@ -152,7 +152,7 @@ func (s *service) Commit(ctx context.Context, cr *snapshotsapi.CommitSnapshotReq | |||||||
| } | } | ||||||
|  |  | ||||||
| func (s *service) Remove(ctx context.Context, rr *snapshotsapi.RemoveSnapshotRequest) (*ptypes.Empty, error) { | func (s *service) Remove(ctx context.Context, rr *snapshotsapi.RemoveSnapshotRequest) (*ptypes.Empty, error) { | ||||||
| 	log.G(ctx).WithField("key", rr.Key).Debugf("Removing snapshot") | 	log.G(ctx).WithField("key", rr.Key).Debugf("remove snapshot") | ||||||
| 	sn, err := s.getSnapshotter(rr.Snapshotter) | 	sn, err := s.getSnapshotter(rr.Snapshotter) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| @@ -171,7 +171,7 @@ func (s *service) Remove(ctx context.Context, rr *snapshotsapi.RemoveSnapshotReq | |||||||
| } | } | ||||||
|  |  | ||||||
| func (s *service) Stat(ctx context.Context, sr *snapshotsapi.StatSnapshotRequest) (*snapshotsapi.StatSnapshotResponse, error) { | func (s *service) Stat(ctx context.Context, sr *snapshotsapi.StatSnapshotRequest) (*snapshotsapi.StatSnapshotResponse, error) { | ||||||
| 	log.G(ctx).WithField("key", sr.Key).Debugf("Statting snapshot") | 	log.G(ctx).WithField("key", sr.Key).Debugf("stat snapshot") | ||||||
| 	sn, err := s.getSnapshotter(sr.Snapshotter) | 	sn, err := s.getSnapshotter(sr.Snapshotter) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| @@ -186,7 +186,7 @@ func (s *service) Stat(ctx context.Context, sr *snapshotsapi.StatSnapshotRequest | |||||||
| } | } | ||||||
|  |  | ||||||
| func (s *service) Update(ctx context.Context, sr *snapshotsapi.UpdateSnapshotRequest) (*snapshotsapi.UpdateSnapshotResponse, error) { | func (s *service) Update(ctx context.Context, sr *snapshotsapi.UpdateSnapshotRequest) (*snapshotsapi.UpdateSnapshotResponse, error) { | ||||||
| 	log.G(ctx).WithField("key", sr.Info.Name).Debugf("Updating snapshot") | 	log.G(ctx).WithField("key", sr.Info.Name).Debugf("update snapshot") | ||||||
| 	sn, err := s.getSnapshotter(sr.Snapshotter) | 	sn, err := s.getSnapshotter(sr.Snapshotter) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
|   | |||||||
| @@ -168,7 +168,7 @@ func (b *snapshotter) makeSnapshot(ctx context.Context, kind snapshots.Kind, key | |||||||
| 	defer func() { | 	defer func() { | ||||||
| 		if err != nil && t != nil { | 		if err != nil && t != nil { | ||||||
| 			if rerr := t.Rollback(); rerr != nil { | 			if rerr := t.Rollback(); rerr != nil { | ||||||
| 				log.G(ctx).WithError(rerr).Warn("Failure rolling back transaction") | 				log.G(ctx).WithError(rerr).Warn("failed to rollback transaction") | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	}() | 	}() | ||||||
| @@ -203,7 +203,7 @@ func (b *snapshotter) makeSnapshot(ctx context.Context, kind snapshots.Kind, key | |||||||
| 	t = nil | 	t = nil | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		if derr := btrfs.SubvolDelete(target); derr != nil { | 		if derr := btrfs.SubvolDelete(target); derr != nil { | ||||||
| 			log.G(ctx).WithError(derr).WithField("subvolume", target).Error("Failed to delete subvolume") | 			log.G(ctx).WithError(derr).WithField("subvolume", target).Error("failed to delete subvolume") | ||||||
| 		} | 		} | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
| @@ -245,7 +245,7 @@ func (b *snapshotter) Commit(ctx context.Context, name, key string, opts ...snap | |||||||
| 	defer func() { | 	defer func() { | ||||||
| 		if err != nil && t != nil { | 		if err != nil && t != nil { | ||||||
| 			if rerr := t.Rollback(); rerr != nil { | 			if rerr := t.Rollback(); rerr != nil { | ||||||
| 				log.G(ctx).WithError(rerr).Warn("Failure rolling back transaction") | 				log.G(ctx).WithError(rerr).Warn("failed to rollback transaction") | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	}() | 	}() | ||||||
| @@ -266,14 +266,14 @@ func (b *snapshotter) Commit(ctx context.Context, name, key string, opts ...snap | |||||||
| 	t = nil | 	t = nil | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		if derr := btrfs.SubvolDelete(target); derr != nil { | 		if derr := btrfs.SubvolDelete(target); derr != nil { | ||||||
| 			log.G(ctx).WithError(derr).WithField("subvolume", target).Error("Failed to delete subvolume") | 			log.G(ctx).WithError(derr).WithField("subvolume", target).Error("failed to delete subvolume") | ||||||
| 		} | 		} | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if derr := btrfs.SubvolDelete(source); derr != nil { | 	if derr := btrfs.SubvolDelete(source); derr != nil { | ||||||
| 		// Log as warning, only needed for cleanup, will not cause name collision | 		// Log as warning, only needed for cleanup, will not cause name collision | ||||||
| 		log.G(ctx).WithError(derr).WithField("subvolume", source).Warn("Failed to delete subvolume") | 		log.G(ctx).WithError(derr).WithField("subvolume", source).Warn("failed to delete subvolume") | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	return nil | 	return nil | ||||||
| @@ -313,13 +313,13 @@ func (b *snapshotter) Remove(ctx context.Context, key string) (err error) { | |||||||
| 	defer func() { | 	defer func() { | ||||||
| 		if err != nil && t != nil { | 		if err != nil && t != nil { | ||||||
| 			if rerr := t.Rollback(); rerr != nil { | 			if rerr := t.Rollback(); rerr != nil { | ||||||
| 				log.G(ctx).WithError(rerr).Warn("Failure rolling back transaction") | 				log.G(ctx).WithError(rerr).Warn("failed to rollback transaction") | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if removed != "" { | 		if removed != "" { | ||||||
| 			if derr := btrfs.SubvolDelete(removed); derr != nil { | 			if derr := btrfs.SubvolDelete(removed); derr != nil { | ||||||
| 				log.G(ctx).WithError(derr).WithField("subvolume", removed).Warn("Failed to delete subvolume") | 				log.G(ctx).WithError(derr).WithField("subvolume", removed).Warn("failed to delete subvolume") | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	}() | 	}() | ||||||
| @@ -361,7 +361,7 @@ func (b *snapshotter) Remove(ctx context.Context, key string) (err error) { | |||||||
| 				logrus.ErrorKey: err1, | 				logrus.ErrorKey: err1, | ||||||
| 				"subvolume":     source, | 				"subvolume":     source, | ||||||
| 				"renamed":       removed, | 				"renamed":       removed, | ||||||
| 			}).Error("Failed to restore subvolume from renamed") | 			}).Error("failed to restore subvolume from renamed") | ||||||
| 			// Keep removed to allow for manual restore | 			// Keep removed to allow for manual restore | ||||||
| 			removed = "" | 			removed = "" | ||||||
| 		} | 		} | ||||||
|   | |||||||
| @@ -157,7 +157,7 @@ func (o *snapshotter) Commit(ctx context.Context, name, key string, opts ...snap | |||||||
|  |  | ||||||
| 	if _, err := storage.CommitActive(ctx, key, name, snapshots.Usage(usage), opts...); err != nil { | 	if _, err := storage.CommitActive(ctx, key, name, snapshots.Usage(usage), opts...); err != nil { | ||||||
| 		if rerr := t.Rollback(); rerr != nil { | 		if rerr := t.Rollback(); rerr != nil { | ||||||
| 			log.G(ctx).WithError(rerr).Warn("Failure rolling back transaction") | 			log.G(ctx).WithError(rerr).Warn("failed to rollback transaction") | ||||||
| 		} | 		} | ||||||
| 		return errors.Wrap(err, "failed to commit snapshot") | 		return errors.Wrap(err, "failed to commit snapshot") | ||||||
| 	} | 	} | ||||||
| @@ -174,7 +174,7 @@ func (o *snapshotter) Remove(ctx context.Context, key string) (err error) { | |||||||
| 	defer func() { | 	defer func() { | ||||||
| 		if err != nil && t != nil { | 		if err != nil && t != nil { | ||||||
| 			if rerr := t.Rollback(); rerr != nil { | 			if rerr := t.Rollback(); rerr != nil { | ||||||
| 				log.G(ctx).WithError(rerr).Warn("Failure rolling back transaction") | 				log.G(ctx).WithError(rerr).Warn("failed to rollback transaction") | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	}() | 	}() | ||||||
| @@ -199,7 +199,7 @@ func (o *snapshotter) Remove(ctx context.Context, key string) (err error) { | |||||||
| 		if renamed != "" { | 		if renamed != "" { | ||||||
| 			if err1 := os.Rename(renamed, path); err1 != nil { | 			if err1 := os.Rename(renamed, path); err1 != nil { | ||||||
| 				// May cause inconsistent data on disk | 				// May cause inconsistent data on disk | ||||||
| 				log.G(ctx).WithError(err1).WithField("path", renamed).Errorf("Failed to rename after failed commit") | 				log.G(ctx).WithError(err1).WithField("path", renamed).Errorf("failed to rename after failed commit") | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		return errors.Wrap(err, "failed to commit") | 		return errors.Wrap(err, "failed to commit") | ||||||
| @@ -207,7 +207,7 @@ func (o *snapshotter) Remove(ctx context.Context, key string) (err error) { | |||||||
| 	if renamed != "" { | 	if renamed != "" { | ||||||
| 		if err := os.RemoveAll(renamed); err != nil { | 		if err := os.RemoveAll(renamed); err != nil { | ||||||
| 			// Must be cleaned up, any "rm-*" could be removed if no active transactions | 			// Must be cleaned up, any "rm-*" could be removed if no active transactions | ||||||
| 			log.G(ctx).WithError(err).WithField("path", renamed).Warnf("Failed to remove root filesystem") | 			log.G(ctx).WithError(err).WithField("path", renamed).Warnf("failed to remove root filesystem") | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -259,7 +259,7 @@ func (o *snapshotter) createSnapshot(ctx context.Context, kind snapshots.Kind, k | |||||||
| 	s, err := storage.CreateSnapshot(ctx, kind, key, parent, opts...) | 	s, err := storage.CreateSnapshot(ctx, kind, key, parent, opts...) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		if rerr := t.Rollback(); rerr != nil { | 		if rerr := t.Rollback(); rerr != nil { | ||||||
| 			log.G(ctx).WithError(rerr).Warn("Failure rolling back transaction") | 			log.G(ctx).WithError(rerr).Warn("failed to rollback transaction") | ||||||
| 		} | 		} | ||||||
| 		return nil, errors.Wrap(err, "failed to create snapshot") | 		return nil, errors.Wrap(err, "failed to create snapshot") | ||||||
| 	} | 	} | ||||||
| @@ -275,7 +275,7 @@ func (o *snapshotter) createSnapshot(ctx context.Context, kind snapshots.Kind, k | |||||||
| 		path = o.getSnapshotDir(s.ID) | 		path = o.getSnapshotDir(s.ID) | ||||||
| 		if err := os.Rename(td, path); err != nil { | 		if err := os.Rename(td, path); err != nil { | ||||||
| 			if rerr := t.Rollback(); rerr != nil { | 			if rerr := t.Rollback(); rerr != nil { | ||||||
| 				log.G(ctx).WithError(rerr).Warn("Failure rolling back transaction") | 				log.G(ctx).WithError(rerr).Warn("failed to rollback transaction") | ||||||
| 			} | 			} | ||||||
| 			return nil, errors.Wrap(err, "failed to rename") | 			return nil, errors.Wrap(err, "failed to rename") | ||||||
| 		} | 		} | ||||||
|   | |||||||
| @@ -172,7 +172,7 @@ func (o *snapshotter) Commit(ctx context.Context, name, key string, opts ...snap | |||||||
| 	defer func() { | 	defer func() { | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			if rerr := t.Rollback(); rerr != nil { | 			if rerr := t.Rollback(); rerr != nil { | ||||||
| 				log.G(ctx).WithError(rerr).Warn("Failure rolling back transaction") | 				log.G(ctx).WithError(rerr).Warn("failed to rollback transaction") | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	}() | 	}() | ||||||
| @@ -204,7 +204,7 @@ func (o *snapshotter) Remove(ctx context.Context, key string) (err error) { | |||||||
| 	defer func() { | 	defer func() { | ||||||
| 		if err != nil && t != nil { | 		if err != nil && t != nil { | ||||||
| 			if rerr := t.Rollback(); rerr != nil { | 			if rerr := t.Rollback(); rerr != nil { | ||||||
| 				log.G(ctx).WithError(rerr).Warn("Failure rolling back transaction") | 				log.G(ctx).WithError(rerr).Warn("failed to rollback transaction") | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	}() | 	}() | ||||||
| @@ -225,13 +225,13 @@ func (o *snapshotter) Remove(ctx context.Context, key string) (err error) { | |||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		if err1 := os.Rename(renamed, path); err1 != nil { | 		if err1 := os.Rename(renamed, path); err1 != nil { | ||||||
| 			// May cause inconsistent data on disk | 			// May cause inconsistent data on disk | ||||||
| 			log.G(ctx).WithError(err1).WithField("path", renamed).Errorf("Failed to rename after failed commit") | 			log.G(ctx).WithError(err1).WithField("path", renamed).Errorf("failed to rename after failed commit") | ||||||
| 		} | 		} | ||||||
| 		return errors.Wrap(err, "failed to commit") | 		return errors.Wrap(err, "failed to commit") | ||||||
| 	} | 	} | ||||||
| 	if err := os.RemoveAll(renamed); err != nil { | 	if err := os.RemoveAll(renamed); err != nil { | ||||||
| 		// Must be cleaned up, any "rm-*" could be removed if no active transactions | 		// Must be cleaned up, any "rm-*" could be removed if no active transactions | ||||||
| 		log.G(ctx).WithError(err).WithField("path", renamed).Warnf("Failed to remove root filesystem") | 		log.G(ctx).WithError(err).WithField("path", renamed).Warnf("failed to remove root filesystem") | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	return nil | 	return nil | ||||||
| @@ -291,7 +291,7 @@ func (o *snapshotter) createSnapshot(ctx context.Context, kind snapshots.Kind, k | |||||||
| 	defer func() { | 	defer func() { | ||||||
| 		if isRollback { | 		if isRollback { | ||||||
| 			if rerr := t.Rollback(); rerr != nil { | 			if rerr := t.Rollback(); rerr != nil { | ||||||
| 				log.G(ctx).WithError(rerr).Warn("Failure rolling back transaction") | 				log.G(ctx).WithError(rerr).Warn("failed to rollback transaction") | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	}() | 	}() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Derek McGowan
					Derek McGowan