Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more reliable stop for none driver #4871

Merged
merged 6 commits into from
Jul 25, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion pkg/drivers/none/none.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package none
import (
"fmt"
"strings"
"time"

"github.com/docker/machine/libmachine/drivers"
"github.com/docker/machine/libmachine/state"
Expand All @@ -29,6 +30,7 @@ import (
"k8s.io/minikube/pkg/minikube/command"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/minikube/cruntime"
"k8s.io/minikube/pkg/util"
)

const driverName = constants.DriverNone
Expand Down Expand Up @@ -218,7 +220,26 @@ func (d *Driver) RunSSHCommandFromDriver() error {
// stopKubelet idempotently stops the kubelet
func stopKubelet(exec command.Runner) error {
glog.Infof("stopping kubelet.service ...")
return exec.Run("sudo systemctl stop kubelet.service")
stop := func() error {
err := exec.Run("sudo systemctl stop kubelet.service")
out, errStatus := exec.CombinedOutput("sudo systemctl show -p SubState --value kubelet")
if err != nil {
glog.Errorf("Temporary Error: getting systemctl status for kubelet:", errStatus)
}
if errStatus != nil {
glog.Errorf("Temporary Error: failed to get systemctl status for kubelet:", errStatus)
}
if !strings.Contains(out, "dead") {
return fmt.Errorf("expected to kublet to be dead but it got %s", out)
medyagh marked this conversation as resolved.
Show resolved Hide resolved
}
return nil
}

if err := util.RetryAfter(3, stop, 2*time.Second); err != nil {
return errors.Wrapf(err, "Error stopping kubelet")
}

return nil
}

// restartKubelet restarts the kubelet
Expand Down