-
Notifications
You must be signed in to change notification settings - Fork 39
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
feat(jobreceiver): Implement the command package #1240
Conversation
Adds a new jobreceiver/command package that encapsulates the handling of executing commands. Mostly borrowed from sensu-go's robust commands package used by it's multi-platform agents. Signed-off-by: Christian Kruse <[email protected]>
ea23a21
to
7393266
Compare
Signed-off-by: Christian Kruse <[email protected]>
7393266
to
c407b49
Compare
Signed-off-by: Christian Kruse <[email protected]>
Signed-off-by: Christian Kruse <[email protected]>
d23dfe8
to
98c5bea
Compare
Signed-off-by: Christian Kruse <[email protected]>
Signed-off-by: Christian Kruse <[email protected]>
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.
It looks good to me but I suppose we should also wait for review from someone who has been on the OSC team a bit longer. I found a few doc nits.
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.
Looks good overall, had some questions about tests and the platform-specific bits.
Signed-off-by: Christian Kruse <[email protected]>
Implements
pkg/receiver/jobreceiver/command/command
I had a hard time with this one. I started by copying the work @portertech did in the PoC that had been adapted from sensu, but I ran into several issues.
First. The sensu command package had lots of opinionated behavior that I felt was not appropriate to copy over. Things like timeout behavior (hard coding exit code 2 and writing a blurb to stderr). More difficult to suss out was the bespoke timeout, process group and cleanup logic that all seemed geared towards the assumption of a shell environment (which is no longer obligated.)
Second. Our usage pattern here is different than Sensu's. Sensu's command interface buffers the entirety of command output before returning it to the caller. Here we need to stream that output to the pipeline to accommodate the log_entries output format. Handling this inner process communication is actually quite nuanced. Go's os/exec package takes a reasonable approach to handling this with exec.Cmd.Std[out|err]Pipe but it wasn't particularly compatible with sensu's command interface or the way it was doing timeouts.
In the end I decided to lean towards default behavior and accept that we may end up needing to re-learn some of lessons in the future.