Merge pull request #847 from dmcgowan/overlay-commit-bug
overlay: call rollback on commit error
This commit is contained in:
commit
a9be12a52f
@ -152,6 +152,14 @@ func (o *snapshotter) Commit(ctx context.Context, name, key string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
if rerr := t.Rollback(); rerr != nil {
|
||||||
|
log.G(ctx).WithError(rerr).Warn("Failure rolling back transaction")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
// grab the existing id
|
// grab the existing id
|
||||||
id, _, _, err := storage.GetInfo(ctx, key)
|
id, _, _, err := storage.GetInfo(ctx, key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -163,10 +171,7 @@ func (o *snapshotter) Commit(ctx context.Context, name, key string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := storage.CommitActive(ctx, key, name, snapshot.Usage(usage)); err != nil {
|
if _, err = storage.CommitActive(ctx, key, name, snapshot.Usage(usage)); err != nil {
|
||||||
if rerr := t.Rollback(); rerr != nil {
|
|
||||||
log.G(ctx).WithError(rerr).Warn("Failure rolling back transaction")
|
|
||||||
}
|
|
||||||
return errors.Wrap(err, "failed to commit snapshot")
|
return errors.Wrap(err, "failed to commit snapshot")
|
||||||
}
|
}
|
||||||
return t.Commit()
|
return t.Commit()
|
||||||
|
Loading…
Reference in New Issue
Block a user