From 06a6ec21815cc9d765b32be3a6723619116f3c1d Mon Sep 17 00:00:00 2001 From: bruceauyeung Date: Wed, 9 Nov 2016 10:55:34 +0800 Subject: [PATCH] add failure check on umount when kubeadm reset, and on service stop Signed-off-by: bruceauyeung --- cmd/kubeadm/app/cmd/reset.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cmd/kubeadm/app/cmd/reset.go b/cmd/kubeadm/app/cmd/reset.go index a44afbefd9d..197ea246464 100644 --- a/cmd/kubeadm/app/cmd/reset.go +++ b/cmd/kubeadm/app/cmd/reset.go @@ -124,12 +124,17 @@ func (r *Reset) Run(out io.Writer) error { fmt.Printf("%v", err) } else { fmt.Printf("Stopping the %s service...\n", serviceToStop) - initSystem.ServiceStop(serviceToStop) + if err := initSystem.ServiceStop(serviceToStop); err != nil { + fmt.Printf("failed to stop the %s service", serviceToStop) + } } fmt.Printf("Unmounting directories in /var/lib/kubelet...\n") - // Don't check for errors here, since umount will return a non-zero exit code if there is no directories to umount - exec.Command("sh", "-c", "cat /proc/mounts | awk '{print $2}' | grep '/var/lib/kubelet' | xargs umount").Run() + umountDirsCmd := "cat /proc/mounts | awk '{print $2}' | grep '/var/lib/kubelet' | xargs -r umount" + umountOutputBytes, err := exec.Command("sh", "-c", umountDirsCmd).Output() + if err != nil { + fmt.Printf("failed to unmount directories in /var/lib/kubelet, %s", string(umountOutputBytes)) + } resetConfigDir("/etc/kubernetes/")