looking for empty keypair produces error 500

Bug #530824 reported by truijllo on 2010-03-02
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Eucalyptus
Confirmed
Undecided
chris grzegorczyk

Bug Description

Asking for a empty keypair produces an unmanaged exception ( after a timeout ).

Here 3 examples with
- an existent key
- an inexistent one
- empty key

inexistent keys returns None/Null, empty throws exception and force to wait for the timeout

>>> ec2.get_key_pair('carlo')
KeyPair:carlo
>>> ec2.get_key_pair('pippo_inexistent_pippo')
>>> ec2.get_key_pair('')
Warning: failed to parse error message from AWS: :1:0: syntax error
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python2.5/site-packages/boto/ec2/connection.py", line 611, in get_key_pair
return self.get_all_key_pairs(keynames=[keyname])[0]
File "/usr/lib/python2.5/site-packages/boto/ec2/connection.py", line 598, in get_all_key_pairs
return self.get_list('DescribeKeyPairs', params, [('item', KeyPair)])
File "/usr/lib/python2.5/site-packages/boto/connection.py", line 553, in get_list
response = self.make_request(action, params, path, verb)
File "/usr/lib/python2.5/site-packages/boto/connection.py", line 540, in make_request
return self._mexe(verb, qs, request_body, headers)
File "/usr/lib/python2.5/site-packages/boto/connection.py", line 396, in _mexe
raise BotoServerError(response.status, response.reason, body)
boto.exception.BotoServerError: BotoServerError: 500 Internal Server Error
Failure: 500 Internal Server Error

truijllo (truijllo) wrote :

experienced on
Eucalyptus 1.6.2 (and previous ) on Centos 5.1

Neil Soman (neilsoman) wrote :

The issue here is that boto does not do input validation in some cases and in case the keypair is empty, it should not send a malformed request to the service. Something like,

--- boto-1.8d-orig/boto/ec2/connection.py 2009-06-24 18:28:54.000000000 -0700
+++ boto-1.8d/boto/ec2/connection.py 2010-03-02 13:50:51.000000000 -0800
@@ -597,7 +597,7 @@
             self.build_list_params(params, keynames, 'KeyName')
         return self.get_list('DescribeKeyPairs', params, [('item', KeyPair)])

- def get_key_pair(self, keyname):
+ def get_key_pair(self, keyname=None):
         """
         Convenience method to retrieve a specific keypair (KeyPair).

@@ -607,10 +607,11 @@
         @rtype: L{KeyPair<boto.ec2.keypair.KeyPair>}
         @return: The KeyPair specified or None if it is not found
         """
- try:
- return self.get_all_key_pairs(keynames=[keyname])[0]
- except IndexError: # None of those key pairs available
- return None
+ if keyname:
+ try:
+ return self.get_all_key_pairs(keynames=[keyname])[0]
+ except IndexError: # None of those key pairs available
+ return None

     def create_key_pair(self, key_name):
         """

However, Eucalyptus should not throw an "500 Internal Error" regardless, so this issue needs to be fixed on both ends.

Neil Soman (neilsoman) wrote :

^^ with the appropriate indentation of course.

Changed in eucalyptus:
status: New → Confirmed
Changed in eucalyptus:
assignee: nobody → chris grzegorczyk (chris-grze)
Andy Grimm (agrimm) wrote :

This issue is now being tracked upstream at http://eucalyptus.atlassian.net/browse/EUCA-2681

Please watch that issue for further updates.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers