2019-01-01 08:23:01 +00:00
|
|
|
package containerd
|
|
|
|
|
|
|
|
import (
|
2020-05-05 21:41:21 +00:00
|
|
|
"bufio"
|
2019-01-01 08:23:01 +00:00
|
|
|
"context"
|
|
|
|
"fmt"
|
2019-02-08 04:12:49 +00:00
|
|
|
"io"
|
2019-01-01 08:23:01 +00:00
|
|
|
"os"
|
|
|
|
"os/exec"
|
2019-03-02 15:56:27 +00:00
|
|
|
"path/filepath"
|
2020-05-05 21:41:21 +00:00
|
|
|
"strings"
|
2019-01-01 08:23:01 +00:00
|
|
|
"time"
|
|
|
|
|
2019-03-07 00:34:05 +00:00
|
|
|
"github.com/containerd/containerd"
|
2021-02-12 07:37:58 +00:00
|
|
|
"github.com/containerd/containerd/errdefs"
|
|
|
|
"github.com/containerd/containerd/images"
|
2019-03-07 00:34:05 +00:00
|
|
|
"github.com/containerd/containerd/namespaces"
|
2021-08-20 08:32:17 +00:00
|
|
|
"github.com/containerd/containerd/pkg/cri/constants"
|
2023-12-08 19:51:28 +00:00
|
|
|
"github.com/containerd/containerd/pkg/cri/labels"
|
2021-02-12 07:37:58 +00:00
|
|
|
"github.com/containerd/containerd/reference/docker"
|
2023-01-27 21:16:59 +00:00
|
|
|
"github.com/k3s-io/k3s/pkg/agent/cri"
|
2022-03-02 23:47:27 +00:00
|
|
|
util2 "github.com/k3s-io/k3s/pkg/agent/util"
|
|
|
|
"github.com/k3s-io/k3s/pkg/daemons/config"
|
|
|
|
"github.com/k3s-io/k3s/pkg/version"
|
2019-02-08 04:12:49 +00:00
|
|
|
"github.com/natefinch/lumberjack"
|
2020-02-24 20:13:59 +00:00
|
|
|
"github.com/pkg/errors"
|
2021-11-24 19:03:30 +00:00
|
|
|
"github.com/rancher/wharfie/pkg/tarfile"
|
2021-02-12 07:37:58 +00:00
|
|
|
"github.com/rancher/wrangler/pkg/merr"
|
2019-01-01 08:23:01 +00:00
|
|
|
"github.com/sirupsen/logrus"
|
2022-12-09 23:42:15 +00:00
|
|
|
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
|
2019-01-01 08:23:01 +00:00
|
|
|
)
|
|
|
|
|
2023-12-08 19:51:28 +00:00
|
|
|
var (
|
|
|
|
// In addition to using the CRI pinned label, we add our own label to indicate that
|
|
|
|
// the image was pinned by the import process, so that we can clear the pin on subsequent startups.
|
|
|
|
// ref: https://github.com/containerd/containerd/blob/release/1.7/pkg/cri/labels/labels.go
|
|
|
|
k3sPinnedImageLabelKey = "io.cattle." + version.Program + ".pinned"
|
|
|
|
k3sPinnedImageLabelValue = "pinned"
|
|
|
|
)
|
|
|
|
|
2021-02-12 07:37:58 +00:00
|
|
|
// Run configures and starts containerd as a child process. Once it is up, images are preloaded
|
|
|
|
// or pulled from files found in the agent images directory.
|
2019-01-09 16:54:15 +00:00
|
|
|
func Run(ctx context.Context, cfg *config.Node) error {
|
2019-04-19 21:08:05 +00:00
|
|
|
if err := setupContainerdConfig(ctx, cfg); err != nil {
|
2019-01-01 08:23:01 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-12-16 20:00:40 +00:00
|
|
|
args := getContainerdArgs(cfg)
|
2019-02-08 04:12:49 +00:00
|
|
|
stdOut := io.Writer(os.Stdout)
|
|
|
|
stdErr := io.Writer(os.Stderr)
|
|
|
|
|
|
|
|
if cfg.Containerd.Log != "" {
|
|
|
|
logrus.Infof("Logging containerd to %s", cfg.Containerd.Log)
|
2023-01-13 18:30:50 +00:00
|
|
|
fileOut := &lumberjack.Logger{
|
2019-02-08 04:12:49 +00:00
|
|
|
Filename: cfg.Containerd.Log,
|
|
|
|
MaxSize: 50,
|
|
|
|
MaxBackups: 3,
|
|
|
|
MaxAge: 28,
|
|
|
|
Compress: true,
|
|
|
|
}
|
2023-01-13 18:30:50 +00:00
|
|
|
// If k3s is started with --debug, write logs to both the log file and stdout/stderr,
|
|
|
|
// even if a log path is set.
|
|
|
|
if cfg.Containerd.Debug {
|
|
|
|
stdOut = io.MultiWriter(stdOut, fileOut)
|
|
|
|
stdErr = io.MultiWriter(stdErr, fileOut)
|
|
|
|
} else {
|
|
|
|
stdOut = fileOut
|
|
|
|
stdErr = fileOut
|
|
|
|
}
|
2019-01-01 08:23:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
go func() {
|
2020-12-11 22:40:36 +00:00
|
|
|
env := []string{}
|
2022-06-14 23:28:02 +00:00
|
|
|
cenv := []string{}
|
2020-12-11 22:40:36 +00:00
|
|
|
|
|
|
|
for _, e := range os.Environ() {
|
|
|
|
pair := strings.SplitN(e, "=", 2)
|
|
|
|
switch {
|
|
|
|
case pair[0] == "NOTIFY_SOCKET":
|
|
|
|
// elide NOTIFY_SOCKET to prevent spurious notifications to systemd
|
|
|
|
case pair[0] == "CONTAINERD_LOG_LEVEL":
|
|
|
|
// Turn CONTAINERD_LOG_LEVEL variable into log-level flag
|
|
|
|
args = append(args, "--log-level", pair[1])
|
|
|
|
case strings.HasPrefix(pair[0], "CONTAINERD_"):
|
|
|
|
// Strip variables with CONTAINERD_ prefix before passing through
|
|
|
|
// This allows doing things like setting a proxy for image pulls by setting
|
|
|
|
// CONTAINERD_https_proxy=http://proxy.example.com:8080
|
|
|
|
pair[0] = strings.TrimPrefix(pair[0], "CONTAINERD_")
|
2022-06-14 23:28:02 +00:00
|
|
|
cenv = append(cenv, strings.Join(pair, "="))
|
2020-12-11 22:40:36 +00:00
|
|
|
default:
|
|
|
|
env = append(env, strings.Join(pair, "="))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-09 16:54:15 +00:00
|
|
|
logrus.Infof("Running containerd %s", config.ArgString(args[1:]))
|
2021-11-08 15:32:43 +00:00
|
|
|
cmd := exec.CommandContext(ctx, args[0], args[1:]...)
|
2019-02-08 04:12:49 +00:00
|
|
|
cmd.Stdout = stdOut
|
|
|
|
cmd.Stderr = stdErr
|
2022-06-14 23:28:02 +00:00
|
|
|
cmd.Env = append(env, cenv...)
|
2020-12-11 22:40:36 +00:00
|
|
|
|
2020-02-22 18:39:33 +00:00
|
|
|
addDeathSig(cmd)
|
2019-01-01 08:23:01 +00:00
|
|
|
if err := cmd.Run(); err != nil {
|
2023-08-28 17:17:05 +00:00
|
|
|
logrus.Errorf("containerd exited: %s", err)
|
2019-01-01 08:23:01 +00:00
|
|
|
}
|
|
|
|
os.Exit(1)
|
|
|
|
}()
|
|
|
|
|
2023-01-27 21:16:59 +00:00
|
|
|
if err := cri.WaitForService(ctx, cfg.Containerd.Address, "containerd"); err != nil {
|
2022-01-25 18:02:54 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return preloadImages(ctx, cfg)
|
|
|
|
}
|
|
|
|
|
2021-02-12 07:37:58 +00:00
|
|
|
// preloadImages reads the contents of the agent images directory, and attempts to
|
|
|
|
// import into containerd any files found there. Supported compressed types are decompressed, and
|
|
|
|
// any .txt files are processed as a list of images that should be pre-pulled from remote registries.
|
|
|
|
// If configured, imported images are retagged as being pulled from additional registries.
|
2020-05-05 21:41:21 +00:00
|
|
|
func preloadImages(ctx context.Context, cfg *config.Node) error {
|
2019-03-04 20:45:30 +00:00
|
|
|
fileInfo, err := os.Stat(cfg.Images)
|
2019-03-07 16:47:37 +00:00
|
|
|
if os.IsNotExist(err) {
|
|
|
|
return nil
|
|
|
|
} else if err != nil {
|
2019-03-07 00:34:05 +00:00
|
|
|
logrus.Errorf("Unable to find images in %s: %v", cfg.Images, err)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if !fileInfo.IsDir() {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-10-08 00:36:57 +00:00
|
|
|
fileInfos, err := os.ReadDir(cfg.Images)
|
2019-03-07 00:34:05 +00:00
|
|
|
if err != nil {
|
|
|
|
logrus.Errorf("Unable to read images in %s: %v", cfg.Images, err)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-03-29 23:16:34 +00:00
|
|
|
client, err := Client(cfg.Containerd.Address)
|
2019-03-07 00:34:05 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer client.Close()
|
|
|
|
|
2023-12-08 19:51:28 +00:00
|
|
|
// Image pulls must be done using the CRI client, not the containerd client.
|
|
|
|
// Repository mirrors and rewrites are handled by the CRI service; if you pull directly
|
|
|
|
// using the containerd image service it will ignore the configured settings.
|
2023-01-27 21:16:59 +00:00
|
|
|
criConn, err := cri.Connection(ctx, cfg.Containerd.Address)
|
2020-05-05 21:41:21 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer criConn.Close()
|
2023-12-08 19:51:28 +00:00
|
|
|
imageClient := runtimeapi.NewImageServiceClient(criConn)
|
2020-05-05 21:41:21 +00:00
|
|
|
|
2021-08-03 20:07:02 +00:00
|
|
|
// Ensure that our images are imported into the correct namespace
|
|
|
|
ctx = namespaces.WithNamespace(ctx, constants.K8sContainerdNamespace)
|
|
|
|
|
2023-12-08 19:51:28 +00:00
|
|
|
// At startup all leases from k3s are cleared; we no longer use leases to lock content
|
|
|
|
if err := clearLeases(ctx, client); err != nil {
|
|
|
|
return errors.Wrap(err, "failed to clear leases")
|
2021-06-16 19:11:10 +00:00
|
|
|
}
|
|
|
|
|
2023-12-08 19:51:28 +00:00
|
|
|
// Clear the pinned labels on all images previously pinned by k3s
|
|
|
|
if err := clearLabels(ctx, client); err != nil {
|
|
|
|
return errors.Wrap(err, "failed to clear pinned labels")
|
2021-02-12 07:37:58 +00:00
|
|
|
}
|
2019-03-07 00:34:05 +00:00
|
|
|
|
|
|
|
for _, fileInfo := range fileInfos {
|
2019-03-02 15:56:27 +00:00
|
|
|
if fileInfo.IsDir() {
|
2019-03-07 00:34:05 +00:00
|
|
|
continue
|
2019-03-02 15:56:27 +00:00
|
|
|
}
|
|
|
|
|
2021-02-12 07:37:58 +00:00
|
|
|
start := time.Now()
|
2019-03-07 00:34:05 +00:00
|
|
|
filePath := filepath.Join(cfg.Images, fileInfo.Name())
|
|
|
|
|
2023-12-08 19:51:28 +00:00
|
|
|
if err := preloadFile(ctx, cfg, client, imageClient, filePath); err != nil {
|
2021-02-12 07:37:58 +00:00
|
|
|
logrus.Errorf("Error encountered while importing %s: %v", filePath, err)
|
2019-03-07 00:34:05 +00:00
|
|
|
continue
|
|
|
|
}
|
2021-11-24 19:03:30 +00:00
|
|
|
logrus.Infof("Imported images from %s in %s", filePath, time.Since(start))
|
2021-02-12 07:37:58 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2019-03-07 00:34:05 +00:00
|
|
|
|
2021-02-12 07:37:58 +00:00
|
|
|
// preloadFile handles loading images from a single tarball or pre-pull image list.
|
|
|
|
// This is in its own function so that we can ensure that the various readers are properly closed, as some
|
|
|
|
// decompressing readers need to be explicitly closed and others do not.
|
2023-12-08 19:51:28 +00:00
|
|
|
func preloadFile(ctx context.Context, cfg *config.Node, client *containerd.Client, imageClient runtimeapi.ImageServiceClient, filePath string) error {
|
|
|
|
var images []images.Image
|
2021-11-24 19:03:30 +00:00
|
|
|
if util2.HasSuffixI(filePath, ".txt") {
|
|
|
|
file, err := os.Open(filePath)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer file.Close()
|
|
|
|
logrus.Infof("Pulling images from %s", filePath)
|
2023-12-08 19:51:28 +00:00
|
|
|
images, err = prePullImages(ctx, client, imageClient, file)
|
|
|
|
if err != nil {
|
|
|
|
return errors.Wrap(err, "failed to pull images from "+filePath)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
opener, err := tarfile.GetOpener(filePath)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
imageReader, err := opener()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer imageReader.Close()
|
|
|
|
|
|
|
|
logrus.Infof("Importing images from %s", filePath)
|
|
|
|
images, err = client.Import(ctx, imageReader, containerd.WithAllPlatforms(true))
|
|
|
|
if err != nil {
|
|
|
|
return errors.Wrap(err, "failed to import images from "+filePath)
|
|
|
|
}
|
2021-11-24 19:03:30 +00:00
|
|
|
}
|
|
|
|
|
2023-12-08 19:51:28 +00:00
|
|
|
if err := labelImages(ctx, client, images); err != nil {
|
|
|
|
return errors.Wrap(err, "failed to add pinned label to images")
|
|
|
|
}
|
|
|
|
if err := retagImages(ctx, client, images, cfg.AgentConfig.AirgapExtraRegistry); err != nil {
|
|
|
|
return errors.Wrap(err, "failed to retag images")
|
2021-02-12 07:37:58 +00:00
|
|
|
}
|
2020-05-05 21:41:21 +00:00
|
|
|
|
2023-12-08 19:51:28 +00:00
|
|
|
for _, image := range images {
|
|
|
|
logrus.Infof("Imported %s", image.Name)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// clearLeases deletes any leases left by previous versions of k3s.
|
|
|
|
// We no longer use leases to lock content; they only locked the
|
|
|
|
// blobs, not the actual images.
|
|
|
|
func clearLeases(ctx context.Context, client *containerd.Client) error {
|
|
|
|
ls := client.LeasesService()
|
|
|
|
existingLeases, err := ls.List(ctx)
|
2021-11-24 19:03:30 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
2021-02-12 07:37:58 +00:00
|
|
|
}
|
2023-12-08 19:51:28 +00:00
|
|
|
for _, lease := range existingLeases {
|
|
|
|
if lease.ID == version.Program {
|
|
|
|
logrus.Debugf("Deleting existing lease: %v", lease)
|
|
|
|
ls.Delete(ctx, lease)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2021-02-12 07:37:58 +00:00
|
|
|
|
2023-12-08 19:51:28 +00:00
|
|
|
// clearLabels removes the pinned labels on all images in the image store that were previously pinned by k3s
|
|
|
|
func clearLabels(ctx context.Context, client *containerd.Client) error {
|
|
|
|
var errs []error
|
|
|
|
imageService := client.ImageService()
|
|
|
|
images, err := imageService.List(ctx, fmt.Sprintf("labels.%q==%s", k3sPinnedImageLabelKey, k3sPinnedImageLabelValue))
|
2021-02-12 07:37:58 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2023-12-08 19:51:28 +00:00
|
|
|
for _, image := range images {
|
|
|
|
delete(image.Labels, k3sPinnedImageLabelKey)
|
|
|
|
delete(image.Labels, labels.PinnedImageLabelKey)
|
|
|
|
if _, err := imageService.Update(ctx, image, "labels"); err != nil {
|
|
|
|
errs = append(errs, errors.Wrap(err, "failed to delete labels from image "+image.Name))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return merr.NewErrors(errs...)
|
|
|
|
}
|
2021-02-12 07:37:58 +00:00
|
|
|
|
2023-12-08 19:51:28 +00:00
|
|
|
// labelImages adds labels to the listed images, indicating that they
|
|
|
|
// are pinned by k3s and should not be pruned.
|
|
|
|
func labelImages(ctx context.Context, client *containerd.Client, images []images.Image) error {
|
|
|
|
var errs []error
|
|
|
|
imageService := client.ImageService()
|
|
|
|
for i, image := range images {
|
|
|
|
if image.Labels[k3sPinnedImageLabelKey] == k3sPinnedImageLabelValue &&
|
|
|
|
image.Labels[labels.PinnedImageLabelKey] == labels.PinnedImageLabelValue {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
if image.Labels == nil {
|
|
|
|
image.Labels = map[string]string{}
|
|
|
|
}
|
|
|
|
image.Labels[k3sPinnedImageLabelKey] = k3sPinnedImageLabelValue
|
|
|
|
image.Labels[labels.PinnedImageLabelKey] = labels.PinnedImageLabelValue
|
|
|
|
updatedImage, err := imageService.Update(ctx, image, "labels")
|
|
|
|
if err != nil {
|
|
|
|
errs = append(errs, errors.Wrap(err, "failed to add labels to image "+image.Name))
|
|
|
|
} else {
|
|
|
|
images[i] = updatedImage
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return merr.NewErrors(errs...)
|
2021-02-12 07:37:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// retagImages retags all listed images as having been pulled from the given remote registries.
|
|
|
|
// If duplicate images exist, they are overwritten. This is most useful when using a private registry
|
|
|
|
// for all images, as can be configured by the RKE2/Rancher system-default-registry setting.
|
|
|
|
func retagImages(ctx context.Context, client *containerd.Client, images []images.Image, registries []string) error {
|
|
|
|
var errs []error
|
|
|
|
imageService := client.ImageService()
|
|
|
|
for _, image := range images {
|
|
|
|
name, err := parseNamedTagged(image.Name)
|
2019-03-07 00:34:05 +00:00
|
|
|
if err != nil {
|
2023-12-08 19:51:28 +00:00
|
|
|
errs = append(errs, errors.Wrap(err, "failed to parse tags for image "+image.Name))
|
2021-02-12 07:37:58 +00:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
for _, registry := range registries {
|
2023-12-08 19:51:28 +00:00
|
|
|
newName := fmt.Sprintf("%s/%s:%s", registry, docker.Path(name), name.Tag())
|
|
|
|
if newName == image.Name {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
image.Name = newName
|
2021-02-12 07:37:58 +00:00
|
|
|
if _, err = imageService.Create(ctx, image); err != nil {
|
|
|
|
if errdefs.IsAlreadyExists(err) {
|
|
|
|
if err = imageService.Delete(ctx, image.Name); err != nil {
|
2023-12-08 19:51:28 +00:00
|
|
|
errs = append(errs, errors.Wrap(err, "failed to delete existing image "+image.Name))
|
2021-02-12 07:37:58 +00:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
if _, err = imageService.Create(ctx, image); err != nil {
|
2023-12-08 19:51:28 +00:00
|
|
|
errs = append(errs, errors.Wrap(err, "failed to tag after deleting existing image "+image.Name))
|
2021-02-12 07:37:58 +00:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
} else {
|
2023-12-08 19:51:28 +00:00
|
|
|
errs = append(errs, errors.Wrap(err, "failed to tag image "+image.Name))
|
2021-02-12 07:37:58 +00:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
logrus.Infof("Tagged %s", image.Name)
|
2019-03-07 00:34:05 +00:00
|
|
|
}
|
|
|
|
}
|
2021-02-12 07:37:58 +00:00
|
|
|
return merr.NewErrors(errs...)
|
2019-01-01 08:23:01 +00:00
|
|
|
}
|
2019-04-19 21:08:05 +00:00
|
|
|
|
2021-02-12 07:37:58 +00:00
|
|
|
// parseNamedTagged parses and normalizes an image name, and converts the resulting reference
|
|
|
|
// to a type that exposes the tag.
|
|
|
|
func parseNamedTagged(name string) (docker.NamedTagged, error) {
|
|
|
|
ref, err := docker.ParseNormalizedNamed(name)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
tagged, ok := ref.(docker.NamedTagged)
|
|
|
|
if !ok {
|
|
|
|
return nil, fmt.Errorf("can't cast %T to NamedTagged", ref)
|
|
|
|
}
|
|
|
|
return tagged, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// prePullImages asks containerd to pull images in a given list, so that they
|
2023-12-08 19:51:28 +00:00
|
|
|
// are ready when the containers attempt to start later. If the image already exists,
|
|
|
|
// or is successfully pulled, information about the image is retrieved from the image store.
|
|
|
|
// NOTE: Pulls MUST be done via CRI API, not containerd API, in order to use mirrors and rewrites.
|
|
|
|
func prePullImages(ctx context.Context, client *containerd.Client, imageClient runtimeapi.ImageServiceClient, imageList io.Reader) ([]images.Image, error) {
|
|
|
|
errs := []error{}
|
|
|
|
images := []images.Image{}
|
|
|
|
imageService := client.ImageService()
|
|
|
|
scanner := bufio.NewScanner(imageList)
|
2020-05-05 21:41:21 +00:00
|
|
|
for scanner.Scan() {
|
2023-12-08 19:51:28 +00:00
|
|
|
name := strings.TrimSpace(scanner.Text())
|
|
|
|
if _, err := imageClient.ImageStatus(ctx, &runtimeapi.ImageStatusRequest{
|
2020-05-05 21:41:21 +00:00
|
|
|
Image: &runtimeapi.ImageSpec{
|
2023-12-08 19:51:28 +00:00
|
|
|
Image: name,
|
2020-05-05 21:41:21 +00:00
|
|
|
},
|
2023-12-08 19:51:28 +00:00
|
|
|
}); err == nil {
|
|
|
|
logrus.Infof("Image %s has already been pulled", name)
|
|
|
|
if image, err := imageService.Get(ctx, name); err != nil {
|
|
|
|
errs = append(errs, err)
|
|
|
|
} else {
|
|
|
|
images = append(images, image)
|
|
|
|
}
|
2020-05-05 21:41:21 +00:00
|
|
|
continue
|
|
|
|
}
|
2023-12-08 19:51:28 +00:00
|
|
|
logrus.Infof("Pulling image %s", name)
|
|
|
|
if _, err := imageClient.PullImage(ctx, &runtimeapi.PullImageRequest{
|
2020-05-05 21:41:21 +00:00
|
|
|
Image: &runtimeapi.ImageSpec{
|
2023-12-08 19:51:28 +00:00
|
|
|
Image: name,
|
2020-05-05 21:41:21 +00:00
|
|
|
},
|
2023-12-08 19:51:28 +00:00
|
|
|
}); err != nil {
|
|
|
|
errs = append(errs, err)
|
|
|
|
} else {
|
|
|
|
if image, err := imageService.Get(ctx, name); err != nil {
|
|
|
|
errs = append(errs, err)
|
|
|
|
} else {
|
|
|
|
images = append(images, image)
|
|
|
|
}
|
2020-05-05 21:41:21 +00:00
|
|
|
}
|
|
|
|
}
|
2023-12-08 19:51:28 +00:00
|
|
|
return images, merr.NewErrors(errs...)
|
2020-05-05 21:41:21 +00:00
|
|
|
}
|