chef-boneyard / knife-rackspace

Chef knife plug-in for Rackspace
https://github.com/chef/knife-rackspace
Apache License 2.0
153 stars 114 forks source link

knife rackspace server create failing #132

Closed budgester closed 7 years ago

budgester commented 7 years ago
martinstev-ltm1:~ martin.stevens$ knife rackspace server create --image 6dc97231-c87a-4d34-bd5c-cf0b57743b2d -VV
INFO: Using configuration from /Users/martin.stevens/.chef/knife.rb
DEBUG: version  (config)
DEBUG: version v2 (cli)
DEBUG: rackspace_api_key ********* (config)
DEBUG: rackspace_api_key ********* (cli)
DEBUG: rackspace_username  (config)
DEBUG: rackspace_username  (cli)
DEBUG: rackspace_api_username ********* (config)
DEBUG: rackspace_api_username  (cli)
DEBUG: rackspace_auth_url  (config)
DEBUG: rackspace_auth_url  (cli)
DEBUG: rackspace_auth_url https://identity.api.rackspacecloud.com/v2.0 (using)
DEBUG: rackspace_region LON (config)
DEBUG: rackspace_region LON (cli)
DEBUG: rackspace v2
DEBUG: https_proxy <not specified> (config)
DEBUG: http_proxy <not specified> (config)
DEBUG: using proxy <none> (config)
DEBUG: ssl_verify_peer false (config)
DEBUG: version  (config)
DEBUG: version v2 (cli)
DEBUG: rackspace_api_key ********* (config)
DEBUG: rackspace_api_key ********* (cli)
DEBUG: rackspace_username  (config)
DEBUG: rackspace_username  (cli)
DEBUG: rackspace_api_username samtaylor (config)
DEBUG: rackspace_api_username  (cli)
DEBUG: rackspace_auth_url  (config)
DEBUG: rackspace_auth_url  (cli)
DEBUG: rackspace_auth_url https://identity.api.rackspacecloud.com/v2.0 (using)
DEBUG: rackspace_region LON (config)
DEBUG: rackspace_region LON (cli)
DEBUG: rackspace v2
/opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/fog-rackspace-0.1.2/lib/fog/rackspace.rb:108:in `escape': undefined method `gsub' for 2:Fixnum (NoMethodError)
    from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/fog-rackspace-0.1.2/lib/fog/rackspace/requests/compute_v2/get_flavor.rb:26:in `get_flavor'
    from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/fog-rackspace-0.1.2/lib/fog/rackspace/models/compute_v2/flavors.rb:31:in `get'
    from /Users/martin.stevens/.chefdk/gem/ruby/2.3.0/gems/knife-rackspace-1.0.1/lib/chef/knife/rackspace_server_create.rb:392:in `run'
    from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/knife.rb:443:in `block in run_with_pretty_exceptions'
    from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/local_mode.rb:44:in `with_server_connectivity'
    from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/knife.rb:442:in `run_with_pretty_exceptions'
    from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/knife.rb:219:in `run'
    from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application/knife.rb:156:in `run'
    from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/bin/knife:25:in `<top (required)>'
    from /usr/local/bin/knife:58:in `load'
    from /usr/local/bin/knife:58:in `<main>'
budgester commented 7 years ago

If I specify a flavour ID then I don't get this error.

martinb3 commented 7 years ago

I wonder if this is because of fog-rackspace-0.1.2. I'm not sure flavor is optional.

davidgiesberg commented 7 years ago

What would you expect to happen if you didn't specify flavor?

budgester commented 7 years ago

It should either give me a message saying "you have not specified a flavour" or chose a default flavour maybe. In a similar way that aws will choose a micro instance if nothing is specified.

So that if I run "knife rackspace server create" and I have my environment variables for the account for the account set up, I will get a box, it might not be the right one, but I can then overide it with switches.

At the very worst case it should print out the help options rather than fail with a ruby error, or the docs/README should specify that the flavour is a required rather than optional

budgester commented 7 years ago

Looking at the code rackspace_server_create.rb it already looks like a default flavour is set.

  option :flavor,
    :short => "-f FLAVOR",
    :long => "--flavor FLAVOR",
    :description => "The flavor of server; default is 2 (512 MB)",
    :proc => Proc.new { |f| Chef::Config[:knife][:flavor] = f.to_s },
    :default => 2
martinb3 commented 7 years ago

I think different flavors are going to be available in different regions and different accounts. We probably simply need to make the default "2" to fix the gsub error, though. That would at least return something more helpful if the API doesn't like the flavor (vs. a ruby error).

martinb3 commented 7 years ago

Hi there -- I've tweaked this to error in a better way. I'll be doing a release shortly. Thank you!