From 5ee167c14c9978409db059054a02635de35a2e93 Mon Sep 17 00:00:00 2001 From: John Griffith Date: Tue, 29 Jul 2014 09:59:33 -0600 Subject: [PATCH] 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 --- cinder/tests/test_volume.py | 1 + cinder/volume/manager.py | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) 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") -- 2.45.2