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:
Derek McGowan
2017-12-01 14:57:34 -08:00
parent f6df9f6632
commit b28d7cdf1b
9 changed files with 36 additions and 32 deletions

View File

@@ -168,7 +168,7 @@ func (b *snapshotter) makeSnapshot(ctx context.Context, kind snapshots.Kind, key
defer func() {
if err != nil && t != 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
if err != 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
}
@@ -245,7 +245,7 @@ func (b *snapshotter) Commit(ctx context.Context, name, key string, opts ...snap
defer func() {
if err != nil && t != 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
if err != 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
}
if derr := btrfs.SubvolDelete(source); derr != nil {
// 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
@@ -313,13 +313,13 @@ func (b *snapshotter) Remove(ctx context.Context, key string) (err error) {
defer func() {
if err != nil && t != 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 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,
"subvolume": source,
"renamed": removed,
}).Error("Failed to restore subvolume from renamed")
}).Error("failed to restore subvolume from renamed")
// Keep removed to allow for manual restore
removed = ""
}

View File

@@ -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 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")
}
@@ -174,7 +174,7 @@ func (o *snapshotter) Remove(ctx context.Context, key string) (err error) {
defer func() {
if err != nil && t != 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 err1 := os.Rename(renamed, path); err1 != nil {
// 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")
@@ -207,7 +207,7 @@ func (o *snapshotter) Remove(ctx context.Context, key string) (err error) {
if renamed != "" {
if err := os.RemoveAll(renamed); err != nil {
// 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...)
if err != 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")
}
@@ -275,7 +275,7 @@ func (o *snapshotter) createSnapshot(ctx context.Context, kind snapshots.Kind, k
path = o.getSnapshotDir(s.ID)
if err := os.Rename(td, path); err != 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")
}

View File

@@ -172,7 +172,7 @@ func (o *snapshotter) Commit(ctx context.Context, name, key string, opts ...snap
defer func() {
if err != 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() {
if err != nil && t != 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 err1 := os.Rename(renamed, path); err1 != nil {
// 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")
}
if err := os.RemoveAll(renamed); err != nil {
// 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
@@ -291,7 +291,7 @@ func (o *snapshotter) createSnapshot(ctx context.Context, kind snapshots.Kind, k
defer func() {
if isRollback {
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")
}
}
}()