Move image existence checks into downloading functions.
parent
26634c18a8
commit
d6f60bbd4a
|
@ -75,6 +75,11 @@ func ImageExistsInDaemon(img string) bool {
|
|||
|
||||
// ImageToCache writes img to the local cache directory
|
||||
func ImageToCache(img string) error {
|
||||
if ImageExistsInCache(img) {
|
||||
klog.Infof("%s exists in cache, skipping pull", img)
|
||||
return nil
|
||||
}
|
||||
|
||||
f := filepath.Join(constants.KICCacheDir, path.Base(img)+".tar")
|
||||
f = localpath.SanitizeCacheDir(f)
|
||||
|
||||
|
@ -140,6 +145,10 @@ func ImageToCache(img string) error {
|
|||
|
||||
// ImageToDaemon writes img to the local docker daemon
|
||||
func ImageToDaemon(img string) error {
|
||||
if ImageExistsInDaemon(img) {
|
||||
klog.Infof("%s exists in daemon, skipping pull", img)
|
||||
return nil
|
||||
}
|
||||
// buffered channel
|
||||
c := make(chan v1.Update, 200)
|
||||
|
||||
|
|
|
@ -127,16 +127,11 @@ func beginDownloadKicBaseImage(g *errgroup.Group, cc *config.ClusterConfig, down
|
|||
}()
|
||||
for _, img := range append([]string{baseImg}, kic.FallbackImages...) {
|
||||
var err error
|
||||
if download.ImageExistsInCache(img) {
|
||||
klog.Infof("%s exists in cache, skipping pull", img)
|
||||
klog.Infof("Downloading %s to local cache", img)
|
||||
err = download.ImageToCache(img)
|
||||
if err == nil {
|
||||
klog.Infof("successfully saved %s as a tarball", img)
|
||||
finalImg = img
|
||||
} else {
|
||||
klog.Infof("Downloading %s to local cache", img)
|
||||
err = download.ImageToCache(img)
|
||||
if err == nil {
|
||||
klog.Infof("successfully saved %s as a tarball", img)
|
||||
finalImg = img
|
||||
}
|
||||
}
|
||||
if downloadOnly {
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue