Skip to content

Commit

Permalink
Fix tx closed error when upperdirlabel specified
Browse files Browse the repository at this point in the history
When upperdirLabel specified, overlay Update will throw tx closed error since Commit is invoked before GetInfo

Signed-off-by: cardy.tang <zuniorone@gmail.com>
(cherry picked from commit 9f9ebbd)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
  • Loading branch information
cardyok authored and thaJeztah committed Jan 24, 2023
1 parent 4ca63a1 commit 8c70403
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions snapshots/overlay/overlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,6 @@ func (o *snapshotter) Update(ctx context.Context, info snapshots.Info, fieldpath
return snapshots.Info{}, err
}

if err := t.Commit(); err != nil {
return snapshots.Info{}, err
}

if o.upperdirLabel {
id, _, _, err := storage.GetInfo(ctx, info.Name)
if err != nil {
Expand All @@ -175,6 +171,10 @@ func (o *snapshotter) Update(ctx context.Context, info snapshots.Info, fieldpath
info.Labels[upperdirKey] = o.upperPath(id)
}

if err := t.Commit(); err != nil {
return snapshots.Info{}, err
}

return info, nil
}

Expand Down

0 comments on commit 8c70403

Please sign in to comment.