提交 f22a3633 编写于 作者: M Medya Gh

add shut down to stop

上级 892162d1
......@@ -31,6 +31,8 @@ const (
nodeRoleLabelKey = "role.minikube.sigs.k8s.io"
// CreatedByLabelKey is applied to any container/volume that is created by minikube created_by.minikube.sigs.k8s.io=true
CreatedByLabelKey = "created_by.minikube.sigs.k8s.io"
// ShutDownCmd is the command halt and stop the container
ShutDownCmd = "sudo init 0"
)
// CreateParams are parameters needed to create a container
......
......@@ -77,8 +77,8 @@ func DeleteHost(api libmachine.API, machineName string) error {
return mcnerror.ErrHostDoesNotExist{Name: machineName}
}
// Hyper-V requires special care to avoid ACPI and file locking issues
if host.Driver.DriverName() == driver.HyperV {
// some drivers need manual shut down before delete to avoid getting stuck.
if driver.NeedsShutdown(host.Driver.DriverName()) {
if err := StopHost(api, machineName); err != nil {
glog.Warningf("stop host: %v", err)
}
......
......@@ -25,6 +25,7 @@ import (
"github.com/docker/machine/libmachine/state"
"github.com/golang/glog"
"github.com/pkg/errors"
"k8s.io/minikube/pkg/drivers/kic/oci"
"k8s.io/minikube/pkg/minikube/driver"
"k8s.io/minikube/pkg/minikube/out"
"k8s.io/minikube/pkg/util/retry"
......@@ -78,8 +79,13 @@ func trySSHPowerOff(h *host.Host) error {
}
out.T(out.Shutdown, `Powering off "{{.profile_name}}" via SSH ...`, out.V{"profile_name": h.Name})
out, err := h.RunSSHCommand("sudo poweroff")
// poweroff always results in an error, since the host disconnects.
glog.Infof("poweroff result: out=%s, err=%v", out, err)
if driver.IsKIC(h.DriverName) {
out, err := h.RunSSHCommand(oci.ShutDownCmd)
glog.Infof("shutdown cmd %q result: out=%s, err=%v", oci.ShutDownCmd, out, err)
} else {
out, err := h.RunSSHCommand("sudo poweroff")
// poweroff always results in an error, since the host disconnects.
glog.Infof("poweroff result: out=%s, err=%v", out, err)
}
return nil
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册