From 7fd2eea9710ca96415ee7d08349ae981a262f44f Mon Sep 17 00:00:00 2001 From: John Griffith Date: Tue, 29 Jul 2014 07:37:07 -0600 Subject: [PATCH] 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 --- cinder/tests/test_db_api.py | 6 ++++-- cinder/volume/manager.py | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) 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)}) -- 2.45.2