-
Notifications
You must be signed in to change notification settings - Fork 59
Don't fail on err in exec #259
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
Don't fail on err in exec #259
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you have time to work on this, I've provided some notes that should help you make progress. If you don't have time, LMK and I'll finish it up.
otelcli/exec.go
Outdated
@@ -94,7 +95,10 @@ func doExec(cmd *cobra.Command, args []string) { | |||
} | |||
|
|||
if err := child.Run(); err != nil { | |||
config.SoftFail("command failed: %s", err) | |||
span.Status = & tracev1.Status { | |||
Message: fmt.Sprintln("exec command failed: ", err), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd just do fmt.Sprintf here, message doesn't need the newline.
data_for_test.go
Outdated
// Config: otelcli.DefaultConfig().WithEndpoint("grpc://{{endpoint}}"), | ||
// }, | ||
// }, | ||
// }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm this test looks right.
Try adding "--fail", "--verbose"
to the CliArgs. It looks like config.SoftFail
is being called when child.Run() returns an err.
If the command starts but does not complete successfully, the error is of type *ExitError. Other error types may be returned for other situations.
so the if err :- child.Run(); err != nil
needs to be expanded to check for ExitError and not SoftFail on that so you can send the error upstream in the span status.
Unfortunately, I don't have further cycles to put towards this. Thanks for the review and the time/effort you've spent on this tool! |
Thanks for the PR! Work is busy right now so it might take me a couple weeks but I'll get this in and release. |
Added ExitCode to the results struct so it's easier to test against. I'm trying to remove Diagnostics eventually so it should move anyways. Reworked some failure catching to be more robust for exec. Tests pass :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for getting this started!
It turned out the test code that examines exit status needed some rework to test this, so I added that to your PR.
Fixes #258
I'm having a hard time writing a test for this. I have verified that this change makes the code do what I want - spans show up in Honeycomb and
otel-cli exec false
has a non-0 exit code.However, the test does not appear to work? Locally it tells me that no spans were recorded.