Summary
Currently the interface for operating on leases is focused entirely around create, listing, and deleting lease objects. From the client perspective, leases are immutable and can only be deleted when done. Internally, leases are mutated whenever provided by requests which create or remove resources (such as snapshots, content, ingests).
However, leases provide a powerful mechanism for doing resource management apart from managing images or containers. Leases themselves are root objects and the only root object which can be expired and not tied to any specific structure. One way this could be leveraged is during operations which do not mutate content, but need to read content as a whole, such as pushing or exporting an image. Today, removal operations which occur mid push or export may result in failing the operation after it has already began. Another example is buildkit needing to manage content and snapshot resources using its own caching structure which are different from the image and container structures used internally by containerd to hold references.
Proposal
Add 3 new functions to to the lease manager interface and leases GRPC api for adding, listing, and removing individual resources. Define a lease resource type consisting of 2 strings (Type and ID) for generically referencing the resource objects held by leases.
The changes in the top level leases package may look like
diff --git a/leases/lease.go b/leases/lease.go
index 909b4ea0bb..e904df0e36 100644
--- a/leases/lease.go
+++ b/leases/lease.go
@@ -32,6 +32,15 @@ type Manager interface {
Create(context.Context, ...Opt) (Lease, error)
Delete(context.Context, Lease, ...DeleteOpt) error
List(context.Context, ...string) ([]Lease, error)
+
+ AddResource(context.Context, Lease, Resource) error
+ RemoveResource(context.Context, Lease, Resource) error
+ ListResource(context.Context, Lease) ([]Resource, error)
+}
+
+type Resource struct {
+ Type string
+ ID string
}
// Lease retains resources to prevent cleanup before
Summary
Currently the interface for operating on leases is focused entirely around create, listing, and deleting lease objects. From the client perspective, leases are immutable and can only be deleted when done. Internally, leases are mutated whenever provided by requests which create or remove resources (such as snapshots, content, ingests).
However, leases provide a powerful mechanism for doing resource management apart from managing images or containers. Leases themselves are root objects and the only root object which can be expired and not tied to any specific structure. One way this could be leveraged is during operations which do not mutate content, but need to read content as a whole, such as pushing or exporting an image. Today, removal operations which occur mid push or export may result in failing the operation after it has already began. Another example is buildkit needing to manage content and snapshot resources using its own caching structure which are different from the image and container structures used internally by containerd to hold references.
Proposal
Add 3 new functions to to the lease manager interface and leases GRPC api for adding, listing, and removing individual resources. Define a lease resource type consisting of 2 strings (Type and ID) for generically referencing the resource objects held by leases.
The changes in the top level leases package may look like