]> xenbits.xensource.com Git - osstest/openstack-nova.git/commitdiff
Avoid lazy-loading instance.id when cross_az_attach=False
authorMatt Riedemann <mriedem.os@gmail.com>
Fri, 26 May 2017 01:35:09 +0000 (21:35 -0400)
committerMatt Riedemann <mriedem.os@gmail.com>
Sat, 27 May 2017 13:40:13 +0000 (13:40 +0000)
The instance is no longer created in the API so the id attribute
won't be set, which means when checking the instance AZ against
the volume AZ, if they don't match we can't put the instance.id
in the error message. We shouldn't have been putting the instance
primary key in the error message anyway.

This fixes the bug by using the instance.uuid which is set in
this object in _provision_instances.

Change-Id: I396b767815b666706fec980ded482fa4746d2efc
Closes-Bug: #1693654
(cherry picked from commit 40cf447d28a5c9842f3546c4e7fe4efa682293cf)

nova/tests/unit/volume/test_cinder.py
nova/volume/cinder.py

index 7b325a3a60c4fa6656213f06398eaac8f1d7ffa7..c7d059aa545e3cce91a6cee449242b539f0b6987 100644 (file)
@@ -201,6 +201,9 @@ class CinderApiTestCase(test.NoDBTestCase):
                   'attach_status': 'detached',
                   'availability_zone': 'zone2'}
         instance = fake_instance_obj(self.ctx)
+        # Simulate _provision_instances in the compute API; the instance is not
+        # created in the API so the instance will not have an id attribute set.
+        delattr(instance, 'id')
 
         self.assertRaises(exception.InvalidVolume,
                           self.api.check_availability_zone,
index 91195efdb454753ff519730338e88f4bc81635be..bd99dacd28eaf03b68859d079edefb73782e4a05 100644 (file)
@@ -278,7 +278,7 @@ class API(object):
                 msg = _("Instance %(instance)s and volume %(vol)s are not in "
                         "the same availability_zone. Instance is in "
                         "%(ins_zone)s. Volume is in %(vol_zone)s") % {
-                            "instance": instance['id'],
+                            "instance": instance.uuid,
                             "vol": volume['id'],
                             'ins_zone': instance_az,
                             'vol_zone': volume['availability_zone']}