From 09e2fcad69034c0ad1fc5d24db44b415e9129fd1 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Fri, 6 Mar 2020 17:30:35 -0800 Subject: [PATCH 1/4] fall back to caching images if preload fails --- pkg/minikube/node/config.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/minikube/node/config.go b/pkg/minikube/node/config.go index 2f3dd26fb1ea..0031b4948b38 100644 --- a/pkg/minikube/node/config.go +++ b/pkg/minikube/node/config.go @@ -38,6 +38,7 @@ import ( "k8s.io/minikube/pkg/minikube/exit" "k8s.io/minikube/pkg/minikube/kubeconfig" "k8s.io/minikube/pkg/minikube/localpath" + "k8s.io/minikube/pkg/minikube/machine" "k8s.io/minikube/pkg/minikube/out" "k8s.io/minikube/pkg/util/lock" ) @@ -67,7 +68,10 @@ func configureRuntimes(runner cruntime.CommandRunner, drvName string, k8s config } if !driver.IsKIC(drvName) { if err := cr.Preload(k8s.KubernetesVersion); err != nil { - glog.Infof("Failed to preload container runtime %s: %v", cr.Name(), err) + glog.Infof("Failed to preload container runtime %s: %v, falling back to caching images", cr.Name(), err) + if err := machine.CacheImagesForBootstrapper(k8s.ImageRepository, k8s.KubernetesVersion, viper.GetString(cmdcfg.Bootstrapper)); err != nil { + exit.WithError("Failed to cache images", err) + } } } From 84bc0d440bfb01749a6061c2e85da355acfc6fa2 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Fri, 6 Mar 2020 17:33:13 -0800 Subject: [PATCH 2/4] wait for images to download before configuring runtimes --- pkg/minikube/node/start.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/minikube/node/start.go b/pkg/minikube/node/start.go index d1ac337c31c6..ceee851afe54 100644 --- a/pkg/minikube/node/start.go +++ b/pkg/minikube/node/start.go @@ -55,6 +55,7 @@ func Start(mc config.ClusterConfig, n config.Node, primary bool, existingAddons // exits here in case of --download-only option. handleDownloadOnly(&cacheGroup, &kicGroup, k8sVersion) waitDownloadKicArtifacts(&kicGroup) + waitCacheRequiredImages(&cacheGroup) mRunner, preExists, machineAPI, host := startMachine(&mc, &n) defer machineAPI.Close() @@ -62,7 +63,6 @@ func Start(mc config.ClusterConfig, n config.Node, primary bool, existingAddons // configure the runtime (docker, containerd, crio) cr := configureRuntimes(mRunner, driverName, mc.KubernetesConfig) showVersionInfo(k8sVersion, cr) - waitCacheRequiredImages(&cacheGroup) //TODO(sharifelgamal): Part out the cluster-wide operations, perhaps using the "primary" param From 992b51cd4eee83794bfbe80ef7ac59c94d04eed4 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Fri, 6 Mar 2020 17:35:31 -0800 Subject: [PATCH 3/4] move wait function to after startMachine --- pkg/minikube/node/start.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/minikube/node/start.go b/pkg/minikube/node/start.go index ceee851afe54..045471cacfdb 100644 --- a/pkg/minikube/node/start.go +++ b/pkg/minikube/node/start.go @@ -55,11 +55,12 @@ func Start(mc config.ClusterConfig, n config.Node, primary bool, existingAddons // exits here in case of --download-only option. handleDownloadOnly(&cacheGroup, &kicGroup, k8sVersion) waitDownloadKicArtifacts(&kicGroup) - waitCacheRequiredImages(&cacheGroup) mRunner, preExists, machineAPI, host := startMachine(&mc, &n) defer machineAPI.Close() + waitCacheRequiredImages(&cacheGroup) + // configure the runtime (docker, containerd, crio) cr := configureRuntimes(mRunner, driverName, mc.KubernetesConfig) showVersionInfo(k8sVersion, cr) From 095fd2a526ebe102dc95aaee7ecd7f7a3d962b19 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Fri, 6 Mar 2020 17:36:58 -0800 Subject: [PATCH 4/4] review comments --- pkg/minikube/node/config.go | 2 +- pkg/minikube/node/start.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/minikube/node/config.go b/pkg/minikube/node/config.go index 0031b4948b38..14ad22ae8f5d 100644 --- a/pkg/minikube/node/config.go +++ b/pkg/minikube/node/config.go @@ -68,7 +68,7 @@ func configureRuntimes(runner cruntime.CommandRunner, drvName string, k8s config } if !driver.IsKIC(drvName) { if err := cr.Preload(k8s.KubernetesVersion); err != nil { - glog.Infof("Failed to preload container runtime %s: %v, falling back to caching images", cr.Name(), err) + glog.Errorf("Failed to preload container runtime %s: %v, falling back to caching images", cr.Name(), err) if err := machine.CacheImagesForBootstrapper(k8s.ImageRepository, k8s.KubernetesVersion, viper.GetString(cmdcfg.Bootstrapper)); err != nil { exit.WithError("Failed to cache images", err) } diff --git a/pkg/minikube/node/start.go b/pkg/minikube/node/start.go index 045471cacfdb..8dfbde664360 100644 --- a/pkg/minikube/node/start.go +++ b/pkg/minikube/node/start.go @@ -59,6 +59,7 @@ func Start(mc config.ClusterConfig, n config.Node, primary bool, existingAddons mRunner, preExists, machineAPI, host := startMachine(&mc, &n) defer machineAPI.Close() + // wait for preloaded tarball to finish downloading before configuring runtimes waitCacheRequiredImages(&cacheGroup) // configure the runtime (docker, containerd, crio)