Skip to content

Commit

Permalink
Fallback to trying kic image without SHA when using image registry
Browse files Browse the repository at this point in the history
Signed-off-by: ghosind <[email protected]>
  • Loading branch information
ghosind committed Jan 8, 2025
1 parent 07ebc23 commit 99ec65a
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions pkg/minikube/node/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,19 @@ func beginDownloadKicBaseImage(g *errgroup.Group, cc *config.ClusterConfig, down
register.Reg.SetStep(register.PullingBaseImage)
out.Step(style.Pulling, "Pulling base image {{.kicVersion}} ...", out.V{"kicVersion": kic.Version})
g.Go(func() error {
images := make([]string, 0, 2+len(kic.FallbackImages))
baseImg := cc.KicBaseImage
baseFallbackImg := ""
if baseImg == kic.BaseImage && len(cc.KubernetesConfig.ImageRepository) != 0 {
baseImg = updateKicImageRepo(baseImg, cc.KubernetesConfig.ImageRepository)
baseImg, baseFallbackImg = updateKicImageRepo(baseImg, cc.KubernetesConfig.ImageRepository)
cc.KicBaseImage = baseImg
}
images = append(images, baseImg)
if baseFallbackImg != "" && baseFallbackImg != baseImg {
images = append(images, baseFallbackImg)
}
images = append(images, kic.FallbackImages...)

var finalImg string
// If we end up using a fallback image, notify the user
defer func() {
Expand All @@ -139,7 +147,7 @@ func beginDownloadKicBaseImage(g *errgroup.Group, cc *config.ClusterConfig, down
}()
// first we try to download the kicbase image (and fall back images) from docker registry
var err error
for _, img := range append([]string{baseImg}, kic.FallbackImages...) {
for _, img := range images {

if driver.IsDocker(cc.Driver) && download.ImageExistsInDaemon(img) && !downloadOnly {
klog.Infof("%s exists in daemon, skipping load", img)
Expand Down Expand Up @@ -278,13 +286,16 @@ func imagesInConfigFile() ([]string, error) {
return []string{}, nil
}

func updateKicImageRepo(imgName string, repo string) string {
func updateKicImageRepo(imgName string, repo string) (string, string) {
image := strings.TrimPrefix(imgName, "gcr.io/")
if repo == constants.AliyunMirror {
// for aliyun registry must strip namespace from image name, e.g.
// registry.cn-hangzhou.aliyuncs.com/google_containers/k8s-minikube/kicbase:v0.0.25 will not work
// registry.cn-hangzhou.aliyuncs.com/google_containers/kicbase:v0.0.25 does work
image = strings.TrimPrefix(image, "k8s-minikube/")
}
return path.Join(repo, image)
baseImg := path.Join(repo, image)
// try a fallback image without sha, because #11068
fallbackImg := strings.Split(image, "@sha256:")[0]
return baseImg, fallbackImg
}

0 comments on commit 99ec65a

Please sign in to comment.