Clarify logic around beginDownloadKicArtifacts
parent
1f7ae5b35b
commit
1a01b9450c
|
@ -35,8 +35,8 @@ import (
|
||||||
"k8s.io/minikube/pkg/minikube/out"
|
"k8s.io/minikube/pkg/minikube/out"
|
||||||
)
|
)
|
||||||
|
|
||||||
// beginCacheRequiredImages caches images required for kubernetes version in the background
|
// beginCacheKubernetesImages caches images required for kubernetes version in the background
|
||||||
func beginCacheRequiredImages(g *errgroup.Group, imageRepository string, k8sVersion string) {
|
func beginCacheKubernetesImages(g *errgroup.Group, imageRepository string, k8sVersion string) {
|
||||||
if !viper.GetBool("cache-images") {
|
if !viper.GetBool("cache-images") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -82,17 +82,22 @@ func doCacheBinaries(k8sVersion string) error {
|
||||||
return machine.CacheBinariesForBootstrapper(k8sVersion, viper.GetString(cmdcfg.Bootstrapper))
|
return machine.CacheBinariesForBootstrapper(k8sVersion, viper.GetString(cmdcfg.Bootstrapper))
|
||||||
}
|
}
|
||||||
|
|
||||||
func beginDownloadKicArtifacts(g *errgroup.Group, k8sVersion, cRuntime string) {
|
// beginDownloadKicArtifacts downloads the kic image + preload tarball, returns true if preload is available
|
||||||
|
func beginDownloadKicArtifacts(g *errgroup.Group, k8sVersion, cRuntime string) bool {
|
||||||
glog.Info("Beginning downloading kic artifacts")
|
glog.Info("Beginning downloading kic artifacts")
|
||||||
g.Go(func() error {
|
g.Go(func() error {
|
||||||
glog.Infof("Downloading %s to local daemon", kic.BaseImage)
|
glog.Infof("Downloading %s to local daemon", kic.BaseImage)
|
||||||
return image.WriteImageToDaemon(kic.BaseImage)
|
return image.WriteImageToDaemon(kic.BaseImage)
|
||||||
})
|
})
|
||||||
|
|
||||||
g.Go(func() error {
|
if download.PreloadExists(k8sVersion, cRuntime) {
|
||||||
glog.Info("Caching tarball of preloaded images")
|
g.Go(func() error {
|
||||||
return download.Preload(k8sVersion, cRuntime)
|
glog.Info("Caching tarball of preloaded images")
|
||||||
})
|
return download.Preload(k8sVersion, cRuntime)
|
||||||
|
})
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func waitDownloadKicArtifacts(g *errgroup.Group) {
|
func waitDownloadKicArtifacts(g *errgroup.Group) {
|
||||||
|
|
|
@ -23,7 +23,6 @@ import (
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
"k8s.io/minikube/pkg/addons"
|
"k8s.io/minikube/pkg/addons"
|
||||||
"k8s.io/minikube/pkg/minikube/config"
|
"k8s.io/minikube/pkg/minikube/config"
|
||||||
"k8s.io/minikube/pkg/minikube/download"
|
|
||||||
"k8s.io/minikube/pkg/minikube/driver"
|
"k8s.io/minikube/pkg/minikube/driver"
|
||||||
"k8s.io/minikube/pkg/minikube/exit"
|
"k8s.io/minikube/pkg/minikube/exit"
|
||||||
"k8s.io/minikube/pkg/minikube/kubeconfig"
|
"k8s.io/minikube/pkg/minikube/kubeconfig"
|
||||||
|
@ -41,17 +40,17 @@ func Start(mc config.ClusterConfig, n config.Node, primary bool, existingAddons
|
||||||
// See if we can create a volume of preloaded images
|
// See if we can create a volume of preloaded images
|
||||||
// If not, pull images in the background while the VM boots.
|
// If not, pull images in the background while the VM boots.
|
||||||
var kicGroup errgroup.Group
|
var kicGroup errgroup.Group
|
||||||
downloadImages := true
|
needKubernetesImages := true
|
||||||
if driver.IsKIC(driverName) {
|
if driver.IsKIC(driverName) {
|
||||||
if download.PreloadExists(k8sVersion, mc.KubernetesConfig.ContainerRuntime) {
|
// If we can download a preload tarball, it isn't necessary to pull Kubernetes images
|
||||||
beginDownloadKicArtifacts(&kicGroup, k8sVersion, mc.KubernetesConfig.ContainerRuntime)
|
if beginDownloadKicArtifacts(&kicGroup, k8sVersion, mc.KubernetesConfig.ContainerRuntime) {
|
||||||
downloadImages = false
|
needKubernetesImages = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var cacheGroup errgroup.Group
|
var cacheGroup errgroup.Group
|
||||||
if downloadImages {
|
if needKubernetesImages {
|
||||||
beginCacheRequiredImages(&cacheGroup, mc.KubernetesConfig.ImageRepository, k8sVersion)
|
beginCacheKubernetesImages(&cacheGroup, mc.KubernetesConfig.ImageRepository, k8sVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Abstraction leakage alert: startHost requires the config to be saved, to satistfy pkg/provision/buildroot.
|
// Abstraction leakage alert: startHost requires the config to be saved, to satistfy pkg/provision/buildroot.
|
||||||
|
|
Loading…
Reference in New Issue