Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: knife-windows
-
Labels:None
-
Environment:Hide
chefserver:~/chef$ knife winrm os:windows interactive
Connected to 192.168.128.156, 192.168.129.126, 192.168.129.152, 192.168.129.148, 192.168.129.129, 192.168.128.124, 192.168.129.124, 192.168.128.123, 192.168.12
8.127, 192.168.129.125, 192.168.128.155, 192.168.129.153, 192.168.128.4, 192.168.129.46, 192.168.128.153, fe80::6891:8766:39f6:3364, 192.168.129.149, 192.168.1
29.122, 192.168.129.8, 192.168.129.156, 192.168.128.154, 192.168.129.128, 192.168.128.125, 192.168.129.4, 192.168.128.9, 192.168.129.155, 192.168.129.9, 192.16
8.129.127, 192.168.128.122, 192.168.129.10, 192.168.129.123, fe80::6cc5:35b3:2990:ab5b, 192.168.128.149, 192.168.128.128, 192.168.128.126, 192.168.128.152, 192
.168.128.129, 192.168.128.10, 192.168.129.154 and 192.168.128.148To run a command on a list of servers, do:
on SERVER1 SERVER2 SERVER3; COMMAND
Example: on latte foamy; echo foobarTo exit interactive mode, use 'quit!'
knife-winrm> hostname
ERROR: URI::InvalidURIError: the scheme http does not accept registry part: fe80::6891:8766:39f6:3364:5985 (or bad hostname?)
chefserver:~/chef$ devwinrm -m 192.168.128.148 hostname
ERROR: WinRM::WinRMHTTPTransportError: Bad HTTP response returned from server (500).Showchefserver:~/chef$ knife winrm os:windows interactive Connected to 192.168.128.156, 192.168.129.126, 192.168.129.152, 192.168.129.148, 192.168.129.129, 192.168.128.124, 192.168.129.124, 192.168.128.123, 192.168.12 8.127, 192.168.129.125, 192.168.128.155, 192.168.129.153, 192.168.128.4, 192.168.129.46, 192.168.128.153, fe80::6891:8766:39f6:3364, 192.168.129.149, 192.168.1 29.122, 192.168.129.8, 192.168.129.156, 192.168.128.154, 192.168.129.128, 192.168.128.125, 192.168.129.4, 192.168.128.9, 192.168.129.155, 192.168.129.9, 192.16 8.129.127, 192.168.128.122, 192.168.129.10, 192.168.129.123, fe80::6cc5:35b3:2990:ab5b, 192.168.128.149, 192.168.128.128, 192.168.128.126, 192.168.128.152, 192 .168.128.129, 192.168.128.10, 192.168.129.154 and 192.168.128.148 To run a command on a list of servers, do: on SERVER1 SERVER2 SERVER3; COMMAND Example: on latte foamy; echo foobar To exit interactive mode, use 'quit!' knife-winrm> hostname ERROR: URI::InvalidURIError: the scheme http does not accept registry part: fe80::6891:8766:39f6:3364:5985 (or bad hostname?) chefserver:~/chef$ devwinrm -m 192.168.128.148 hostname ERROR: WinRM::WinRMHTTPTransportError: Bad HTTP response returned from server (500).
Description
Two issues to highlight.
One is the exiting of knife if any winrm url is broken (ie a host has an ipv6 ip address, see OHAI-322), this makes 'knife os:windows "hostname"' fail.
The second one, which is what this ticket is open for, is if we have an error and we currently have open sessions via winrm to windows nodes, and we do not close them correctly, it leaves the winrm server in a bad state. And subsequent winrm http requests get returned an HTTP 500 server error response from windows. The only way I've found to put the server back into a useful state is to manually (via rdp or teh console, since knife-windows just screwed our ability to run commands via winrm) restart the Windows Remote Management service.
This is a critical bug that has been manifesting itself for a while, but I finally figured out what was going on.
I suspect that em-winrm isn't containing the errors cleanly inside session.relay_command.
You can usually get the winrm server into the same state by running a command that takes a while and hitting control-c. (like a winrm bootstrap)
All well and good that we have a bad hostname, but that shouldn't kill all the other connections that are in the middle of executing, sometimes leaving their remote windows service in a bad state.
chris@chefserver:~/chef$ prodwinrm os:windows interactive -V -V
DEBUG: Using configuration from /home/chris/chef/.chef/knife.rb
DEBUG: Signing the request as production-admin
DEBUG: Sending HTTP Request via GET to chefserver.local:4000/search/node
DEBUG: Adding 192.168.128.156
DEBUG: :session => :init
DEBUG: Adding 192.168.129.126
DEBUG: Adding 192.168.129.152
DEBUG: Adding 192.168.129.148
DEBUG: Adding 192.168.129.129
DEBUG: Adding 192.168.128.124
DEBUG: Adding 192.168.129.124
DEBUG: Adding 192.168.128.123
DEBUG: Adding 192.168.128.127
DEBUG: Adding 192.168.129.125
DEBUG: Adding 192.168.128.155
DEBUG: Adding 192.168.129.153
DEBUG: Adding 192.168.128.4
DEBUG: Adding 192.168.129.46
DEBUG: Adding 192.168.128.153
DEBUG: Adding fe80::6891:8766:39f6:3364
DEBUG: Adding 192.168.129.149
DEBUG: Adding 192.168.129.122
DEBUG: Adding 192.168.129.8
DEBUG: Adding 192.168.129.156
DEBUG: Adding 192.168.128.154
DEBUG: Adding 192.168.129.128
DEBUG: Adding 192.168.128.125
DEBUG: Adding 192.168.129.4
DEBUG: Adding 192.168.128.9
DEBUG: Adding 192.168.129.155
DEBUG: Adding 192.168.129.9
DEBUG: Adding 192.168.129.127
DEBUG: Adding 192.168.128.122
DEBUG: Adding 192.168.129.10
DEBUG: Adding 192.168.129.123
DEBUG: Adding fe80::6cc5:35b3:2990:ab5b
DEBUG: Adding 192.168.128.149
DEBUG: Adding 192.168.128.128
DEBUG: Adding 192.168.128.126
DEBUG: Adding 192.168.128.152
DEBUG: Adding 192.168.128.129
DEBUG: Adding 192.168.128.10
DEBUG: Adding 192.168.129.154
DEBUG: Adding 192.168.128.148
Connected to 192.168.128.156, 192.168.129.126, 192.168.129.152, 192.168.129.148, 192.168.129.129, 192.168.128.124, 192.168.129.124, 192.168.128.123, 192.168.12
8.127, 192.168.129.125, 192.168.128.155, 192.168.129.153, 192.168.128.4, 192.168.129.46, 192.168.128.153, fe80::6891:8766:39f6:3364, 192.168.129.149, 192.168.1
29.122, 192.168.129.8, 192.168.129.156, 192.168.128.154, 192.168.129.128, 192.168.128.125, 192.168.129.4, 192.168.128.9, 192.168.129.155, 192.168.129.9, 192.16
8.129.127, 192.168.128.122, 192.168.129.10, 192.168.129.123, fe80::6cc5:35b3:2990:ab5b, 192.168.128.149, 192.168.128.128, 192.168.128.126, 192.168.128.152, 192
.168.128.129, 192.168.128.10, 192.168.129.154 and 192.168.128.148
To run a command on a list of servers, do:
on SERVER1 SERVER2 SERVER3; COMMAND
Example: on latte foamy; echo foobar
To exit interactive mode, use 'quit!'
knife-winrm> hostname
DEBUG: :relay_to_servers => hostname
DEBUG: :relayed => 192.168.128.156
DEBUG: :relayed => 192.168.129.126
DEBUG: :relayed => 192.168.129.152
DEBUG: :relayed => 192.168.129.148
DEBUG: :relayed => 192.168.129.129
DEBUG: :relayed => 192.168.128.124
DEBUG: :relayed => 192.168.129.124
DEBUG: :relayed => 192.168.128.123
DEBUG: :relayed => 192.168.128.127
DEBUG: :relayed => 192.168.129.125
DEBUG: :relayed => 192.168.128.155
DEBUG: :relayed => 192.168.129.153
DEBUG: :relayed => 192.168.128.4
DEBUG: :relayed => 192.168.129.46
DEBUG: :relayed => 192.168.128.153
DEBUG: :relayed => fe80::6891:8766:39f6:3364
DEBUG: :relayed => 192.168.129.149
DEBUG: :relayed => 192.168.129.122
DEBUG: :relayed => 192.168.129.8
DEBUG: :relayed => 192.168.129.156
DEBUG: :relayed => 192.168.128.154
DEBUG: :relayed => 192.168.129.128
DEBUG: :relayed => 192.168.128.125
DEBUG: :relayed => 192.168.129.4
DEBUG: :relayed => 192.168.128.9
DEBUG: :relayed => 192.168.129.155
DEBUG: :relayed => 192.168.129.9
DEBUG: :relayed => 192.168.129.127
DEBUG: :relayed => 192.168.128.122
DEBUG: :relayed => 192.168.129.10
DEBUG: :relayed => 192.168.129.123
DEBUG: :relayed => fe80::6cc5:35b3:2990:ab5b
DEBUG: :relayed => 192.168.128.149
DEBUG: :relayed => 192.168.128.128
DEBUG: :relayed => 192.168.128.126
DEBUG: :relayed => 192.168.128.152
DEBUG: :relayed => 192.168.128.129
DEBUG: :relayed => 192.168.128.10
DEBUG: 192.168.129.122 => :run_command
DEBUG: :relayed => 192.168.128.148
DEBUG: 192.168.129.8 => :run_command
DEBUG: 192.168.129.126 => :run_command
DEBUG: 192.168.129.148 => :run_command
DEBUG: 192.168.129.129 => :run_command
DEBUG: 192.168.128.124 => :run_command
DEBUG: 192.168.129.124 => :run_command
DEBUG: 192.168.128.123 => :run_command
DEBUG: 192.168.128.127 => :run_command
DEBUG: 192.168.129.125 => :run_command
DEBUG: 192.168.128.155 => :run_command
DEBUG: 192.168.129.153 => :run_command
DEBUG: 192.168.128.4 => :run_command
DEBUG: 192.168.129.46 => :run_command
DEBUG: 192.168.129.152 => :run_command
DEBUG: fe80::6891:8766:39f6:3364 => :run_command
/usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/uri/generic.rb:199:in `initialize': the scheme http does not accept registry part: fe80::6891:8766:39f6:33
64:5985 (or bad hostname?) (URI::InvalidURIError)
from /usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/uri/http.rb:78:in `initialize'
from /usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/uri/common.rb:177:in `new'
from /usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/uri/common.rb:177:in `parse'
from /usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/uri/common.rb:628:in `parse'
from /home/chris/chef/.bundle/vendor/ruby/1.9.1/gems/winrm-1.0.5/lib/winrm/http/transport.rb:12:in `initialize'
from /home/chris/chef/.bundle/vendor/ruby/1.9.1/gems/winrm-1.0.5/lib/winrm/http/transport.rb:49:in `initialize'
from /home/chris/chef/.bundle/vendor/ruby/1.9.1/gems/winrm-1.0.5/lib/winrm/winrm_service.rb:29:in `new'
from /home/chris/chef/.bundle/vendor/ruby/1.9.1/gems/winrm-1.0.5/lib/winrm/winrm_service.rb:29:in `initialize'
from /home/chris/chef/.bundle/vendor/ruby/1.9.1/gems/em-winrm-0.5.2/lib/em-winrm/server.rb:79:in `new'
from /home/chris/chef/.bundle/vendor/ruby/1.9.1/gems/em-winrm-0.5.2/lib/em-winrm/server.rb:79:in `client'
from /home/chris/chef/.bundle/vendor/ruby/1.9.1/gems/em-winrm-0.5.2/lib/em-winrm/server.rb:48:in `block (2 levels) in run_command'
from /home/chris/chef/.bundle/vendor/ruby/1.9.1/gems/eventmachine-1.0.0.beta.3/lib/eventmachine.rb:1009:in `call'
from /home/chris/chef/.bundle/vendor/ruby/1.9.1/gems/eventmachine-1.0.0.beta.3/lib/eventmachine.rb:1009:in `block in spawn_threadpool'
chris@chefserver:~/chef$
Maybe we should wrap https://github.com/schisamo/em-winrm/blob/master/lib/em-winrm/server.rb#L48 in a rescue?