mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
Change containerd image leases from 24h to permanent (#3452)
* Changed containerd image licenses from 24h to permanent. Delete any existing licenses on server startup Signed-off-by: dereknola <derek.nola@suse.com>
This commit is contained in:
parent
88f95ec409
commit
86b3ba8dba
@ -17,6 +17,7 @@ import (
|
|||||||
"github.com/containerd/containerd"
|
"github.com/containerd/containerd"
|
||||||
"github.com/containerd/containerd/errdefs"
|
"github.com/containerd/containerd/errdefs"
|
||||||
"github.com/containerd/containerd/images"
|
"github.com/containerd/containerd/images"
|
||||||
|
"github.com/containerd/containerd/leases"
|
||||||
"github.com/containerd/containerd/namespaces"
|
"github.com/containerd/containerd/namespaces"
|
||||||
"github.com/containerd/containerd/reference/docker"
|
"github.com/containerd/containerd/reference/docker"
|
||||||
"github.com/klauspost/compress/zstd"
|
"github.com/klauspost/compress/zstd"
|
||||||
@ -175,11 +176,24 @@ func preloadImages(ctx context.Context, cfg *config.Node) error {
|
|||||||
|
|
||||||
// Ensure that nothing else can modify the image store while we're importing,
|
// Ensure that nothing else can modify the image store while we're importing,
|
||||||
// and that our images are imported into the k8s.io namespace
|
// and that our images are imported into the k8s.io namespace
|
||||||
ctx, done, err := client.WithLease(namespaces.WithNamespace(ctx, "k8s.io"))
|
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())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer done(ctx)
|
|
||||||
|
|
||||||
for _, fileInfo := range fileInfos {
|
for _, fileInfo := range fileInfos {
|
||||||
if fileInfo.IsDir() {
|
if fileInfo.IsDir() {
|
||||||
|
Loading…
Reference in New Issue
Block a user