From 5d39878baaf04ff983268727f71dcf8f8bfe267d Mon Sep 17 00:00:00 2001 From: XrXr Date: Sun, 18 Jun 2017 22:05:09 -0400 Subject: [PATCH] Don't treat stopping stopped hosts as error Running `minikube stop` while nothing is running results in a crash. This patch makes `cluster.StopHost()` swallow the stop-while-stopped error libmachine returns. --- pkg/minikube/cluster/cluster.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/minikube/cluster/cluster.go b/pkg/minikube/cluster/cluster.go index 06a13cbc2f8a..18a2fd1b4b99 100644 --- a/pkg/minikube/cluster/cluster.go +++ b/pkg/minikube/cluster/cluster.go @@ -33,6 +33,7 @@ import ( "github.com/docker/machine/libmachine/drivers" "github.com/docker/machine/libmachine/engine" "github.com/docker/machine/libmachine/host" + "github.com/docker/machine/libmachine/mcnerror" "github.com/docker/machine/libmachine/state" "github.com/golang/glog" "github.com/pkg/errors" @@ -103,6 +104,10 @@ func StopHost(api libmachine.API) error { return errors.Wrapf(err, "Error loading host: %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 nil