-
Couldn't load subscription status.
- Fork 2
Add log passthrough for lock-exec #26
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
Conversation
7a104a0 to
a1b859e
Compare
|
👀 just curious what you'll expect to happen with cron logs when this goes to prod. got any prediction? |
lock/run.go
Outdated
| cmd := exec.CommandContext(ctx, fields[0], fields[1:]...) //nolint:gosec | ||
|
|
||
| // Write to std outputs + combined buffer | ||
| var outbuf bytes.Buffer | ||
| cmd.Stdout = io.MultiWriter(os.Stdout, &outbuf) | ||
| cmd.Stderr = io.MultiWriter(os.Stderr, &outbuf) | ||
|
|
||
| cmderr := cmd.Run() | ||
| cmdout := outbuf.Bytes() | ||
|
|
||
| return strings.TrimSpace(string(cmdout)), cmderr |
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.
Just confirming I think this means that we're going to write output directly to stdout and return it in this function where it will be logged again by the lock-exec CLI?
I think that might be fine... What do you think about creating a new function like RunDirectOutput (not sure of a good name) that has your change here and then does not return the output. So instead of returning the output it just sends it directly to stdout and then returns only the command exit code.
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 didn't want to change this function's interface so I set it up to do both.
This line logs it and adds the output as metadata to the log sent to dd. I was worried someone might have alerts or other things connected to that field.
I'm down to pick one or the other and drop that metadata if we think it's redundant though. Which would you prefer?
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 could also update that log to avoid the double-print
|
@ejeun this should get us to a place where calling Haven't confirmed if these logs will make it to DD correctly but I was going to check it on staging/prod. I didn't see any special connections set up in |
a1b859e to
86b7a57
Compare
Creates multiwriter with a single buffer (combined output) and std IO file descriptors
86b7a57 to
2abd386
Compare
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.
Yay! Thank you!
|
I will merge this and tag a new version |
Writes command output directly to std IO and no longer returns a buffer.
https://www.loom.com/share/fc29e6dce02e43059e495169468caf0e