-
Notifications
You must be signed in to change notification settings - Fork 7
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
Allow timeout option for WinRM commands #27
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.
The rub here is definitely the testing- I don't have a slick WinRM setup to hand locally but if this passes your local manual tests LGTM 👍
Leaving as a comment since this is still a draft but LMK when you'd like an approved review
a6323fb
to
f2ff783
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.
Follows the same pattern as the SSH code with some finer error handling - looks good. I'm not able to test this myself so this is just a read-over. Looks like there are some unrelated linting issues but changes look solid.
f2ff783
to
3a4c86e
Compare
# If this command hits timeout, calling close with the command currently running causes | ||
# a RuntimeError error in WinRM's cleanup code. This specific error can be ignored. | ||
# The command will be terminated and further commands can be sent on the connection. | ||
raise e unless timeout && e.to_s == "opts[:shell_id] is required" |
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.
WinRb/WinRM#316 addresses this but is not yet released in a gem. Even once it is available, there's a chance there'll just be another exception we need to catch and dismiss.
3a4c86e
to
dcc8385
Compare
I've done more testing to confirm that exceptions don't happen when running commands without a timeout. This can potentially be replaced in future by using an elevated shell, which features command timeouts. Tracking that via inspec/inspec#1418 |
Allows end users (e.g. InSpec test coders) to specify a timeout for a potentially long running command. If the timeout is reached, the command is expected to be terminated on the host and an exception is raised (a subsequent change to InSpec will handle this exception). This complements recent changes to the base connection and ssh connection in train: inspec/train#625 Signed-off-by: James Stocks <[email protected]>
Signed-off-by: James Stocks <[email protected]>
dcc8385
to
8a057ec
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.
💯 Just looked over the files/changes again (including the new changes) and looks sound to me. ✅
Allows end users (e.g. InSpec test coders) to specify a timeout for a potentially long running command.
If the timeout is reached, the command is expected to be terminated on the host and an exception is raised (a subsequent change to InSpec will handle this exception).
This complements recent changes to the base connection and ssh connection in train: inspec/train#625
Tested with a variety of commands with and without the
timeout
option against Server 2019 and 2012R2 instances.Signed-off-by: James Stocks [email protected]
Related Issue
inspec/inspec#3772
Types of changes
Checklist: