Fix tx closed error when upperdirlabel specified

When upperdirLabel specified, overlay Update will throw tx closed error since Commit is invoked before GetInfo

Signed-off-by: cardy.tang <zuniorone@gmail.com>
This commit is contained in:
cardy.tang 2022-05-24 00:05:36 +08:00
parent b5107a8984
commit 9f9ebbd991

View File

@ -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 {
@ -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
}