From e66de6bfbb49e8204047ae8a3dd68a2490cd4b04 Mon Sep 17 00:00:00 2001 From: Matthew Wong Date: Tue, 19 Oct 2021 16:09:59 -0700 Subject: [PATCH] Ignore 'wait: no child processes' error when calling mount/umount (cherry-pick of https://github.com/kubernetes/kubernetes/pull/103780) --- .../kubernetes/pkg/util/mount/mount_linux.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/vendor/k8s.io/kubernetes/pkg/util/mount/mount_linux.go b/vendor/k8s.io/kubernetes/pkg/util/mount/mount_linux.go index dfd52bfe1..fc2b16e60 100644 --- a/vendor/k8s.io/kubernetes/pkg/util/mount/mount_linux.go +++ b/vendor/k8s.io/kubernetes/pkg/util/mount/mount_linux.go @@ -44,6 +44,8 @@ const ( fsckErrorsCorrected = 1 // 'fsck' found errors but exited without correcting them fsckErrorsUncorrected = 4 + // Error thrown by exec cmd.Run() when process spawned by cmd.Start() completes before cmd.Wait() is called (see - k/k issue #103753) + errNoChildProcesses = "wait: no child processes" ) // Mounter provides the default implementation of mount.Interface @@ -136,6 +138,14 @@ func (mounter *Mounter) doMount(mounterPath string, mountCmd string, source stri command := exec.Command(mountCmd, mountArgs...) output, err := command.CombinedOutput() if err != nil { + if err.Error() == errNoChildProcesses { + if command.ProcessState.Success() { + // We don't consider errNoChildProcesses an error if the process itself succeeded (see - k/k issue #103753). + return nil + } + // Rewrite err with the actual exit error of the process. + err = &exec.ExitError{ProcessState: command.ProcessState} + } args := strings.Join(mountArgs, " ") klog.Errorf("Mount failed: %v\nMounting command: %s\nMounting arguments: %s\nOutput: %s\n", err, mountCmd, args, string(output)) return fmt.Errorf("mount failed: %v\nMounting command: %s\nMounting arguments: %s\nOutput: %s", @@ -203,6 +213,14 @@ func (mounter *Mounter) Unmount(target string) error { command := exec.Command("umount", target) output, err := command.CombinedOutput() if err != nil { + if err.Error() == errNoChildProcesses { + if command.ProcessState.Success() { + // We don't consider errNoChildProcesses an error if the process itself succeeded (see - k/k issue #103753). + return nil + } + // Rewrite err with the actual exit error of the process. + err = &exec.ExitError{ProcessState: command.ProcessState} + } return fmt.Errorf("unmount failed: %v\nUnmounting arguments: %s\nOutput: %s", err, target, string(output)) } return nil