-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Improved WinRM error handling (including better ready?
and wait_for_ready
)
#4943
Conversation
…e differing default values
Conflicts: test/unit/plugins/communicators/winrm/shell_test.rb
@@ -28,7 +28,7 @@ Gem::Specification.new do |s| | |||
s.add_dependency "rb-kqueue", "~> 0.2.0" | |||
s.add_dependency "rest-client", ">= 1.6.0", "< 2.0" | |||
s.add_dependency "wdm", "~> 0.1.0" | |||
s.add_dependency "winrm", "~> 1.1.3" | |||
s.add_dependency "winrm", "= 1.3.0.dev.2" |
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 scares me. Is there a released version we can depend on?
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.
There is now. @sneal released WInRM 1.3 today. I've updated the gemspec on here and I'm updating my other open PRs related to WinRM.
Note that I've got a few open PRs related to WinRM. I tried to split it to make it a little easier to review...
This looks really really good, modulo the dependency on a dev version of winrm. |
Agreed with @sethvargo. |
@mitchellh / @sethvargo / @sneal What about the first note?
I'm not sure if I:
|
@maxlinc I don't think that's unreasonable for WinRM to be honest... |
@maxlinc Vagrant handles Ctrl-C pretty well, so I think the best logic is to make the wait_for_retry smarter like browser do with page loads: After X minutes, say "WinRM is taking awhile to come online. Sometimes Windows takes this long to boot, but if you were expecting it to boot faster, this can be indicative of a problem. Press Ctrl-C to cancel." |
case exception.status_code | ||
# If the error is a 401, we can return a more specific error message | ||
when 401 | ||
raise Errors::AuthenticationFailed, |
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 shouldn't be needed with WinRM 1.3, it should always raise a WinRMAuthorizationError
Testing this out, looks really good so far. |
@maxlinc Can you fix the merge conflict? This is tested and ready to be merged. Thanks for your efforts here, the error output is much better. In the future we should make it fail fast if we get an auth error instead of retrying for a couple of minutes. At least now you see an auth error in stdout instead of Vagrant appearing to be frozen. |
…r_handling Conflicts: plugins/communicators/winrm/config.rb plugins/communicators/winrm/shell.rb test/unit/plugins/communicators/winrm/shell_test.rb
@sneal merged. |
Improved WinRM error handling (including better `ready?` and `wait_for_ready`)
We gained a ton of improvemnts to WinRM error handling in #4943, but we also got one bug. The new code raises an exception when `winrm_info` does not return right away. This was preventing us from catching the retry/timout logic that's meant to wait until boot_timeout for the WinRM communicator to be ready. This restores the proper behavior by rescuing the WinRMNotReady exception and continuing to retry until the surrounding timeout fires.
I split this from #4236 to make things easier to review. That PR contains just changes for SSL. This PR builds on that PR so the diff currently shows SSL support, but it'll shrink once that PR is merged and I rebase.
A few notes:
max_times
, which was set to 20, with a 10 second sleep. That means WinRM will retry authentication for 10 minutes attempt authentication!Errno
.Vagrant::Errors::Communicator::ConnectionRefused
instead ofVagrant::Errors::SSHConnectionRefused
andVagrantPlugins::CommunicatorWinRM::Errors::ConnectionRefused
), but I'd rather focus on WinRM and save refactoring for a separate PR.