From 4becdaca723ad76df981df99ce98d00f7253fbe9 Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Fri, 22 Nov 2024 09:17:34 -0800 Subject: [PATCH] Add label on PrepareSnapshot to warn about non-expiring leases Currently when preparing a snapshot for a container, a lease is used to hold that snapshot for the lifespan of a container. That is workaround to preserve the snapshot when a container is recreated, however, the containerd object should be able to hold this reference itself. Signed-off-by: Derek McGowan --- daemon/containerd/image_snapshot.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/daemon/containerd/image_snapshot.go b/daemon/containerd/image_snapshot.go index 004a0fbdf3..445ffe876a 100644 --- a/daemon/containerd/image_snapshot.go +++ b/daemon/containerd/image_snapshot.go @@ -55,6 +55,11 @@ func (i *ImageService) PrepareSnapshot(ctx context.Context, id string, parentIma parentSnapshot = identity.ChainID(diffIDs).String() } + // TODO: Consider a better way to do this. It is better to have a container directly + // reference a snapshot, however, that is not done today because a container may + // removed and recreated with nothing holding the snapshot in between. Consider + // removing this lease and only temporarily holding a lease on re-create, using + // non-expiring leases introduces the possibility of leaking resources. ls := i.client.LeasesService() lease, err := ls.Create(ctx, leases.WithID(id)) if err != nil {