diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 5b170d9022c8..f7b7221c39db 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -226,12 +226,7 @@ func runStart(cmd *cobra.Command, args []string) { cr := configureRuntimes(host, runner) // prepareHostEnvironment uses the downloaded images, so we need to wait for background task completion. - if viper.GetBool(cacheImages) { - console.OutStyle("waiting", "Waiting for image downloads to complete ...") - if err := cacheGroup.Wait(); err != nil { - glog.Errorln("Error caching images: ", err) - } - } + waitCacheImages(&cacheGroup) bs := prepareHostEnvironment(m, config.KubernetesConfig) @@ -294,6 +289,17 @@ func beginCacheImages(g *errgroup.Group, k8sVersion string) { }) } +// waitCacheImages blocks until the image cache jobs complete +func waitCacheImages(g *errgroup.Group) { + if !viper.GetBool(cacheImages) { + return + } + console.OutStyle("waiting", "Waiting for image downloads to complete ...") + if err := g.Wait(); err != nil { + glog.Errorln("Error caching images: ", err) + } +} + // generateConfig generates cfg.Config based on flags and supplied arguments func generateConfig(cmd *cobra.Command, k8sVersion string) (cfg.Config, error) { r, err := cruntime.New(cruntime.Config{Type: viper.GetString(containerRuntime)})