Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capture stdout and stderr even if cmd.Run fails #34

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mproffitt
Copy link

Description of your changes

In its current form, if cmd.Run fails, then the function immediately exits with no reason given for the termination. This makes debugging scripts hard to understand as no indication is given for the failure, other than a failure occured.

By trapping the error returned from cmd.Run, we first process the buffers for both stdout and stderr and set these to the dxr.

Additionally we capture a truncated stderr from the command error which can help point to where the command failed, setting this as the Fatal error message returned as an event.

I have:

@mproffitt mproffitt marked this pull request as draft January 11, 2025 10:16
In its current form, if `cmd.Run` fails, then the function immediately
exits with no reason given for the termination. This makes debugging
scripts hard to understand as no indication is given for the failure,
other than a failure occured.

By trapping the error returned from `cmd.Run`, we first process the
buffers for both `stdout` and `stderr` and set these to the `dxr`.

Additionally we capture a truncated `stderr` from the command error
which can help point to where the command failed, setting this as the
Fatal error message returned as an event.

Signed-off-by: Martin Proffitt <[email protected]>
@mproffitt mproffitt force-pushed the rework-shell-execution branch from fb34de0 to 7c9454c Compare January 11, 2025 10:18
@mproffitt
Copy link
Author

Leaving in draft until this has been tested fully inside a cluster

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant