提交 34fafc78 编写于 作者: M Medya Gh

fine tune

上级 29280cef
......@@ -282,6 +282,10 @@ func (d *Driver) Remove() error {
}
}
if id, err := oci.ContainerID(d.OCIBinary, d.MachineName); err == nil && id != "" {
return fmt.Errorf("expected no container ID be found for %q after delete. but got %q", d.MachineName, id)
}
return nil
}
......@@ -370,6 +374,11 @@ func (d *Driver) Stop() error {
return nil
}
// RunSSHCommandFromDriver implements direct ssh control to the driver
func (d *Driver) RunSSHCommandFromDriver() error {
return fmt.Errorf("driver does not support RunSSHCommandFromDriver commands")
}
// killAPIServerProc will kill an api server proc if it exists
// to ensure this never happens https://github.com/kubernetes/minikube/issues/7521
func killAPIServerProc(runner command.Runner) error {
......
......@@ -497,15 +497,17 @@ func ContainerStatus(ociBin string, name string) (string, error) {
// to ensure the containers process and networking bindings are all closed
// to avoid containers getting stuck before delete https://github.com/kubernetes/minikube/issues/7657
func ShutDown(ociBin string, name string) error {
cmd := exec.Command(ociBin, "exec", "--privileged", "-t", name, "sudo", "init", "0")
cmd := exec.Command(ociBin, "exec", "--privileged", "-t", name, "/bin/bash", "-c", "sudo init 0")
if out, err := cmd.CombinedOutput(); err != nil {
return errors.Wrapf(err, "shutdown %s: output %q", name, out)
glog.Infof("error shutdown %s output %q : %v", name, out, err)
}
// helps with allowing docker realize the container is exited and report its status correctly.
time.Sleep(time.Second * 1)
// wait till it is stoped
stopped := func() error {
st, err := ContainerStatus(ociBin, name)
if st == "exited" {
glog.Infof("container %s status is %s", name, st)
return nil
}
if err != nil {
......
......@@ -31,8 +31,6 @@ 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"
// ShutownCmd is the command halt and stop the container
ShutownCmd = "sudo init 0"
)
// CreateParams are parameters needed to create a container
......
......@@ -80,8 +80,8 @@ func trySSHPowerOff(h *host.Host) error {
out.T(out.Shutdown, `Powering off "{{.profile_name}}" via SSH ...`, out.V{"profile_name": h.Name})
if driver.IsKIC(h.DriverName) {
out, err := h.RunSSHCommand(oci.ShutownCmd)
glog.Infof("shutdown cmd %q result: out=%s, err=%v", oci.ShutownCmd, out, err)
err := oci.ShutDown(h.DriverName, h.Name)
glog.Infof("shutdown container: err=%v", err)
} else {
out, err := h.RunSSHCommand("sudo poweroff")
// poweroff always results in an error, since the host disconnects.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册