Skip to content

Commit 6dcfc40

Browse files
committed
kicbase: simplify the image loading logic
This change refactors beginDownloadKicBaseImage() a bit to achieve a more streamlined flow of logic, combining redundant blocks. In the special case of podman, it leaves image loading from cache loading from cache unimplemented and replaces the confusing and unhelpful message by a more helpful one. Signed-off-by: Michael Adam <[email protected]>
1 parent 6d351f1 commit 6dcfc40

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

pkg/minikube/node/cache.go

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -154,31 +154,33 @@ func beginDownloadKicBaseImage(g *errgroup.Group, cc *config.ClusterConfig, down
154154
var err error
155155
for _, img := range append([]string{baseImg}, kic.FallbackImages...) {
156156

157-
if driver.IsDocker(cc.Driver) && download.ImageExistsInDaemon(img) && !downloadOnly {
158-
klog.Infof("%s exists in daemon, skipping load", img)
159-
finalImg = img
160-
return nil
161-
}
157+
if driver.IsDocker(cc.Driver) {
158+
if download.ImageExistsInDaemon(img) {
159+
klog.Infof("%s exists in daemon, skipping load", img)
160+
finalImg = img
161+
return nil
162+
}
162163

163-
klog.Infof("Downloading %s to local cache", img)
164-
err = download.ImageToCache(img)
165-
if err == nil {
166-
klog.Infof("successfully saved %s as a tarball", img)
167-
}
168-
if downloadOnly && err == nil {
169-
return nil
170-
}
164+
klog.Infof("Downloading %s to local cache", img)
165+
err = download.ImageToCache(img)
166+
if err == nil {
167+
klog.Infof("successfully saved %s as a tarball", img)
168+
}
169+
if downloadOnly {
170+
return nil
171+
}
171172

172-
if cc.Driver == driver.Podman {
173-
return fmt.Errorf("not yet implemented, see issue #8426")
174-
}
175-
if driver.IsDocker(cc.Driver) && err == nil {
176173
klog.Infof("Loading %s from local cache", img)
177174
if finalImg, err = download.CacheToDaemon(img); err == nil {
178175
klog.Infof("successfully loaded and using %s from cached tarball", img)
179176
return nil
180177
}
181178
}
179+
if cc.Driver == driver.Podman {
180+
return fmt.Errorf("skipping image load via cache: not implemented for podman. see issue #8426")
181+
182+
}
183+
182184
klog.Infof("failed to download %s, will try fallback image if available: %v", img, err)
183185
}
184186
// second if we failed to download any fallback image

0 commit comments

Comments
 (0)