use image loaded from cache

pull/13787/head
Jack Zhang 2022-03-15 11:14:55 +08:00
parent 2b5a15fe19
commit 0e81f07eaa
1 changed files with 6 additions and 4 deletions

View File

@ -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)