Merge "Transform instance.live_migration_rollback_dest notification"

This commit is contained in:
Zuul 2018-07-15 13:25:45 +00:00 committed by Gerrit Code Review
commit 202c147f3c
7 changed files with 74 additions and 9 deletions

View File

@ -0,0 +1,11 @@
{
"event_type": "instance.live_migration_rollback_dest.end",
"payload": {
"$ref": "common_payloads/InstanceActionPayload.json#",
"nova_object.data": {
"action_initiator_user": "admin"
}
},
"priority": "INFO",
"publisher_id": "nova-compute:host2"
}

View File

@ -0,0 +1,11 @@
{
"event_type": "instance.live_migration_rollback_dest.start",
"payload": {
"$ref": "common_payloads/InstanceActionPayload.json#",
"nova_object.data": {
"action_initiator_user": "admin"
}
},
"priority": "INFO",
"publisher_id": "nova-compute:host2"
}

View File

@ -6732,6 +6732,10 @@ class ComputeManager(manager.Manager):
self._notify_about_instance_usage( self._notify_about_instance_usage(
context, instance, "live_migration.rollback.dest.start", context, instance, "live_migration.rollback.dest.start",
network_info=network_info) network_info=network_info)
compute_utils.notify_about_instance_action(
context, instance, self.host,
action=fields.NotificationAction.LIVE_MIGRATION_ROLLBACK_DEST,
phase=fields.NotificationPhase.START)
try: try:
# NOTE(tr3buchet): tear down networks on destination host # NOTE(tr3buchet): tear down networks on destination host
self.network_api.setup_networks_on_host(context, instance, self.network_api.setup_networks_on_host(context, instance,
@ -6755,6 +6759,10 @@ class ComputeManager(manager.Manager):
self._notify_about_instance_usage( self._notify_about_instance_usage(
context, instance, "live_migration.rollback.dest.end", context, instance, "live_migration.rollback.dest.end",
network_info=network_info) network_info=network_info)
compute_utils.notify_about_instance_action(
context, instance, self.host,
action=fields.NotificationAction.LIVE_MIGRATION_ROLLBACK_DEST,
phase=fields.NotificationPhase.END)
@periodic_task.periodic_task( @periodic_task.periodic_task(
spacing=CONF.heal_instance_info_cache_interval) spacing=CONF.heal_instance_info_cache_interval)

View File

@ -542,8 +542,8 @@ class InstanceStateUpdatePayload(base.NotificationPayloadBase):
@base.notification_sample('instance-live_migration_post_dest-end.json') @base.notification_sample('instance-live_migration_post_dest-end.json')
@base.notification_sample('instance-live_migration_rollback-start.json') @base.notification_sample('instance-live_migration_rollback-start.json')
@base.notification_sample('instance-live_migration_rollback-end.json') @base.notification_sample('instance-live_migration_rollback-end.json')
# @base.notification_sample('instance-live_migration_rollback_dest-start.json') @base.notification_sample('instance-live_migration_rollback_dest-start.json')
# @base.notification_sample('instance-live_migration_rollback_dest-end.json') @base.notification_sample('instance-live_migration_rollback_dest-end.json')
@base.notification_sample('instance-interface_detach-start.json') @base.notification_sample('instance-interface_detach-start.json')
@base.notification_sample('instance-interface_detach-end.json') @base.notification_sample('instance-interface_detach-end.json')
@base.notification_sample('instance-resize_confirm-start.json') @base.notification_sample('instance-resize_confirm-start.json')

View File

@ -65,9 +65,12 @@ class TestInstanceNotificationSampleWithMultipleCompute(
# Ensure that instance is in active state after an action # Ensure that instance is in active state after an action
self._wait_for_state_change(self.admin_api, server, 'ACTIVE') self._wait_for_state_change(self.admin_api, server, 'ACTIVE')
@mock.patch('nova.compute.manager.ComputeManager.'
'_live_migration_cleanup_flags', return_value=[True, False])
@mock.patch('nova.compute.rpcapi.ComputeAPI.pre_live_migration', @mock.patch('nova.compute.rpcapi.ComputeAPI.pre_live_migration',
side_effect=exception.DestinationDiskExists(path='path')) side_effect=exception.DestinationDiskExists(path='path'))
def _test_live_migration_rollback(self, server, mock_migration): def _test_live_migration_rollback(self, server, mock_migration,
mock_flags):
post = { post = {
'os-migrateLive': { 'os-migrateLive': {
'host': 'host2', 'host': 'host2',
@ -76,10 +79,14 @@ class TestInstanceNotificationSampleWithMultipleCompute(
} }
} }
self.admin_api.post_server_action(server['id'], post) self.admin_api.post_server_action(server['id'], post)
self._wait_for_notification('instance.live_migration_rollback.start') self._wait_for_notification(
self._wait_for_notification('instance.live_migration_rollback.end') 'instance.live_migration_rollback_dest.end')
self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS)) # 0. instance.live_migration_rollback.start
# 1. instance.live_migration_rollback.end
# 2. instance.live_migration_rollback_dest.start
# 3. instance.live_migration_rollback_dest.end
self.assertEqual(4, len(fake_notifier.VERSIONED_NOTIFICATIONS))
self._verify_notification( self._verify_notification(
'instance-live_migration_rollback-start', 'instance-live_migration_rollback-start',
replacements={ replacements={
@ -92,6 +99,18 @@ class TestInstanceNotificationSampleWithMultipleCompute(
'reservation_id': server['reservation_id'], 'reservation_id': server['reservation_id'],
'uuid': server['id']}, 'uuid': server['id']},
actual=fake_notifier.VERSIONED_NOTIFICATIONS[1]) actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
self._verify_notification(
'instance-live_migration_rollback_dest-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
actual=fake_notifier.VERSIONED_NOTIFICATIONS[2])
self._verify_notification(
'instance-live_migration_rollback_dest-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
actual=fake_notifier.VERSIONED_NOTIFICATIONS[3])
def _test_live_migration_success(self, server): def _test_live_migration_success(self, server):
post = { post = {

View File

@ -6723,10 +6723,12 @@ class ComputeTestCase(BaseTestCase,
_test() _test()
@mock.patch('nova.compute.utils.notify_about_instance_action')
@mock.patch.object(fake.FakeDriver, @mock.patch.object(fake.FakeDriver,
'rollback_live_migration_at_destination') 'rollback_live_migration_at_destination')
def test_rollback_live_migration_at_destination_correctly(self, def test_rollback_live_migration_at_destination_correctly(self,
mock_rollback): mock_rollback,
mock_notify):
# creating instance testdata # creating instance testdata
c = context.get_admin_context() c = context.get_admin_context()
instance = self._create_fake_instance_obj({'host': 'dummy'}) instance = self._create_fake_instance_obj({'host': 'dummy'})
@ -6754,8 +6756,15 @@ class ComputeTestCase(BaseTestCase,
'root_device_name': None, 'root_device_name': None,
'block_device_mapping': []}, 'block_device_mapping': []},
destroy_disks=True, migrate_data=None) destroy_disks=True, migrate_data=None)
mock_notify.assert_has_calls([
mock.call(c, instance, self.compute.host,
action='live_migration_rollback_dest',
phase='start'),
mock.call(c, instance, self.compute.host,
action='live_migration_rollback_dest',
phase='end')])
@mock.patch('nova.virt.driver.ComputeDriver.' @mock.patch.object(fake.FakeDriver,
'rollback_live_migration_at_destination') 'rollback_live_migration_at_destination')
def test_rollback_live_migration_at_destination_network_fails( def test_rollback_live_migration_at_destination_network_fails(
self, mock_rollback): self, mock_rollback):

View File

@ -551,6 +551,13 @@ class FakeDriver(driver.ComputeDriver):
network_info, disk_info, migrate_data): network_info, disk_info, migrate_data):
return migrate_data return migrate_data
def rollback_live_migration_at_destination(self, context, instance,
network_info,
block_device_info,
destroy_disks=True,
migrate_data=None):
return
def unfilter_instance(self, instance, network_info): def unfilter_instance(self, instance, network_info):
return return