Fix check for stopping k8s.

pull/13072/head
klaases 2021-12-03 14:15:00 -08:00
parent f3186d07d8
commit 47a280bdc7
2 changed files with 14 additions and 4 deletions

View File

@ -295,10 +295,9 @@ func provisionWithDriver(cmd *cobra.Command, ds registry.DriverState, existing *
updateDriver(driverName)
}
// If Kubernetes is running, and --no-kubernetes is specified, stop.
// Check whether we may need to stop Kubernetes.
var stopk8s bool
if existing != nil && existing.KubernetesConfig.KubernetesVersion != constants.NoKubernetesVersion && viper.GetBool(noKubernetes) {
klog.Infof("ABC1 existing.KubernetesConfig.KubernetesVersion %s", existing.KubernetesConfig.KubernetesVersion)
if existing != nil && viper.GetBool(noKubernetes) {
stopk8s = true
}

View File

@ -803,7 +803,14 @@ func (k *Bootstrapper) GenerateToken(cc config.ClusterConfig) (string, error) {
// StopKubernetes attempts to stop existing kubernetes.
func StopKubernetes(runner command.Runner, cr cruntime.Manager) {
out.Infof("Stopping Kubernetes ...")
// Verify that Kubernetes is still running.
stk := kverify.ServiceStatus(runner, "kubelet")
if stk.String() != "Running" {
return
}
out.Infof("Kubernetes: Stopping ...")
// Force stop "Kubelet".
if err := sysinit.New(runner).ForceStop("kubelet"); err != nil {
@ -821,6 +828,10 @@ func StopKubernetes(runner command.Runner, cr cruntime.Manager) {
klog.Warningf("error stopping containers: %v", err)
}
}
// Verify that Kubernetes has stopped.
stk = kverify.ServiceStatus(runner, "kubelet")
out.Infof("Kubernetes: {{.status}}", out.V{"status": stk.String()})
}
// DeleteCluster removes the components that were started earlier