Closed maxlinc closed 10 years ago
The fix works for all the happy path scenarios, but it still blows up in a really nasty way if you have an image that isn't found. E.g. if you have a typo like rs.image = 'xUbuntu 14.04 LTS (Trusty Tahr) (PVHVM)'
you'll get this:
Bringing machine 'exact_name' up with 'rackspace' provider...
==> exact_name: Finding flavor for server...
==> exact_name: Finding image for server...
/opt/boxen/rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/excon-0.37.0/lib/excon/middlewares/expects.rb:6:in `response_call': [HTTP 400 | ] Expected([200, 203]) <=> Actual(400 Bad Request) (Fog::Compute::RackspaceV2::BadRequest)
response => #<Excon::Response:0x007fa6f4537288 @data={:body=>"", :headers=>{"Content-Length"=>"0", "Connection"=>"close", "Server"=>"Jetty(8.0.y.z-SNAPSHOT)"}, :status=>400, :remote_ip=>"198.101.165.140", :local_port=>52406, :local_address=>"10.3.20.36"}, @body="", @headers={"Content-Length"=>"0", "Connection"=>"close", "Server"=>"Jetty(8.0.y.z-SNAPSHOT)"}, @status=400, @remote_ip="198.101.165.140", @local_port=52406, @local_address="10.3.20.36"> -
from /opt/boxen/rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/excon-0.37.0/lib/excon/middlewares/response_parser.rb:26:in `response_call'
You seem to get a much nicer error if you escape the name:
item = collection.get URI.escape(name)
Bringing machine 'exact_name' up with 'rackspace' provider...
==> exact_name: Finding flavor for server...
==> exact_name: Finding image for server...
No matching image was found! Please check your image setting to
make sure you have a valid image chosen.
That's probably more monitoring friendly as well, because a spike in 400 Bad Request responses is usually more alarming than 404 Not Found.
You might just want to short-circuit it if it's not escaped, because I think you can only get by IDs and that IDs will never require escaping. So if name != URI.escape(name)
, then the parameter probably is probably a name, not an ID and you'll always get a 404 response.
P.s. I abbreviated that stacktrace. The user will see a long stacktrace, and won't see the more useful "No matching image was found!" message.
@maxlinc I figured the escape functionality should be in fog so I created this PR https://github.com/fog/fog/pull/3013.
Now, I could try to add some logic to detect the fog version and use escape if necessary. Do you think that's worth it?
Make sense to patch it in fog.
I think it's worth detecting the fog version and putting in a fallback, unless you want to bump the minimum fog version. In this case I'd lean towards broader compatibility w/ plugins that require older fogs, since it's just a one-liner.
Vagrant rackspace is supposed to be able to look up images as a regex, an exact string, or by ID.
So the vagrant file below should work (
vagrant up --provider rackspace
brings them up all, or specify a machine name to test one at a time), but the "exact_name" was broken by the recent changes in #101.The error is: