Transform instance.live_migration_force_complete notification
The instance.live_migration_force_complete.start and instance.live_migration_force_complete.end notifications have been transformed to the versioned notification framework. Co-Authored-By: Takashi Natsume <natsume.takashi@lab.ntt.co.jp> Change-Id: I2e9a474457a7597a9febc111b13a67ddcf45f29e Implements: bp versioned-notification-transformation-rocky
This commit is contained in:
parent
6322cb6a18
commit
23efc549a1
@ -0,0 +1,12 @@
|
||||
{
|
||||
"event_type": "instance.live_migration_force_complete.end",
|
||||
"payload": {
|
||||
"$ref": "common_payloads/InstanceActionPayload.json#",
|
||||
"nova_object.data": {
|
||||
"action_initiator_user": "admin",
|
||||
"task_state": "migrating"
|
||||
}
|
||||
},
|
||||
"priority": "INFO",
|
||||
"publisher_id": "nova-compute:compute"
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
{
|
||||
"event_type": "instance.live_migration_force_complete.start",
|
||||
"payload": {
|
||||
"$ref": "common_payloads/InstanceActionPayload.json#",
|
||||
"nova_object.data": {
|
||||
"action_initiator_user": "admin",
|
||||
"task_state": "migrating"
|
||||
}
|
||||
},
|
||||
"priority": "INFO",
|
||||
"publisher_id": "nova-compute:compute"
|
||||
}
|
@ -6282,9 +6282,17 @@ class ComputeManager(manager.Manager):
|
||||
|
||||
self._notify_about_instance_usage(
|
||||
context, instance, 'live.migration.force.complete.start')
|
||||
compute_utils.notify_about_instance_action(
|
||||
context, instance, self.host,
|
||||
action=fields.NotificationAction.LIVE_MIGRATION_FORCE_COMPLETE,
|
||||
phase=fields.NotificationPhase.START)
|
||||
self.driver.live_migration_force_complete(instance)
|
||||
self._notify_about_instance_usage(
|
||||
context, instance, 'live.migration.force.complete.end')
|
||||
compute_utils.notify_about_instance_action(
|
||||
context, instance, self.host,
|
||||
action=fields.NotificationAction.LIVE_MIGRATION_FORCE_COMPLETE,
|
||||
phase=fields.NotificationPhase.END)
|
||||
|
||||
@wrap_exception()
|
||||
@wrap_instance_event(prefix='compute')
|
||||
|
@ -63,7 +63,9 @@ class EventType(NotificationObject):
|
||||
# NotificationActionField enum
|
||||
# Version 1.14: UPDATE_PROP value is added to the NotificationActionField
|
||||
# enum
|
||||
VERSION = '1.14'
|
||||
# Version 1.15: LIVE_MIGRATION_FORCE_COMPLETE is added to the
|
||||
# NotificationActionField enum
|
||||
VERSION = '1.15'
|
||||
|
||||
fields = {
|
||||
'object': fields.StringField(nullable=False),
|
||||
|
@ -550,6 +550,8 @@ class InstanceStateUpdatePayload(base.NotificationPayloadBase):
|
||||
@base.notification_sample('instance-resize_confirm-end.json')
|
||||
@base.notification_sample('instance-resize_revert-start.json')
|
||||
@base.notification_sample('instance-resize_revert-end.json')
|
||||
@base.notification_sample('instance-live_migration_force_complete-start.json')
|
||||
@base.notification_sample('instance-live_migration_force_complete-end.json')
|
||||
@base.notification_sample('instance-shelve_offload-start.json')
|
||||
@base.notification_sample('instance-shelve_offload-end.json')
|
||||
@base.notification_sample('instance-soft_delete-start.json')
|
||||
|
@ -807,6 +807,7 @@ class NotificationAction(BaseNovaEnum):
|
||||
LIVE_MIGRATION_PRE = 'live_migration_pre'
|
||||
LIVE_MIGRATION_ROLLBACK_DEST = 'live_migration_rollback_dest'
|
||||
LIVE_MIGRATION_ROLLBACK = 'live_migration_rollback'
|
||||
LIVE_MIGRATION_FORCE_COMPLETE = 'live_migration_force_complete'
|
||||
REBUILD = 'rebuild'
|
||||
REBUILD_SCHEDULED = 'rebuild_scheduled'
|
||||
INTERFACE_DETACH = 'interface_detach'
|
||||
@ -836,7 +837,7 @@ class NotificationAction(BaseNovaEnum):
|
||||
RESIZE_CONFIRM, RESIZE_PREP, RESIZE_REVERT, SHELVE_OFFLOAD,
|
||||
SOFT_DELETE, TRIGGER_CRASH_DUMP, UNRESCUE, UNSHELVE, ADD_HOST,
|
||||
REMOVE_HOST, ADD_MEMBER, UPDATE_METADATA, LOCK, UNLOCK,
|
||||
REBUILD_SCHEDULED, UPDATE_PROP)
|
||||
REBUILD_SCHEDULED, UPDATE_PROP, LIVE_MIGRATION_FORCE_COMPLETE)
|
||||
|
||||
|
||||
# TODO(rlrossit): These should be changed over to be a StateMachine enum from
|
||||
|
@ -56,7 +56,8 @@ class TestInstanceNotificationSampleWithMultipleCompute(
|
||||
self._test_live_migration_rollback,
|
||||
self._test_live_migration_abort,
|
||||
self._test_live_migration_success,
|
||||
self._test_evacuate_server
|
||||
self._test_evacuate_server,
|
||||
self._test_live_migration_force_complete
|
||||
]
|
||||
|
||||
for action in actions:
|
||||
@ -253,6 +254,43 @@ class TestInstanceNotificationSampleWithMultipleCompute(
|
||||
actual=notifications[0])
|
||||
self.admin_api.put_service(service_id, {'forced_down': False})
|
||||
|
||||
def _test_live_migration_force_complete(self, server):
|
||||
post = {
|
||||
'os-migrateLive': {
|
||||
'host': 'host2',
|
||||
'block_migration': True,
|
||||
'force': True,
|
||||
}
|
||||
}
|
||||
self.admin_api.post_server_action(server['id'], post)
|
||||
|
||||
self._wait_for_state_change(self.api, server, 'MIGRATING')
|
||||
|
||||
migrations = self._wait_and_get_migrations(server)
|
||||
migration_id = migrations[0]['id']
|
||||
self.admin_api.force_complete_migration(server['id'], migration_id)
|
||||
|
||||
self._wait_for_notification(
|
||||
'instance.live_migration_force_complete.end')
|
||||
|
||||
# 0. instance.live_migration_pre.start
|
||||
# 1. instance.live_migration_pre.end
|
||||
# 2. instance.live_migration_force_complete.start
|
||||
# 3. instance.live_migration_force_complete.end
|
||||
self.assertEqual(4, len(fake_notifier.VERSIONED_NOTIFICATIONS))
|
||||
self._verify_notification(
|
||||
'instance-live_migration_force_complete-start',
|
||||
replacements={
|
||||
'reservation_id': server['reservation_id'],
|
||||
'uuid': server['id']},
|
||||
actual=fake_notifier.VERSIONED_NOTIFICATIONS[2])
|
||||
self._verify_notification(
|
||||
'instance-live_migration_force_complete-end',
|
||||
replacements={
|
||||
'reservation_id': server['reservation_id'],
|
||||
'uuid': server['id']},
|
||||
actual=fake_notifier.VERSIONED_NOTIFICATIONS[3])
|
||||
|
||||
|
||||
class TestInstanceNotificationSampleWithMultipleComputeOldAttachFlow(
|
||||
TestInstanceNotificationSampleWithMultipleCompute):
|
||||
|
@ -7234,13 +7234,14 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase):
|
||||
migration.status = 'running'
|
||||
migration.id = 0
|
||||
|
||||
@mock.patch('nova.compute.utils.notify_about_instance_action')
|
||||
@mock.patch('nova.image.api.API.generate_image_url',
|
||||
return_value='fake-url')
|
||||
@mock.patch.object(objects.Migration, 'get_by_id',
|
||||
return_value=migration)
|
||||
@mock.patch.object(self.compute.driver,
|
||||
'live_migration_force_complete')
|
||||
def _do_test(force_complete, get_by_id, gen_img_url):
|
||||
def _do_test(force_complete, get_by_id, gen_img_url, mock_notify):
|
||||
self.compute.live_migration_force_complete(
|
||||
self.context, self.instance)
|
||||
|
||||
@ -7259,6 +7260,14 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase):
|
||||
self.assertEqual(
|
||||
self.instance.uuid,
|
||||
fake_notifier.NOTIFICATIONS[1].payload['instance_id'])
|
||||
self.assertEqual(2, mock_notify.call_count)
|
||||
mock_notify.assert_has_calls([
|
||||
mock.call(self.context, self.instance, self.compute.host,
|
||||
action='live_migration_force_complete',
|
||||
phase='start'),
|
||||
mock.call(self.context, self.instance, self.compute.host,
|
||||
action='live_migration_force_complete',
|
||||
phase='end')])
|
||||
|
||||
_do_test()
|
||||
|
||||
|
@ -370,7 +370,7 @@ notification_object_data = {
|
||||
'AuditPeriodPayload': '1.0-2b429dd307b8374636703b843fa3f9cb',
|
||||
'BandwidthPayload': '1.0-ee2616a7690ab78406842a2b68e34130',
|
||||
'BlockDevicePayload': '1.0-29751e1b6d41b1454e36768a1e764df8',
|
||||
'EventType': '1.14-471d49b27dce4b38484451f5146b7c16',
|
||||
'EventType': '1.15-a93b5b3b54ebf6c5a158dfcd985d15c5',
|
||||
'ExceptionNotification': '1.0-a73147b93b520ff0061865849d3dfa56',
|
||||
'ExceptionPayload': '1.1-6c43008bd81885a63bc7f7c629f0793b',
|
||||
'FlavorNotification': '1.0-a73147b93b520ff0061865849d3dfa56',
|
||||
|
Loading…
Reference in New Issue
Block a user