Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker driver: add fall back image in docker hub #8320

Merged
merged 2 commits into from
May 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions pkg/drivers/kic/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,15 @@ const (
var (
// BaseImage is the base image is used to spin up kic containers. it uses same base-image as kind.
BaseImage = fmt.Sprintf("gcr.io/k8s-minikube/kicbase:%s@sha256:%s", Version, baseImageSHA)
// BaseImageFallBack the fall back of BaseImage in case gcr.io is not available. stored in github packages https://github.com/kubernetes/minikube/packages/206071

// BaseImageFallBack1 the fall back of BaseImage in case gcr.io is not available. stored in docker hub
// same image is push to https://github.com/kicbase/stable
BaseImageFallBack1 = fmt.Sprintf("kicbase/stable:%s@sha256:%s", Version, baseImageSHA)

// BaseImageFallBack2 the fall back of BaseImage in case gcr.io is not available. stored in github packages https://github.com/kubernetes/minikube/packages/206071
// github packages docker does _NOT_ support pulling by sha as mentioned in the docs:
// https://help.github.com/en/packages/using-github-packages-with-your-projects-ecosystem/configuring-docker-for-use-with-github-packages
BaseImageFallBack = fmt.Sprintf("docker.pkg.github.com/kubernetes/minikube/kicbase:%s", Version)
BaseImageFallBack2 = fmt.Sprintf("docker.pkg.github.com/kubernetes/minikube/kicbase:%s", Version)
Copy link

@priyawadhwa priyawadhwa May 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be cleaner to create an array of images, and then go through them in order until we find one that works

var BaseImages = []string{
 fmt.Sprintf("gcr.io/k8s-minikube/kicbase:%s@sha256:%s", Version, baseImageSHA),
 fmt.Sprintf("kicbase/stable:%s@sha256:%s", Version, baseImageSHA),
 fmt.Sprintf("docker.pkg.github.com/kubernetes/minikube/kicbase:%s", Version)
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good the problem is when looping over the array, would need to detect if there is not any more fallback to return the error, seems like a good idea for a follow up refactor

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, this should definitely be a slice.

)

// Config is configuration for the kic driver used by registry
Expand Down
10 changes: 7 additions & 3 deletions pkg/minikube/node/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,13 @@ func beginDownloadKicArtifacts(g *errgroup.Group, cc *config.ClusterConfig) {
glog.Infof("Downloading %s to local daemon", cc.KicBaseImage)
err := image.WriteImageToDaemon(cc.KicBaseImage)
if err != nil {
glog.Infof("failed to download base-image %q will try to download the fallback base-image %q instead.", cc.KicBaseImage, kic.BaseImageFallBack)
cc.KicBaseImage = kic.BaseImageFallBack
return image.WriteImageToDaemon(kic.BaseImageFallBack)
glog.Infof("failed to download base-image %q will try to download the fallback base-image %q instead.", cc.KicBaseImage, kic.BaseImageFallBack1)
cc.KicBaseImage = kic.BaseImageFallBack1
if err := image.WriteImageToDaemon(kic.BaseImageFallBack1); err != nil {
cc.KicBaseImage = kic.BaseImageFallBack2
glog.Infof("failed to docker hub base-image %q will try to download the github packages base-image %q instead.", cc.KicBaseImage, kic.BaseImageFallBack2)
return image.WriteImageToDaemon(kic.BaseImageFallBack2)
}
}
return nil
})
Expand Down
2 changes: 1 addition & 1 deletion test/integration/fn_mount_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const (
createdByPodRemovedByTest = "created-by-pod-removed-by-test"
)

func validateMountCmd(ctx context.Context, t *testing.T, profile string) { // nolint: cyclomatic complexity 31
func validateMountCmd(ctx context.Context, t *testing.T, profile string) { // nolint
if NoneDriver() {
t.Skip("skipping: none driver does not support mount")
}
Expand Down