1
0
mirror of https://github.com/moby/buildkit.git synced 2025-07-29 04:01:13 +03:00

ensure context.WithoutCancel in defer funcs

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi
2024-06-12 19:08:04 -07:00
parent 70be02f55c
commit 4103099d94
20 changed files with 56 additions and 43 deletions

View File

@ -46,12 +46,13 @@ func (sr *immutableRef) tryComputeOverlayBlob(ctx context.Context, lower, upper
defer func() {
if cw != nil {
ctx = context.WithoutCancel(ctx)
// after commit success cw will be set to nil, if cw isn't nil, error
// happened before commit, we should abort this ingest, and because the
// error may incured by ctx cancel, use a new context here. And since
// cm.Close will unlock this ref in the content store, we invoke abort
// to remove the ingest root in advance.
if aerr := sr.cm.ContentStore.Abort(context.Background(), ref); aerr != nil {
if aerr := sr.cm.ContentStore.Abort(ctx, ref); aerr != nil {
bklog.G(ctx).WithError(aerr).Warnf("failed to abort writer %q", ref)
}
if cerr := cw.Close(); cerr != nil {