Skip to content

Commit

Permalink
fix: fix incorrect finalImg in cache.go
Browse files Browse the repository at this point in the history
  • Loading branch information
ComradeProgrammer authored and medyagh committed Jan 28, 2025
1 parent e85d6ef commit c590592
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
11 changes: 6 additions & 5 deletions pkg/minikube/download/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,11 @@ func ImageToCache(img string) error {
}
}

// GHImageTarballToCache try to download the tarball of kicbase from github release.
// GHKicbaseTarballToCache try to download the tarball of kicbase from github release.
// This is the last resort, in case of all docker registry is not available.
func GHImageTarballToCache(img, imgVersion string) (string, error) {
f := imagePathInCache(img)
func GHKicbaseTarballToCache(kicBaseVersion string) (string, error) {
imageName := fmt.Sprintf("kicbase/stable:%s", kicBaseVersion)
f := imagePathInCache(imageName)
fileLock := f + ".lock"

kicbaseArch := runtime.GOARCH
Expand All @@ -244,9 +245,9 @@ func GHImageTarballToCache(img, imgVersion string) (string, error) {
if releaser != nil {
defer releaser.Release()
}
downloadURL := fmt.Sprintf("https://github.com/kubernetes/minikube/releases/download/%s/%s-%s-%s.tar",
downloadURL := fmt.Sprintf("https://github.com/kubernetes/minikube/releases/download/%s/kicbase-%s-%s.tar",
version.GetVersion(),
img, imgVersion, kicbaseArch)
kicBaseVersion, kicbaseArch)

// we don't want the tarball to be decompressed
// so we pass client options to suppress this behavior
Expand Down
11 changes: 7 additions & 4 deletions pkg/minikube/node/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,18 @@ func beginDownloadKicBaseImage(g *errgroup.Group, cc *config.ClusterConfig, down
out.Ln("")

kicbaseVersion := strings.Split(kic.Version, "-")[0]
finalImg, err = download.GHImageTarballToCache("kicbase", kicbaseVersion)
_, err = download.GHKicbaseTarballToCache(kicbaseVersion)
if err != nil {
klog.Infof("failed to download %s", finalImg)
klog.Infof("failed to download kicbase from github")
return fmt.Errorf("failed to download kic base image or any fallback image")
}
klog.Infof("successfully downloaded %s as fall back image", finalImg)

klog.Infof("successfully downloaded kicbase as fall back image from github")
if !downloadOnly && driver.IsDocker(cc.Driver) {
if finalImg, err = download.CacheToDaemon("kicbase"); err == nil {
if finalImg, err = download.CacheToDaemon(fmt.Sprintf("kicbase/stable:%s", kicbaseVersion)); err == nil {
klog.Infof("successfully loaded and using kicbase from tarball on github")
} else {
return fmt.Errorf("failed to load kic base image into docker: %v", err)
}
}
return nil
Expand Down

0 comments on commit c590592

Please sign in to comment.