Clarify restart code, remove duplicate health check
parent
7e5ab0417b
commit
2411895715
|
@ -365,7 +365,9 @@ func runStart(cmd *cobra.Command, args []string) {
|
||||||
if driverName == driver.None {
|
if driverName == driver.None {
|
||||||
prepareNone()
|
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 {
|
if err := bs.WaitForCluster(config.KubernetesConfig, viper.GetDuration(waitTimeout)); err != nil {
|
||||||
exit.WithError("Wait failed", err)
|
exit.WithError("Wait failed", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -492,23 +492,14 @@ func (k *Bootstrapper) RestartCluster(k8s config.KubernetesConfig) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// We must ensure that the apiserver is healthy before proceeding
|
// We must ensure that the apiserver is healthy before proceeding
|
||||||
glog.Infof("waiting for apiserver healthz ...")
|
if err := k.waitForApiServerHealthz(time.Now(), k8s, kconst.DefaultControlPlaneTimeout); err != nil {
|
||||||
healthz := func() (bool, error) {
|
return errors.Wrap(err, "apiserver healthz")
|
||||||
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 = wait.PollImmediate(kconst.APICallRetryInterval, kconst.DefaultControlPlaneTimeout, healthz); err != nil {
|
if err := k.waitForSystemPods(time.Now(), k8s, kconst.DefaultControlPlaneTimeout); err != nil {
|
||||||
return fmt.Errorf("apiserver healthz never reported healthy")
|
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 {
|
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()))
|
return errors.Wrapf(err, fmt.Sprintf("addon phase cmd:%q", rr.Command()))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue