Skip to content
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

Unable to destroy keypair #2586

Closed
bfosberry opened this issue Jan 20, 2014 · 17 comments · Fixed by #2591
Closed

Unable to destroy keypair #2586

bfosberry opened this issue Jan 20, 2014 · 17 comments · Fixed by #2591

Comments

@bfosberry
Copy link

I'm sure Im doing something wrong here, but everything is auto-generated so not sure what this is :P

 kp =fk.key_pairs.first
 =>   <Fog::Compute::RackspaceV2::KeyPair
    name="MYNAME",
    public_key="ssh-rsa BLAHBLAH BLAH Generated by Nova\n",
    private_key=nil,
    user_id=nil,
    fingerprint="0e:1f:80:20:73:7a:3d:27:24:2e:36:18:b4:fa:c5:6b"
  > 

1.9.3p385 :066 > kp.destroy
Fog::Compute::RackspaceV2::BadRequest: [HTTP 400 | ] Fog::Compute::RackspaceV2::BadRequest - 
    from /var/www/gamekick/shared/bundle/ruby/1.9.1/gems/excon-0.28.0/lib/excon/middlewares/expects.rb:10:in `response_call'
    from /var/www/gamekick/shared/bundle/ruby/1.9.1/gems/excon-0.28.0/lib/excon/middlewares/response_parser.rb:8:in `response_call'
    from /var/www/gamekick/shared/bundle/ruby/1.9.1/gems/excon-0.28.0/lib/excon/connection.rb:361:in `response'
    from /var/www/gamekick/shared/bundle/ruby/1.9.1/gems/excon-0.28.0/lib/excon/connection.rb:254:in `request'
    from /var/www/gamekick/shared/bundle/ruby/1.9.1/gems/fog-1.18.0/lib/fog/core/connection.rb:57:in `request'
    from /var/www/gamekick/shared/bundle/ruby/1.9.1/gems/fog-1.18.0/lib/fog/core/deprecated/connection.rb:20:in `request'
    from /var/www/gamekick/shared/bundle/ruby/1.9.1/gems/fog-1.18.0/lib/fog/rackspace/service.rb:43:in `request'
    from /var/www/gamekick/shared/bundle/ruby/1.9.1/gems/fog-1.18.0/lib/fog/rackspace/compute_v2.rb:152:in `request'
    from /var/www/gamekick/shared/bundle/ruby/1.9.1/gems/fog-1.18.0/lib/fog/rackspace/requests/compute_v2/delete_keypair.rb:18:in `delete_keypair'
    from /var/www/gamekick/shared/bundle/ruby/1.9.1/gems/fog-1.18.0/lib/fog/rackspace/models/compute_v2/key_pair.rb:49:in `destroy'
    from (irb):66
    from /var/www/gamekick/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands/console.rb:47:in `start'
    from /var/www/gamekick/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands/console.rb:8:in `start'
    from /var/www/gamekick/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'
@geemus
Copy link
Member

geemus commented Jan 20, 2014

@krames - could you take a look? Thanks!

@elight
Copy link

elight commented Jan 21, 2014

@bfosberry How did you create the key? I presume you did it through the key_pairs collection? Something like?

c = Fog::Compute.new(...)
c.key_pairs.create(:name => "MYNAME")

@elight
Copy link

elight commented Jan 21, 2014

@geemus Grateful that you ping @krames for Rackspace related issues. In the future, can you ping us both? We're both responsible for the Rackspace SDKs now. Thanks!

@bfosberry
Copy link
Author

Yep, exactly like that. I couldn't find any difference between keys that could be deleted and keys that could not

@elight
Copy link

elight commented Jan 21, 2014

So far, I've tried this with fog HEAD and with fog 1.18.0 without any problem. Granted, I'm on Ruby 2.0. I tried building the same version of Ruby that you're running but the build failed. :-/

@elight
Copy link

elight commented Jan 21, 2014

That said, judging by the 400, I suspect it's a server-side problem. I'll start asking questions here.

@elight
Copy link

elight commented Jan 21, 2014

@bfosberry I checked out delete_keypair.rb to look for anything obvious in fog. After all, a 400 could possibly be due to a malformed request. However, from inspection, I don't see how this is likely to be the case.

Is "MYNAME" indicative of the kind of name you've been giving your keys? The only thing that comes to mind is perhaps you're providing some character requiring escaping and excon isn't escaping it when generating the HTTP DELETE url.

I've reached out to our cloud server team too.

@bfosberry
Copy link
Author

The names I've been giving have upper and lowercase alphanumeric
characters, underscores and spaces. I could sanitize this down to remove
spaces :P. No special characters are included though.

On Tue, Jan 21, 2014 at 1:35 PM, Evan Light notifications@github.comwrote:

