From b74c499709e6cd3da41a360bdcc8668e606cf1a3 Mon Sep 17 00:00:00 2001 From: Derek Nola Date: Tue, 15 Jun 2021 14:56:14 -0700 Subject: [PATCH] Revert "Change containerd image leases from 24h to permanent (#3452)" (#3461) This reverts commit 86b3ba8dbae9aa4df51f8ed7175fa5b6457ff868. --- pkg/agent/containerd/containerd.go | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/pkg/agent/containerd/containerd.go b/pkg/agent/containerd/containerd.go index 11f02561eb..ad5be86ac0 100644 --- a/pkg/agent/containerd/containerd.go +++ b/pkg/agent/containerd/containerd.go @@ -17,7 +17,6 @@ import ( "github.com/containerd/containerd" "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" - "github.com/containerd/containerd/leases" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/reference/docker" "github.com/klauspost/compress/zstd" @@ -176,24 +175,11 @@ func preloadImages(ctx context.Context, cfg *config.Node) error { // Ensure that nothing else can modify the image store while we're importing, // and that our images are imported into the k8s.io namespace - ctx = namespaces.WithNamespace(ctx, "k8s.io") - // At startup all images in the store with a lease are cleared - ls := client.LeasesService() - existingLeases, err := ls.List(ctx) - if err != nil { - return err - } - - for _, lease := range existingLeases { - logrus.Debugf("Deleting existing lease: %v", lease) - ls.Delete(ctx, lease) - } - - // Any images found on import are given a lease that never expires - _, err = ls.Create(ctx, leases.WithRandomID()) + ctx, done, err := client.WithLease(namespaces.WithNamespace(ctx, "k8s.io")) if err != nil { return err } + defer done(ctx) for _, fileInfo := range fileInfos { if fileInfo.IsDir() {