Skip to content

many: replace exec.CombinedOutput when output is parsed - #13223

Merged
pedronis merged 3 commits into
canonical:masterfrom
alfonsosanchezbeato:not-parse-stderr
Oct 5, 2023
Merged

many: replace exec.CombinedOutput when output is parsed#13223
pedronis merged 3 commits into
canonical:masterfrom
alfonsosanchezbeato:not-parse-stderr

Conversation

@alfonsosanchezbeato

Copy link
Copy Markdown
Contributor

Some invocations to external programs used exec.CombinedOutput, that
combines stdout and strerr into a single byte array. This can be an
issue if this output is parsed, as many programs print debug output or
warnings to stderr and that data is unexpected by the parsers. This
patch changes to using osutil.RunSplitOutput or osutil.RunCmd (that
return separately stdout and stderr) when we need to parse stdout, and
also in some other cases when printing separately both streams could
be helpful. Fixes LP #1885597.

@github-actions github-actions Bot added the Needs Documentation -auto- Label automatically added which indicates the change needs documentation label Sep 26, 2023
@alfonsosanchezbeato alfonsosanchezbeato added the Run nested The PR also runs tests inluded in nested suite label Sep 26, 2023

@miguelpires miguelpires left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, this seems very useful

Comment thread osutil/exec.go Outdated
Comment on lines 195 to 196

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// RunSplitOutput runs name command with arg arguments and returs
// stdout, stderr, and an error.
// RunSplitOutput runs name command with arg arguments and returns
// stdout, stderr and an error.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I've changed this

@Meulengracht Meulengracht left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for fixing this

@pedronis pedronis added this to the 2.61 milestone Oct 4, 2023
These functions return separately std{err,out}, and will be used to
replace calls to exec.CombinedOuput.
Some invocations to external programs used exec.CombinedOutput, that
combines stdout and strerr into a single byte array. This can be an
issue if this output is parsed, as many programs print debug output or
warnings to stderr and that data is unexpected by the parsers. This
patch changes to using osutil.RunSplitOutput or osutil.RunCmd (that
return separately stdout and stderr) when we need to parse stdout, and
also in some other cases when printing separately both streams could
be helpful. Fixes LP #1885597.
@pedronis
pedronis merged commit b4f263b into canonical:master Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Documentation -auto- Label automatically added which indicates the change needs documentation Run nested The PR also runs tests inluded in nested suite

4 participants