@bfosberry https://github.com/bfosberry I checked out delete_keypair.rbhttps://github.com/fog/fog/blob/master/lib/fog/rackspace/requests/compute_v2/delete_keypair.rbto look for anything obvious in fog. After all, a 400 could possibly be due
to a malformed request. However, from inspection, I don't see how this is
likely to be the case.

Is "MYNAME" indicative of the kind of name you've been giving your keys?
The only thing that comes to mind is perhaps you're providing some
character requiring escaping and excon isn't escaping it when generating
the HTTP DELETE url.

I've reached out to our cloud server team too.


Reply to this email directly or view it on GitHubhttps://github.com//issues/2586#issuecomment-32954430
.

@bfosberry
Copy link
Author

Btw Im using fog 1.18 and 1.9.3, I'll try using 2.0 when I get a sec

On Tue, Jan 21, 2014 at 2:30 PM, Brendan Fosberry <
brendan.fosberry@gmail.com> wrote:

The names I've been giving have upper and lowercase alphanumeric
characters, underscores and spaces. I could sanitize this down to remove
spaces :P. No special characters are included though.

On Tue, Jan 21, 2014 at 1:35 PM, Evan Light notifications@github.comwrote:

@bfosberry https://github.com/bfosberry I checked out delete_keypair.rbhttps://github.com/fog/fog/blob/master/lib/fog/rackspace/requests/compute_v2/delete_keypair.rbto look for anything obvious in fog. After all, a 400 could possibly be due
to a malformed request. However, from inspection, I don't see how this is
likely to be the case.

Is "MYNAME" indicative of the kind of name you've been giving your keys?
The only thing that comes to mind is perhaps you're providing some
character requiring escaping and excon isn't escaping it when generating
the HTTP DELETE url.

I've reached out to our cloud server team too.


Reply to this email directly or view it on GitHubhttps://github.com//issues/2586#issuecomment-32954430
.

@elight
Copy link

elight commented Jan 21, 2014

I don't suppose it's the key pairs with spaces in their names that are causing the 400s?

I just tried sending an HTTP request using excon, the HTTP library underlying fog, and it doesn't automatically URI encode the path. That could be the problem.

Begs the question whether fog-rackspace should be escaping them. As the parameter is a "name", it seems reasonable...

elight pushed a commit to elight/fog that referenced this issue Jan 21, 2014
Names can contain whitespaces but we weren't handling that case.
@elight
Copy link

elight commented Jan 21, 2014

@bfosberry Try sourcing your fog from here instead of from rubygems.

FYI, I created a keypair with a whitespace. That worked. Then I tried to delete it. 400. After this patch, no problem.

I suspect this will fix the problem you saw.

Sorry about the trouble!

@bfosberry
Copy link
Author

I'll give that a go, thanks! I plan on standardizing my naming regardless, but its good to be aware of this.

Will this patch let me delete the keypair, or prevent me from creating un-deletable keypairs?

thanks for the switch response!

@elight
Copy link

elight commented Jan 21, 2014

@bfosberry Key pairs with whitespaces will work now. They always should have. That is, we let users create key pairs with white spaces so we should be letting you delete them. Otherwise, shame on us. ;-)

@geemus
Copy link
Member

geemus commented Jan 21, 2014

@bfosberry thanks for the detailed report, should be fixed in the next release.

@bfosberry
Copy link
Author

As always, you guys are kickass
On Jan 21, 2014 3:47 PM, "Wesley Beary" notifications@github.com wrote:

@bfosberry https://github.com/bfosberry thanks for the detailed report,
should be fixed in the next release.


Reply to this email directly or view it on GitHubhttps://github.com//issues/2586#issuecomment-32967185
.

@elight
Copy link

elight commented Jan 21, 2014

@bfosberry Considering I've been fighting a head cold this week, that comment just made my day. 😊

@krames
Copy link
Member

krames commented Jan 22, 2014

Thanks @elight!

kzaitsev added a commit to kzaitsev/fog that referenced this issue Jan 23, 2014
* 'master' of github.com:fog/fog: (58 commits)
  make disassociate_address mock idempotent, by not requiring instance data
  Fixes fog#2586
  A hack to fix the Claim#messages= hack on 1.8.7.
  Replace the JSON round-trip with #stringify.
  Missed a chance to use queue.claim!.
  Include the oldest and newest message in stats.
  I guess there isn't really a better place.
  Don't use `&:to_h` style enumerations.
  Only extend the TTL of a MockMessage.
  Make the delete_message mock consistent.
  Yep, just did that.
  Er, actually enable queues_tests, too.
  Refactor PATH_BASE into a constant.
  Enable the queues_tests in mocking mode.
  Er, *actually* enable the messages_tests for mocks.
  Enable the queue_tests in mocking mode.
  Enable the messages_tests in mocking mode.
  Enable the message_tests in mocking mode.
  Enable the claims_tests in mocking mode.
  Enable model tests for Claims.
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants