Skip to content

Commit

Permalink
Merge pull request #106526 from harche/automated-cherry-pick-of-#1037…
Browse files Browse the repository at this point in the history
…80-upstream-release-1.22

Automated cherry pick of #103780: Ignore 'wait: no child processes' error when calling
  • Loading branch information
k8s-ci-robot committed Nov 23, 2021
2 parents 88e84ee + c2904eb commit 8fa0073
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions staging/src/k8s.io/mount-utils/mount_linux.go
Expand Up @@ -45,6 +45,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
Expand Down Expand Up @@ -181,6 +183,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}
}
klog.Errorf("Mount failed: %v\nMounting command: %s\nMounting arguments: %s\nOutput: %s\n", err, mountCmd, mountArgsLogStr, string(output))
return fmt.Errorf("mount failed: %v\nMounting command: %s\nMounting arguments: %s\nOutput: %s",
err, mountCmd, mountArgsLogStr, string(output))
Expand Down Expand Up @@ -284,6 +294,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
Expand Down

0 comments on commit 8fa0073

Please sign in to comment.