-
Notifications
You must be signed in to change notification settings - Fork 683
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
Host resource ping method should return stdout #1927
Host resource ping method should return stdout #1927
Conversation
Signed-off-by: Justin Moy <justin.moy@sendgrid.com>
db437da
to
07d6f60
Compare
@justincmoy I'm 👎 on this as-written because the STDERR from netcat is actually quite useful in troubleshooting, and the STDOUT isn't nearly as useful, especially since many far-end targets will not respond with any data when you send an empty message. Can you explain the reason for this proposed change? |
@adamleff Sure thing. We have an haproxy agent-check that connects to an xinetd daemon, similar to this blog post: https://icicimov.github.io/blog/server/HAProxy-dynamically-adjust-server-weight-using-external-agent/ We would like to write an inspec test that verifies connecting to our specified xinetd port returns expected output. Edit: |
Thanks for sharing your use case. It makes the case for exposing both sets of content. I'd like to avoid using What if we call the |
👍 I'll update this PR accordingly |
Signed-off-by: Justin Moy <justin.moy@sendgrid.com>
29951f8
to
f13a04c
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.
@justincmoy this looks great, thank you. :)
lib/resources/host.rb
Outdated
@@ -156,7 +160,8 @@ def ping(hostname, port, protocol) | |||
|
|||
{ | |||
success: resp.exit_status.to_i.zero?, | |||
output: resp.stderr, | |||
connection_output: resp.stderr, |
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.
why not call it straight stdout
and stderr
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.
This came up in an earlier comment. It's to hide the implementation details from the end user.
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.
Got ya. Thank you, I misread this
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.
As stated in #1927 (comment). Netcat's stdout
and stderr
is what we're using now, but if we iterate on this in the future and find a tool that doesn't use stdout
/stderr
the same way, then we're training the user on a specific implementation.
There are two bits of data being exposed: output about the connection setup, and the output from the socket itself after the connection is established.
I proposed connection_output
and socket_output
accordingly, and I think the _output
piece is important so someone doesn't believe these can be manipulated -- it's simply the output of the connection attempt. I'm totally fine with removing _output
if it helps calm any concerns.
7d09062
to
aa09a93
Compare
@justincmoy after an internal discussion, would you mind changing the method names and the hash keys to remove the
|
Signed-off-by: Justin Moy <justin.moy@sendgrid.com>
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.
Thank you @justincmoy and @adamleff
Prior to this PR, the ping method would return the following for nc (stderr output):
After this PR, the ping method would return the following for nc (stdout output):