Use local cleanup method rather than dependency

Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
Derek McGowan
2024-11-13 21:51:06 -08:00
parent 264801efb1
commit a63602472d

View File

@@ -13,7 +13,6 @@ import (
"github.com/containerd/containerd/content"
"github.com/containerd/containerd/diff"
"github.com/containerd/containerd/mount"
"github.com/containerd/containerd/pkg/cleanup"
"github.com/containerd/containerd/snapshots"
cerrdefs "github.com/containerd/errdefs"
"github.com/containerd/log"
@@ -199,7 +198,7 @@ func (i *ImageService) createDiff(ctx context.Context, name string, sn snapshots
if err != nil {
return nil, "", err
}
defer cleanup.Do(ctx, func(ctx context.Context) {
defer cleanup(ctx, func(ctx context.Context) {
sn.Remove(ctx, upperKey)
})
}
@@ -210,7 +209,7 @@ func (i *ImageService) createDiff(ctx context.Context, name string, sn snapshots
if err != nil {
return nil, "", err
}
defer cleanup.Do(ctx, func(ctx context.Context) {
defer cleanup(ctx, func(ctx context.Context) {
sn.Remove(ctx, lowerKey)
})
@@ -303,6 +302,12 @@ func uniquePart() string {
return fmt.Sprintf("%d-%s", t.Nanosecond(), base64.URLEncoding.EncodeToString(b[:]))
}
func cleanup(ctx context.Context, do func(context.Context)) {
ctx, cancel := context.WithTimeout(context.WithoutCancel(ctx), 10*time.Second)
do(ctx)
cancel()
}
// CommitBuildStep is used by the builder to create an image for each step in
// the build.
//