]> 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 15:59:33 +0000 (09:59 -0600)
committerJohn Griffith <john.griffith8@gmail.com>
Tue, 29 Jul 2014 17:00:05 +0000 (11:00 -0600)
When we update a snapshot status in the db, we need to
use the newly updated snapshot-ref object in the following
notification method call.  Otherwise we're sending a
notifciation message with the old/outdated status
information.

NOTE: This also fixes the unit test that was written to
pass with the bug that existed in the notification.

Closes-Bug: #1349805

Change-Id: I32b86d7edd836310c6da7adffa46e915361668f0

cinder/tests/test_volume.py
cinder/volume/manager.py

index 57851d4ecd1b8e758c523dfb78a7e2c15e4cd6f7..68eb2eedab4b5c212652b449a5d0e064d57e18e1 100644 (file)
@@ -1635,6 +1635,7 @@ class VolumeTestCase(BaseVolumeTestCase):
         self.assertDictMatch(msg['payload'], expected)
         msg = fake_notifier.NOTIFICATIONS[3]
         self.assertEqual(msg['event_type'], 'snapshot.create.end')
+        expected['status'] = 'available'
         self.assertDictMatch(msg['payload'], expected)
 
         self.volume.delete_snapshot(self.context, snapshot_id)
index 1f4433dcfb4c5361a8f250090b45ee116db0e5fb..88d0b37ca5757b99f75d6f3b92eba67d0bdaba2c 100644 (file)
@@ -472,9 +472,10 @@ class VolumeManager(manager.SchedulerDependentManager):
                                         {'status': 'error'})
                 raise exception.MetadataCopyFailure(reason=ex)
 
-        self.db.snapshot_update(context,
-                                snapshot_ref['id'], {'status': 'available',
-                                                     'progress': '100%'})
+        snapshot_ref = self.db.snapshot_update(context,
+                                               snapshot_ref['id'],
+                                               {'status': 'available',
+                                                'progress': '100%'})
 
         LOG.info(_("snapshot %s: created successfully"), snapshot_ref['id'])
         self._notify_about_snapshot_usage(context, snapshot_ref, "create.end")