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
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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)})
|
||||
|
||||
Reference in New Issue
Block a user