From: John Griffith Date: Tue, 29 Jul 2014 15:59:33 +0000 (-0600) Subject: Update ref used for notifications X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=5ee167c14c9978409db059054a02635de35a2e93;p=openstack-build%2Fcinder-build.git Update ref used for notifications 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 --- diff --git a/cinder/tests/test_volume.py b/cinder/tests/test_volume.py index 57851d4ec..68eb2eeda 100644 --- a/cinder/tests/test_volume.py +++ b/cinder/tests/test_volume.py @@ -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) diff --git a/cinder/volume/manager.py b/cinder/volume/manager.py index 1f4433dcf..88d0b37ca 100644 --- a/cinder/volume/manager.py +++ b/cinder/volume/manager.py @@ -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")