From 2411895715708c24e4804b73346b855bc2dab011 Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Tue, 12 Nov 2019 21:29:53 -0800 Subject: [PATCH] Clarify restart code, remove duplicate health check --- cmd/minikube/cmd/start.go | 4 +++- pkg/minikube/bootstrapper/kubeadm/kubeadm.go | 19 +++++-------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 7c38b9d871..050d9f6890 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -365,7 +365,9 @@ func runStart(cmd *cobra.Command, args []string) { if driverName == driver.None { prepareNone() } - if viper.GetBool(waitUntilHealthy) { + + // Skip pre-existing, because we already waited for health + if viper.GetBool(waitUntilHealthy) && !preExists { if err := bs.WaitForCluster(config.KubernetesConfig, viper.GetDuration(waitTimeout)); err != nil { exit.WithError("Wait failed", err) } diff --git a/pkg/minikube/bootstrapper/kubeadm/kubeadm.go b/pkg/minikube/bootstrapper/kubeadm/kubeadm.go index 4773601355..0090367d4b 100644 --- a/pkg/minikube/bootstrapper/kubeadm/kubeadm.go +++ b/pkg/minikube/bootstrapper/kubeadm/kubeadm.go @@ -492,23 +492,14 @@ func (k *Bootstrapper) RestartCluster(k8s config.KubernetesConfig) error { } // We must ensure that the apiserver is healthy before proceeding - glog.Infof("waiting for apiserver healthz ...") - healthz := func() (bool, error) { - status, err := k.GetAPIServerStatus(net.ParseIP(k8s.NodeIP), k8s.NodePort) - if err != nil { - glog.Warningf("status: %v", err) - return false, nil - } - if status != "Running" { - return false, nil - } - return true, nil + if err := k.waitForApiServerHealthz(time.Now(), k8s, kconst.DefaultControlPlaneTimeout); err != nil { + return errors.Wrap(err, "apiserver healthz") } - if err = wait.PollImmediate(kconst.APICallRetryInterval, kconst.DefaultControlPlaneTimeout, healthz); err != nil { - return fmt.Errorf("apiserver healthz never reported healthy") + if err := k.waitForSystemPods(time.Now(), k8s, kconst.DefaultControlPlaneTimeout); err != nil { + return errors.Wrap(err, "system pods") } - // restart the proxy and coredns + // Explicitly re-enable kubeadm addons (proxy, coredns) so that they will check for IP or configuration changes. if rr, err := k.c.RunCmd(exec.Command("/bin/bash", "-c", fmt.Sprintf("%s phase addon all --config %s", baseCmd, yamlConfigPath))); err != nil { return errors.Wrapf(err, fmt.Sprintf("addon phase cmd:%q", rr.Command())) }