Skip to content

Commit

Permalink
Merge pull request moby#46582 from vvoland/c8d-push-defer-noncancella…
Browse files Browse the repository at this point in the history
…ble-context

daemon/c8d: Use non cancellable context in defers
  • Loading branch information
thaJeztah authored Oct 3, 2023
2 parents 77a1411 + 6f27bef commit bc2c827
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion daemon/containerd/image_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/docker/docker/api/types/backend"
imagetypes "github.com/docker/docker/api/types/image"
"github.com/docker/docker/api/types/registry"
"github.com/docker/docker/internal/compatcontext"
registrypkg "github.com/docker/docker/registry"

// "github.com/docker/docker/api/types/container"
Expand Down Expand Up @@ -450,7 +451,7 @@ func (i *ImageService) CreateImage(ctx context.Context, config []byte, parent st
return nil, err
}
defer func() {
if err := release(ctx); err != nil {
if err := release(compatcontext.WithoutCancel(ctx)); err != nil {
log.G(ctx).WithError(err).Warn("failed to release lease created for create")
}
}()
Expand Down
3 changes: 2 additions & 1 deletion daemon/containerd/image_commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/docker/docker/api/types/backend"
"github.com/docker/docker/image"
imagespec "github.com/docker/docker/image/spec/specs-go/v1"
"github.com/docker/docker/internal/compatcontext"
"github.com/docker/docker/pkg/archive"
"github.com/opencontainers/go-digest"
"github.com/opencontainers/image-spec/identity"
Expand Down Expand Up @@ -74,7 +75,7 @@ func (i *ImageService) CommitImage(ctx context.Context, cc backend.CommitConfig)
return "", fmt.Errorf("failed to create lease for commit: %w", err)
}
defer func() {
if err := release(ctx); err != nil {
if err := release(compatcontext.WithoutCancel(ctx)); err != nil {
log.G(ctx).WithError(err).Warn("failed to release lease created for commit")
}
}()
Expand Down
3 changes: 2 additions & 1 deletion daemon/containerd/image_import.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/docker/docker/errdefs"
"github.com/docker/docker/image"
imagespec "github.com/docker/docker/image/spec/specs-go/v1"
"github.com/docker/docker/internal/compatcontext"
"github.com/docker/docker/pkg/archive"
"github.com/docker/docker/pkg/pools"
"github.com/google/uuid"
Expand Down Expand Up @@ -49,7 +50,7 @@ func (i *ImageService) ImportImage(ctx context.Context, ref reference.Named, pla
return "", errdefs.System(err)
}
defer func() {
if err := release(ctx); err != nil {
if err := release(compatcontext.WithoutCancel(ctx)); err != nil {
logger.WithError(err).Warn("failed to release lease created for import")
}
}()
Expand Down
3 changes: 2 additions & 1 deletion daemon/containerd/image_push.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/docker/docker/api/types/events"
"github.com/docker/docker/api/types/registry"
"github.com/docker/docker/errdefs"
"github.com/docker/docker/internal/compatcontext"
"github.com/docker/docker/pkg/progress"
"github.com/docker/docker/pkg/streamformatter"
"github.com/opencontainers/go-digest"
Expand Down Expand Up @@ -84,7 +85,7 @@ func (i *ImageService) pushRef(ctx context.Context, targetRef reference.Named, m
return err
}
defer func() {
if err := release(leasedCtx); err != nil {
if err := release(compatcontext.WithoutCancel(leasedCtx)); err != nil {
log.G(ctx).WithField("image", targetRef).WithError(err).Warn("failed to release lease created for push")
}
}()
Expand Down

0 comments on commit bc2c827

Please sign in to comment.