Fix inappropriate notification send

The method '_build_and_run_instance' sends inappropriate
notification 'create.end' when an exception is raised, instead
it should be sending 'create.error' notification.

Replaced 'create.end' notification with 'create.error'
when exception is raised.

Change-Id: I2661cc47b6ebb674cce2f2b43851aa9eca12b5f8
Closes-Bug:1578500
This commit is contained in:
Rajesh Tailor 2016-05-05 06:11:25 -04:00
parent eec3a2b9e8
commit 19cc6e2ca8
2 changed files with 8 additions and 8 deletions

View File

@ -1916,7 +1916,7 @@ class ComputeManager(manager.Manager):
exception.UnexpectedDeletingTaskStateError) as e: exception.UnexpectedDeletingTaskStateError) as e:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
self._notify_about_instance_usage(context, instance, self._notify_about_instance_usage(context, instance,
'create.end', fault=e) 'create.error', fault=e)
except exception.ComputeResourcesUnavailable as e: except exception.ComputeResourcesUnavailable as e:
LOG.debug(e.format_message(), instance=instance) LOG.debug(e.format_message(), instance=instance)
self._notify_about_instance_usage(context, instance, self._notify_about_instance_usage(context, instance,
@ -1991,7 +1991,7 @@ class ComputeManager(manager.Manager):
exception.UnexpectedDeletingTaskStateError) as e: exception.UnexpectedDeletingTaskStateError) as e:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
self._notify_about_instance_usage(context, instance, self._notify_about_instance_usage(context, instance,
'create.end', fault=e) 'create.error', fault=e)
self._update_scheduler_instance_info(context, instance) self._update_scheduler_instance_info(context, instance)
self._notify_about_instance_usage(context, instance, 'create.end', self._notify_about_instance_usage(context, instance, 'create.end',

View File

@ -3835,7 +3835,7 @@ class ComputeManagerBuildInstanceTestCase(test.NoDBTestCase):
mock_notify.assert_has_calls([ mock_notify.assert_has_calls([
mock.call(self.context, self.instance, 'create.start', mock.call(self.context, self.instance, 'create.start',
extra_usage_info={'image_name': self.image.get('name')}), extra_usage_info={'image_name': self.image.get('name')}),
mock.call(self.context, self.instance, 'create.end', mock.call(self.context, self.instance, 'create.error',
fault=exc)]) fault=exc)])
mock_build.assert_called_once_with(self.context, self.instance, mock_build.assert_called_once_with(self.context, self.instance,
self.requested_networks, self.security_groups) self.requested_networks, self.security_groups)
@ -4412,10 +4412,10 @@ class ComputeManagerBuildInstanceTestCase(test.NoDBTestCase):
_check_access_ip() _check_access_ip()
@mock.patch.object(manager.ComputeManager, '_instance_update') @mock.patch.object(manager.ComputeManager, '_instance_update')
def test_create_end_on_instance_delete(self, mock_instance_update): def test_create_error_on_instance_delete(self, mock_instance_update):
def fake_notify(*args, **kwargs): def fake_notify(*args, **kwargs):
if args[2] == 'create.end': if args[2] == 'create.error':
# Check that launched_at is set on the instance # Check that launched_at is set on the instance
self.assertIsNotNone(args[1].launched_at) self.assertIsNotNone(args[1].launched_at)
@ -4437,10 +4437,10 @@ class ComputeManagerBuildInstanceTestCase(test.NoDBTestCase):
self.security_groups, self.block_device_mapping, self.node, self.security_groups, self.block_device_mapping, self.node,
self.limits, self.filter_properties) self.limits, self.filter_properties)
expected_call = mock.call(self.context, self.instance, expected_call = mock.call(self.context, self.instance,
'create.end', fault=exc) 'create.error', fault=exc)
create_end_call = mock_notify.call_args_list[ create_error_call = mock_notify.call_args_list[
mock_notify.call_count - 1] mock_notify.call_count - 1]
self.assertEqual(expected_call, create_end_call) self.assertEqual(expected_call, create_error_call)
class ComputeManagerMigrationTestCase(test.NoDBTestCase): class ComputeManagerMigrationTestCase(test.NoDBTestCase):