Skip to content

Commit

Permalink
Don't try to start/stop drivers without VMs
Browse files Browse the repository at this point in the history
It is not supported anyway, and just throws errors.
There is no use to restart or to retry, just give up.

This should never be a problem with "none", though.
That always return running, while generic tests ssh.
  • Loading branch information
afbjorklund committed Mar 28, 2020
1 parent 8358df4 commit b4a455a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 25 deletions.
41 changes: 25 additions & 16 deletions pkg/minikube/machine/fix.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/minikube/driver"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/out"
)

Expand Down Expand Up @@ -132,25 +133,33 @@ func recreateIfNeeded(api libmachine.API, cc config.ClusterConfig, n config.Node
}
}

if serr != constants.ErrMachineMissing {
glog.Warningf("unexpected machine state, will restart: %v", serr)
}
if h.Driver.DriverName() != driver.Generic {
if serr != constants.ErrMachineMissing {
glog.Warningf("unexpected machine state, will restart: %v", serr)
}

if s == state.Running {
if !recreated {
out.T(out.Running, `Updating the running {{.driver_name}} "{{.cluster}}" {{.machine_type}} ...`, out.V{"driver_name": cc.Driver, "cluster": cc.Name, "machine_type": machineType})
if s == state.Running {
if !recreated {
out.T(out.Running, `Updating the running {{.driver_name}} "{{.cluster}}" {{.machine_type}} ...`, out.V{"driver_name": cc.Driver, "cluster": cc.Name, "machine_type": machineType})
}
return h, nil
}
return h, nil
}

if !recreated {
out.T(out.Restarting, `Restarting existing {{.driver_name}} {{.machine_type}} for "{{.cluster}}" ...`, out.V{"driver_name": cc.Driver, "cluster": cc.Name, "machine_type": machineType})
}
if err := h.Driver.Start(); err != nil {
return h, errors.Wrap(err, "driver start")
}
if err := api.Save(h); err != nil {
return h, errors.Wrap(err, "save")
if !recreated {
out.T(out.Restarting, `Restarting existing {{.driver_name}} {{.machine_type}} for "{{.cluster}}" ...`, out.V{"driver_name": cc.Driver, "cluster": cc.Name, "machine_type": machineType})
}
if err := h.Driver.Start(); err != nil {
return h, errors.Wrap(err, "driver start")
}
if err := api.Save(h); err != nil {
return h, errors.Wrap(err, "save")
}
} else {
if s == state.Running {
out.T(out.Running, `Using the {{.driver_name}} "{{.cluster}}" {{.machine_type}} ...`, out.V{"driver_name": cc.Driver, "cluster": cc.Name, "machine_type": machineType})
} else {
exit.WithCodeT(exit.Unavailable, `Unable to reach {{.driver_name}} {{.machine_type}} for "{{.cluster}}"`, out.V{"driver_name": cc.Driver, "cluster": cc.Name, "machine_type": machineType})
}
}
return h, nil
}
Expand Down
16 changes: 9 additions & 7 deletions pkg/minikube/machine/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,16 @@ func stop(h *host.Host) error {
}
}

if err := h.Stop(); err != nil {
glog.Infof("stop err: %v", err)
st, ok := err.(mcnerror.ErrHostAlreadyInState)
if ok && st.State == state.Stopped {
glog.Infof("host is already stopped")
return nil
if h.DriverName != driver.Generic {
if err := h.Stop(); err != nil {
glog.Infof("stop err: %v", err)
st, ok := err.(mcnerror.ErrHostAlreadyInState)
if ok && st.State == state.Stopped {
glog.Infof("host is already stopped")
return nil
}
return &retry.RetriableError{Err: errors.Wrap(err, "stop")}
}
return &retry.RetriableError{Err: errors.Wrap(err, "stop")}
}
glog.Infof("stop complete within %s", time.Since(start))
return nil
Expand Down
2 changes: 0 additions & 2 deletions pkg/minikube/tunnel/route_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,5 +164,3 @@ func (router *osRouter) Cleanup(route *Route) error {
}
return nil
}


0 comments on commit b4a455a

Please sign in to comment.