commit
ab64cb952e
|
|
@ -19,11 +19,13 @@ package cmd
|
|||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
cmdUtil "k8s.io/minikube/cmd/util"
|
||||
"k8s.io/minikube/pkg/minikube/cluster"
|
||||
"k8s.io/minikube/pkg/minikube/machine"
|
||||
pkgutil "k8s.io/minikube/pkg/util"
|
||||
)
|
||||
|
||||
// stopCmd represents the stop command
|
||||
|
|
@ -41,7 +43,10 @@ itself, leaving all files intact. The cluster can be started again with the "sta
|
|||
}
|
||||
defer api.Close()
|
||||
|
||||
if err = cluster.StopHost(api); err != nil {
|
||||
stop := func() (err error) {
|
||||
return cluster.StopHost(api)
|
||||
}
|
||||
if err := pkgutil.RetryAfter(5, stop, 1*time.Second); err != nil {
|
||||
fmt.Println("Error stopping machine: ", err)
|
||||
cmdUtil.MaybeReportErrorAndExit(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,14 +105,14 @@ func StartHost(api libmachine.API, config cfg.MachineConfig) (*host.Host, error)
|
|||
func StopHost(api libmachine.API) error {
|
||||
host, err := api.Load(cfg.GetMachineName())
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "Error loading host: %s", cfg.GetMachineName())
|
||||
return errors.Wrapf(err, "Load: %s", cfg.GetMachineName())
|
||||
}
|
||||
if err := host.Stop(); err != nil {
|
||||
alreadyInStateError, ok := err.(mcnerror.ErrHostAlreadyInState)
|
||||
if ok && alreadyInStateError.State == state.Stopped {
|
||||
return nil
|
||||
}
|
||||
return errors.Wrapf(err, "Error stopping host: %s", cfg.GetMachineName())
|
||||
return &util.RetriableError{Err: errors.Wrapf(err, "Stop: %s", cfg.GetMachineName())}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -121,7 +121,7 @@ func StopHost(api libmachine.API) error {
|
|||
func DeleteHost(api libmachine.API) error {
|
||||
host, err := api.Load(cfg.GetMachineName())
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "Error deleting host: %s", cfg.GetMachineName())
|
||||
return errors.Wrapf(err, "Load: %s", cfg.GetMachineName())
|
||||
}
|
||||
m := util.MultiError{}
|
||||
m.Collect(host.Driver.Remove())
|
||||
|
|
|
|||
Loading…
Reference in New Issue