]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Update ref used for notifications
authorJohn Griffith <john.griffith8@gmail.com>
Tue, 29 Jul 2014 13:37:07 +0000 (07:37 -0600)
committerJohn Griffith <john.griffith8@gmail.com>
Sat, 16 Aug 2014 01:43:47 +0000 (19:43 -0600)
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
cinder/volume/manager.py

index 61a46c0f539d0542215091251ce68b1cecf7b9f4..36e6c33911a913a98e3ea8d125642f4f70d37efd 100644 (file)
@@ -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,
index 1f4433dcfb4c5361a8f250090b45ee116db0e5fb..9c00d92098f3f3f8fa0d39a8c1f5acf69932111a 100644 (file)
@@ -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)})