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 Oct 24, 2020
1 parent 19918ca commit d53a0d3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 24 deletions.
42 changes: 25 additions & 17 deletions pkg/minikube/machine/fix.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,26 +135,34 @@ func recreateIfNeeded(api libmachine.API, cc *config.ClusterConfig, n *config.No
}
}

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

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

if !recreated {
out.T(style.Restarting, `Restarting existing {{.driver_name}} {{.machine_type}} for "{{.cluster}}" ...`, out.V{"driver_name": cc.Driver, "cluster": machineName, "machine_type": machineType})
}
if err := h.Driver.Start(); err != nil {
MaybeDisplayAdvice(err, h.DriverName)
return h, errors.Wrap(err, "driver start")
}
if err := saveHost(api, h, cc, n); err != nil {
return h, err
if !recreated {
out.T(style.Restarting, `Restarting existing {{.driver_name}} {{.machine_type}} for "{{.cluster}}" ...`, out.V{"driver_name": cc.Driver, "cluster": machineName, "machine_type": machineType})
}
if err := h.Driver.Start(); err != nil {
MaybeDisplayAdvice(err, h.DriverName)
return h, errors.Wrap(err, "driver start")
}
if err := saveHost(api, h, cc, n); err != nil {
return h, err
}
} else {
if s == state.Running {
out.T(style.Running, `Using the {{.driver_name}} "{{.cluster}}" {{.machine_type}} ...`, out.V{"driver_name": cc.Driver, "cluster": cc.Name, "machine_type": machineType})
} else {
return h, errors.Errorf("not running")
}
}

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 @@ -55,14 +55,16 @@ func stop(h *host.Host) error {
}
}

if err := h.Stop(); err != nil {
klog.Infof("stop err: %v", err)
st, ok := err.(mcnerror.ErrHostAlreadyInState)
if ok && st.State == state.Stopped {
klog.Infof("host is already stopped")
return nil
if h.DriverName != driver.Generic {
if err := h.Stop(); err != nil {
klog.Infof("stop err: %v", err)
st, ok := err.(mcnerror.ErrHostAlreadyInState)
if ok && st.State == state.Stopped {
klog.Infof("host is already stopped")
return nil
}
return &retry.RetriableError{Err: errors.Wrap(err, "stop")}
}
return &retry.RetriableError{Err: errors.Wrap(err, "stop")}
}
klog.Infof("duration metric: stop complete within %s", time.Since(start))
return nil
Expand Down

0 comments on commit d53a0d3

Please sign in to comment.