Skip to content

Commit

Permalink
Update ref used for notifications
Browse files Browse the repository at this point in the history
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
  • Loading branch information
j-griffith committed Aug 16, 2014
1 parent d5b7735 commit 7fd2eea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions cinder/tests/test_db_api.py
Expand Up @@ -658,10 +658,12 @@ def test_volume_get_iscsi_target_num_nonexistent(self):

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,
Expand Down
7 changes: 5 additions & 2 deletions cinder/volume/manager.py
Expand Up @@ -1192,9 +1192,12 @@ def extend_volume(self, context, volume_id, new_size, reservations):
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)})
Expand Down

0 comments on commit 7fd2eea

Please sign in to comment.