Skip to content

Commit

Permalink
Fix a notification bug when creating instances
Browse files Browse the repository at this point in the history
Fixes a notifier bug that caused 'launched_at' to be empty and
state to be reported as 'building', due to failure to refresh
instance data prior to generating the notification.  Fixes
bug 834867.

Change-Id: I70fbf3c67407c67b69040ee481ca6d51212cc55d
  • Loading branch information
Kevin L. Mitchell committed Nov 10, 2011
1 parent 1a5418b commit 57e73d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 6 additions & 6 deletions nova/compute/manager.py
Expand Up @@ -463,12 +463,12 @@ def _error_message(instance_id, message):
network_info, block_device_info)

current_power_state = self._get_power_state(context, instance)
self._instance_update(context,
instance_id,
power_state=current_power_state,
vm_state=vm_states.ACTIVE,
task_state=None,
launched_at=utils.utcnow())
instance = self._instance_update(context,
instance_id,
power_state=current_power_state,
vm_state=vm_states.ACTIVE,
task_state=None,
launched_at=utils.utcnow())

usage_info = utils.usage_from_instance(instance)
notifier.notify('compute.%s' % self.host,
Expand Down
2 changes: 2 additions & 0 deletions nova/tests/test_compute.py
Expand Up @@ -420,9 +420,11 @@ def test_run_instance_usage_notification(self):
self.assertEquals(payload['instance_type'], 'm1.tiny')
type_id = instance_types.get_instance_type_by_name('m1.tiny')['id']
self.assertEquals(str(payload['instance_type_id']), str(type_id))
self.assertEquals(payload['state'], 'active')
self.assertTrue('display_name' in payload)
self.assertTrue('created_at' in payload)
self.assertTrue('launched_at' in payload)
self.assertTrue(payload['launched_at'])
self.assertEquals(payload['image_ref'], '1')
self.compute.terminate_instance(self.context, instance_id)

Expand Down

0 comments on commit 57e73d3

Please sign in to comment.