|
Josh Cooper Thank you for triaging this, however, I need to be clear: This is not about errors that directly result from the execution. To properly recreate the scenario I'm describing here, consider the following:
$value = generate('/path/to/something.sh')
|
Assume that the shell script is a bash script, and runs multiple additional external commands (not via bash's exec).
Now, assume that the puppetmaster on which this is evaluated is under extraordinary circumstances, and is rapidly approaching, eg, the nproc system limit on a Linux box (in the extreme case, assume we are at nproc-1). The following occurs:
-
generate calls the linked helper function, which launches the shell script's bash with stdout and stderr combined. The launched process itself is now running, and has not completed (and therefore not returned a failing error code)
-
bash attempts to launch an extra process (which would then be a child of this process, and inherit the stdout and stderr of its parent). This fails once we have reached nproc processes
-
The failure causes the bash process to emit something along the lines of Error: cannot fork to its stderr (which is combined with its stdout)
-
The bash process itself may continue to run, erroring all along the way, before eventually terminating (possibly with an acceptable return code, depending on the options set in the shell, and the code paths encountered)
-
If the shell script does exit with an acceptable return code, the output will contain the stderr emissions from the parent bash process
I realize that this is relatively difficult to synthesize a test for. My advice would be to set a very low nproc limit (the bare minimum needed to sustain the puppet run + a bit of overhead) and then write a shell script which launches enough processes (a call to a non-builtin sleep would probably be useful here) in the background to consume the overhead and cause the bash process to encounter failures. By making the last command in the script exit 0 or true I believe we can recreate the proper return code.
|