← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1532078] Re: Aggregate availability_zone access throws NotImplementedError when metadata is null

 

We assume by design that the AZ information is only a specific key/value
pair of the metadata dict (where the key is 'availability_zone').

Trying to access the AZ info if the metadata field is unset goes against
that design decision because it makes no sense to persist it differently
at the object layer. Having a level of indirection for accessing it
doesn't mean we should have a defensive approach for accessing that
information.

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

-- 
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/1532078

Title:
  Aggregate availability_zone access throws NotImplementedError when
  metadata is null

Status in OpenStack Compute (nova):
  Invalid

Bug description:
  The Aggregate object has an availability_zone property that, when
  accessed, gets the availability zone as a key/value stored in the
  metadata field. The problem is, the metadata field is nullable, so if
  an Aggregate object is created with no metadata, calling the
  availability_zone property will explode because it is trying to get
  the 'availability_zone' key on the metadata field.

  Here is a simple test that fails to show the problem (put in
  nova/tests/unit/objects/test_aggregate.py):

  def test_get_availability_zone_with_null_metadata(self):
          agg = aggregate.Aggregate()
          self.assertIsNone(agg.availability_zone)

  Here's the result of the test:

  nova.tests.unit.objects.test_aggregate.TestAggregateObject.test_get_availability_zone_with_null_metadata
  --------------------------------------------------------------------------------------------------------

  Captured traceback:
  ~~~~~~~~~~~~~~~~~~~
      Traceback (most recent call last):
        File "nova/tests/unit/objects/test_aggregate.py", line 192, in test_get_availability_zone_with_null_metadata
          self.assertIsNone(agg.availability_zone)
        File "nova/objects/aggregate.py", line 151, in availability_zone
          return self.metadata.get('availability_zone', None)
        File "/opt/stack/nova/.tox/py27/local/lib/python2.7/site-packages/oslo_versionedobjects/base.py", line 67, in getter
          self.obj_load_attr(name)
        File "/opt/stack/nova/.tox/py27/local/lib/python2.7/site-packages/oslo_versionedobjects/base.py", line 578, in obj_load_attr
          _("Cannot load '%s' in the base class") % attrname)
      NotImplementedError: Cannot load 'metadata' in the base class

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


References