From: John Griffith Date: Tue, 29 Jul 2014 13:37:07 +0000 (-0600) Subject: Update ref used for notifications X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=7fd2eea9710ca96415ee7d08349ae981a262f44f;p=openstack-build%2Fcinder-build.git Update ref used for notifications When we update a volume status in the db, we need to use the newly updated volume-ref object in the following notification method call. Otherwise we're sending a notification message with the old/outdated status information. Change-Id: I4d92b340cf5e20aaa885377dfb6bd6fc4ed87d69 Closes-Bug: #1349808 --- diff --git a/cinder/tests/test_db_api.py b/cinder/tests/test_db_api.py index 61a46c0f5..36e6c3391 100644 --- a/cinder/tests/test_db_api.py +++ b/cinder/tests/test_db_api.py @@ -658,10 +658,12 @@ class DBAPIVolumeTestCase(BaseTest): def test_volume_update(self): volume = db.volume_create(self.ctxt, {'host': 'h1'}) - db.volume_update(self.ctxt, volume['id'], - {'host': 'h2', 'metadata': {'m1': 'v1'}}) + ref_a = db.volume_update(self.ctxt, volume['id'], + {'host': 'h2', + 'metadata': {'m1': 'v1'}}) volume = db.volume_get(self.ctxt, volume['id']) self.assertEqual('h2', volume['host']) + self.assertEqual(dict(ref_a), dict(volume)) def test_volume_update_nonexistent(self): self.assertRaises(exception.VolumeNotFound, db.volume_update, diff --git a/cinder/volume/manager.py b/cinder/volume/manager.py index 1f4433dcf..9c00d9209 100644 --- a/cinder/volume/manager.py +++ b/cinder/volume/manager.py @@ -1192,9 +1192,12 @@ class VolumeManager(manager.SchedulerDependentManager): return QUOTAS.commit(context, reservations) - self.db.volume_update(context, volume['id'], {'size': int(new_size), - 'status': 'available'}) + volume = self.db.volume_update(context, + volume['id'], + {'size': int(new_size), + 'status': 'available'}) self.stats['allocated_capacity_gb'] += size_increase + self._notify_about_volume_usage( context, volume, "resize.end", extra_usage_info={'size': int(new_size)})