Aggregate availability_zone access throws NotImplementedError when metadata is null

Bug #1532078 reported by Ryan Rossiter
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Invalid
Undecided
Ryan Rossiter

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

Ryan Rossiter (rlrossit)
Changed in nova:
assignee: nobody → Ryan Rossiter (rlrossit)
Revision history for this message
Sylvain Bauza (sylvain-bauza) wrote :

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
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.