提交 7303ccf0 编写于 作者: M Medya Gh

lint

上级 54aa958f
...@@ -268,7 +268,7 @@ func (d *Driver) Kill() error { ...@@ -268,7 +268,7 @@ func (d *Driver) Kill() error {
// Remove will delete the Kic Node Container // Remove will delete the Kic Node Container
func (d *Driver) Remove() error { func (d *Driver) Remove() error {
if _, err := oci.ContainerID(d.OCIBinary, d.MachineName); err != nil { if _, err := oci.ContainerID(d.OCIBinary, d.MachineName); err != nil {
glog.Info("could not find the container %s to remove it. will try anyways", d.MachineName) glog.Infof("could not find the container %s to remove it. will try anyways", d.MachineName)
} }
if err := oci.DeleteContainer(d.NodeConfig.OCIBinary, d.MachineName); err != nil { if err := oci.DeleteContainer(d.NodeConfig.OCIBinary, d.MachineName); err != nil {
...@@ -277,7 +277,7 @@ func (d *Driver) Remove() error { ...@@ -277,7 +277,7 @@ func (d *Driver) Remove() error {
return err return err
} }
if strings.Contains(err.Error(), "No such container:") { if strings.Contains(err.Error(), "No such container:") {
glog.Info("no container name %q found to delete", d.MachineName) glog.Infof("no container name %q found to delete", d.MachineName)
return nil return nil
} }
......
...@@ -61,7 +61,7 @@ func DeleteContainersByLabel(ociBin string, label string) []error { ...@@ -61,7 +61,7 @@ func DeleteContainersByLabel(ociBin string, label string) []error {
continue continue
} }
if err := ShutDown(ociBin, c); err != nil { if err := ShutDown(ociBin, c); err != nil {
glog.Info("couldn't shut down %s (might be okay): %v ", c, err) glog.Infof("couldn't shut down %s (might be okay): %v ", c, err)
} }
cmd := exec.Command(ociBin, "rm", "-f", "-v", c) cmd := exec.Command(ociBin, "rm", "-f", "-v", c)
if out, err := cmd.CombinedOutput(); err != nil { if out, err := cmd.CombinedOutput(); err != nil {
...@@ -81,7 +81,7 @@ func DeleteContainer(ociBin string, name string) error { ...@@ -81,7 +81,7 @@ func DeleteContainer(ociBin string, name string) error {
} }
// try to delete anyways // try to delete anyways
if err := ShutDown(ociBin, name); err != nil { if err := ShutDown(ociBin, name); err != nil {
glog.Info("couldn't shut down %s (might be okay): %v ", name, err) glog.Infof("couldn't shut down %s (might be okay): %v ", name, err)
} }
cmd := exec.Command(ociBin, "rm", "-f", "-v", name) cmd := exec.Command(ociBin, "rm", "-f", "-v", name)
if out, err := cmd.CombinedOutput(); err != nil { if out, err := cmd.CombinedOutput(); err != nil {
...@@ -497,9 +497,26 @@ func ContainerStatus(ociBin string, name string) (string, error) { ...@@ -497,9 +497,26 @@ func ContainerStatus(ociBin string, name string) (string, error) {
// to ensure the containers process and networking bindings are all closed // 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 // to avoid containers getting stuck before delete https://github.com/kubernetes/minikube/issues/7657
func ShutDown(ociBin string, name string) error { func ShutDown(ociBin string, name string) error {
cmd := exec.Command(ociBin, "exec", "-it", name, "sudo init 0") cmd := exec.Command(ociBin, "exec", "--privileged", "-t", name, "sudo", "init", "0")
if out, err := cmd.CombinedOutput(); err != nil { if out, err := cmd.CombinedOutput(); err != nil {
return errors.Wrapf(err, "shutdown %s: output %q", name, out) return errors.Wrapf(err, "shutdown %s: output %q", name, out)
} }
// wait till it is stoped
stopped := func() error {
st, err := ContainerStatus(ociBin, name)
if st == "exited" {
return nil
}
if err != nil {
glog.Infof("temporary error verifying shutdown: %v", err)
}
glog.Infof("temporary error: container %s status is %s but expect it to be exited", name, st)
return errors.Wrap(err, "couldn't verify cointainer is exited. %v")
}
if err := retry.Expo(stopped, time.Millisecond*500, time.Second*20); err != nil {
return errors.Wrap(err, "verify shutdown")
}
glog.Infof("Successfully shutdown container %s", name)
return nil return nil
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册