From 0e81f07eaad58edf92d6eeb446e05722a076d409 Mon Sep 17 00:00:00 2001 From: Jack Zhang Date: Tue, 15 Mar 2022 11:14:55 +0800 Subject: [PATCH] use image loaded from cache --- pkg/minikube/node/cache.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/minikube/node/cache.go b/pkg/minikube/node/cache.go index 40432c7c03..fbd53889bf 100644 --- a/pkg/minikube/node/cache.go +++ b/pkg/minikube/node/cache.go @@ -136,6 +136,7 @@ func beginDownloadKicBaseImage(g *errgroup.Group, cc *config.ClusterConfig, down }() for _, img := range append([]string{baseImg}, kic.FallbackImages...) { var err error + var isFromCache bool if driver.IsDocker(cc.Driver) && download.ImageExistsInDaemon(img) && !downloadOnly { klog.Infof("%s exists in daemon, skipping load", img) @@ -161,20 +162,21 @@ func beginDownloadKicBaseImage(g *errgroup.Group, cc *config.ClusterConfig, down err = download.CacheToDaemon(img) if err == nil { klog.Infof("successfully loaded %s from cached tarball", img) - finalImg = img - return nil + isFromCache = true } } if driver.IsDocker(cc.Driver) { - klog.Infof("failed to load %s, will try remote image if available: %v", img, err) - klog.Infof("Downloading %s to local daemon", img) err = download.ImageToDaemon(img) if err == nil { klog.Infof("successfully downloaded %s", img) finalImg = img return nil + } else if isFromCache { + klog.Infof("use image loaded from cache %s", strings.Split(img, "@")[0]) + finalImg = strings.Split(img, "@")[0] + return nil } } klog.Infof("failed to download %s, will try fallback image if available: %v", img, err)