Issue Details (XML | Word | Printable)

Key: CHEF-1336
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Blocker Blocker
Assignee: Daniel DeLeo
Reporter: Daniel DeLeo
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Chef

Chef::REST should paper over a bug in net/http

Created: 15/Jun/10 08:08 PM   Updated: 15/Jun/10 09:38 PM   Resolved: 15/Jun/10 09:35 PM
Component/s: Chef Client
Affects Version/s: 0.9.0
Fix Version/s: 0.9.0

Triage Status: Triaged


 Description  « Hide

net/http for some widely deployed versions of ruby has a bug where a connection refused situation causes it to call #closed? on nil, which does not define that method. The result is the end user gets NoMethodError on nil, when they should get Errno::ECONNREFUSED. Chef::Rest should paper over this bug.



Sort Order: Ascending order - Click to sort in descending order
Daniel DeLeo added a comment - 15/Jun/10 09:35 PM

Fixed. In the case that Chef::REST is trying to contact a server that is down or doesn't exist, the debug output is like this:

DEBUG: Sending HTTP Request via GET to 127.127.127.123:4000/clients
DEBUG: rescued error in http connect, re-raising as Errno::ECONNREFUSED to hide bug in net/http
DEBUG: NoMethodError: undefined method `closed?' for nil:NilClass
DEBUG: /Users/ddeleo/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/net/http.rb:1060:in `__request__'
/Users/ddeleo/.rvm/gems/ruby-1.8.7-p249/gems/rest-client-1.5.1/lib/restclient/net_http_ext.rb:17:in `request'
/Users/ddeleo/opscode/chef/chef/lib/chef/rest/rest_request.rb:58:in `call'
/Users/ddeleo/opscode/chef/chef/lib/chef/rest.rb:198:in `api_request'
/Users/ddeleo/opscode/chef/chef/lib/chef/rest.rb:267:in `retriable_rest_request'
/Users/ddeleo/opscode/chef/chef/lib/chef/rest.rb:197:in `api_request'
/Users/ddeleo/opscode/chef/chef/lib/chef/rest.rb:100:in `get_rest'
/Users/ddeleo/opscode/chef/chef/lib/chef/api_client.rb:184:in `list'
/Users/ddeleo/opscode/chef/chef/lib/chef/knife/client_list.rb:35:in `run'
/Users/ddeleo/opscode/chef/chef/lib/chef/application/knife.rb:115:in `run'
chef/bin/knife:25
ERROR: Connection refused connecting to 127.127.127.123:4000 for /clients, retry 1/5

So, the "correct" Errno::ECONNREFUSED is raised, but the original error is disclosed via debug.


Daniel DeLeo added a comment - 15/Jun/10 09:38 PM

This is merged/pushed.