diff --git a/pkg/build/nodeimage/buildcontext.go b/pkg/build/nodeimage/buildcontext.go index cd278848dd..b9fd2379f0 100644 --- a/pkg/build/nodeimage/buildcontext.go +++ b/pkg/build/nodeimage/buildcontext.go @@ -303,26 +303,6 @@ func (c *buildContext) prePullImagesAndWriteManifests(bits kube.Bits, parsedVers return nil, err } - pinFns := []func() error{} - for _, image := range requiredImages { - image := image - pinFns = append(pinFns, func() error { - // pin core bundled images in order to prevent GC-ing - if err := importer.Pin(image, dockerBuildOsAndArch(c.arch)); err != nil { - c.logger.Warnf("Failed to pin %s with error: %v", image, err) - runE := exec.RunErrorForError(err) - c.logger.Warn(string(runE.Output)) - return err - } - return nil - }) - } - // pin all image concurrently and log error if any - if err := errors.UntilErrorConcurrent(pinFns); err != nil { - c.logger.Errorf("Image pin Failed! Failed to pin images %v", err) - // Ignore errors, and don't prevent image building. - } - return importer.ListImported() } diff --git a/pkg/build/nodeimage/imageimporter.go b/pkg/build/nodeimage/imageimporter.go index 3d89e2fd13..2894f57d1d 100644 --- a/pkg/build/nodeimage/imageimporter.go +++ b/pkg/build/nodeimage/imageimporter.go @@ -52,18 +52,10 @@ func (c *containerdImporter) Pull(image, platform string) error { ).SetStdout(io.Discard).SetStderr(io.Discard).Run() } -// kubelet can determine what images to skip while doing image garbage collection -// by checking the pinned attribute of the images through CRI -func (c *containerdImporter) Pin(image, platform string) error { - return c.containerCmder.Command( - "ctr", "--namespace=k8s.io", "images", "label", image, "--platform="+platform, "io.cri-containerd.pinned=pinned", - ).SetStdout(io.Discard).SetStderr(io.Discard).Run() -} - func (c *containerdImporter) LoadCommand() exec.Cmd { return c.containerCmder.Command( // TODO: ideally we do not need this in the future. we have fixed at least one image - "ctr", "--namespace=k8s.io", "images", "import", "--all-platforms", "--no-unpack", "--digests", "-", + "ctr", "--namespace=k8s.io", "images", "import", "--label=io.cri-containerd.pinned=pinned", "--all-platforms", "--no-unpack", "--digests", "-", ) }