← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1564551] Re: initialize_connection failure can result in 'exceptions.TypeError' object has no attribute 'code'

 

What version of nova is this? Mitaka? It probably doesn't really matter,
the issue is here as you pointed out:

except Exception as exc:
                    LOG.error(_LE('Connection between volume %(vol)s and host '
                                  '%(host)s might have succeeded, but attempt '
                                  'to terminate connection has failed. '
                                  'Validate the connection and determine if '
                                  'manual cleanup is needed. Error: %(msg)s '
                                  'Code: %(code)s.'),
                              {'vol': volume_id,
                               'host': connector.get('host'),
                               'msg': six.text_type(exc),
                               'code': exc.code}) <---------- blows up

exc in this case is a TypeError, which doesn't have a code on it. That
code is probably expecting a CinderClientException or NovaException, but
something else breaks and we get a TypeError instead.

** Tags added: volumes

** Changed in: nova
       Status: New => Triaged

** Changed in: nova
   Importance: Undecided => Medium

** Also affects: nova/liberty
   Importance: Undecided
       Status: New

** Also affects: nova/mitaka
   Importance: Undecided
       Status: New

** Tags added: low-hanging-fruit

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1564551

Title:
  initialize_connection failure can result in 'exceptions.TypeError'
  object has no attribute 'code'

Status in OpenStack Compute (nova):
  Triaged
Status in OpenStack Compute (nova) liberty series:
  New
Status in OpenStack Compute (nova) mitaka series:
  New

Bug description:
  Doing an initialize_connection() results in the following partial code
  stack:

  2016-03-29 06:51:06.882 25713 ERROR nova.compute.manager [instance: 4c8d25b3-b136-4c72-a381-4b80dcca5c49]   File "/usr/lib/python2.7/dist-packages/nova/volume/cinder.py", line 232, in wrapper
  2016-03-29 06:51:06.882 25713 ERROR nova.compute.manager [instance: 4c8d25b3-b136-4c72-a381-4b80dcca5c49]     res = method(self, ctx, *args, **kwargs)
  2016-03-29 06:51:06.882 25713 ERROR nova.compute.manager [instance: 4c8d25b3-b136-4c72-a381-4b80dcca5c49]   File "/usr/lib/python2.7/dist-packages/nova/volume/cinder.py", line 259, in wrapper
  2016-03-29 06:51:06.882 25713 ERROR nova.compute.manager [instance: 4c8d25b3-b136-4c72-a381-4b80dcca5c49]     res = method(self, ctx, volume_id, *args, **kwargs)
  2016-03-29 06:51:06.882 25713 ERROR nova.compute.manager [instance: 4c8d25b3-b136-4c72-a381-4b80dcca5c49]   File "/usr/lib/python2.7/dist-packages/nova/volume/cinder.py", line 437, in initialize_connection
  2016-03-29 06:51:06.882 25713 ERROR nova.compute.manager [instance: 4c8d25b3-b136-4c72-a381-4b80dcca5c49]     'code': exc.code})
  2016-03-29 06:51:06.882 25713 ERROR nova.compute.manager [instance: 4c8d25b3-b136-4c72-a381-4b80dcca5c49] AttributeError: 'exceptions.TypeError' object has no attribute 'code'

  
  Here is the method:

      @translate_volume_exception
      def initialize_connection(self, context, volume_id, connector):
          try:
              connection_info = cinderclient(
                  context).volumes.initialize_connection(volume_id, connector)
              connection_info['connector'] = connector
              return connection_info
          except cinder_exception.ClientException as ex:
              with excutils.save_and_reraise_exception():
                  LOG.error(_LE('Initialize connection failed for volume '
                                '%(vol)s on host %(host)s. Error: %(msg)s '
                                'Code: %(code)s. Attempting to terminate '
                                'connection.'),
                            {'vol': volume_id,
                             'host': connector.get('host'),
                             'msg': six.text_type(ex),
                             'code': ex.code})
                  try:
                      self.terminate_connection(context, volume_id, connector)
                  except Exception as exc:
                      LOG.error(_LE('Connection between volume %(vol)s and host '
                                    '%(host)s might have succeeded, but attempt '
                                    'to terminate connection has failed. '
                                    'Validate the connection and determine if '
                                    'manual cleanup is needed. Error: %(msg)s '
                                    'Code: %(code)s.'),
                                {'vol': volume_id,
                                 'host': connector.get('host'),
                                 'msg': six.text_type(exc),
                                 'code': exc.code})               <---------- blows up

      @translate_volume_exception
      def terminate_connection(self, context, volume_id, connector):
          return cinderclient(context).volumes.terminate_connection(volume_id,
                                                                    connector)

  Presumably the issue has to do with the @translate_volume_exception
  decorator on terminate_connection()....so when that fails, the
  exception that is re-raised is not constructed with a 'code' value (?)

To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1564551/+subscriptions


References