Report instance-actions for live migration force complete API
There isn't instance-action reported by new live migration force complete API. This is async API, so there isn't a way for user to know if there is error happened in this API. This patch add instance-actions report to it Change-Id: I29dc8ce0aa576ef55d2a4dfbaa6bd1f2bfd90371 Closes-Bug: #1553050
This commit is contained in:
@@ -3383,6 +3383,9 @@ class API(base.Base):
|
|||||||
state=migration.status,
|
state=migration.status,
|
||||||
method='force complete')
|
method='force complete')
|
||||||
|
|
||||||
|
self._record_action_start(
|
||||||
|
context, instance, instance_actions.LIVE_MIGRATION_FORCE_COMPLETE)
|
||||||
|
|
||||||
self.compute_rpcapi.live_migration_force_complete(
|
self.compute_rpcapi.live_migration_force_complete(
|
||||||
context, instance, migration.id)
|
context, instance, migration.id)
|
||||||
|
|
||||||
|
@@ -50,4 +50,5 @@ SHELVE = 'shelve'
|
|||||||
UNSHELVE = 'unshelve'
|
UNSHELVE = 'unshelve'
|
||||||
LIVE_MIGRATION = 'live-migration'
|
LIVE_MIGRATION = 'live-migration'
|
||||||
LIVE_MIGRATION_CANCEL = 'live_migration_cancel'
|
LIVE_MIGRATION_CANCEL = 'live_migration_cancel'
|
||||||
|
LIVE_MIGRATION_FORCE_COMPLETE = 'live_migration_force_complete'
|
||||||
TRIGGER_CRASH_DUMP = 'trigger_crash_dump'
|
TRIGGER_CRASH_DUMP = 'trigger_crash_dump'
|
||||||
|
@@ -5260,6 +5260,7 @@ class ComputeManager(manager.Manager):
|
|||||||
migrate_data)
|
migrate_data)
|
||||||
|
|
||||||
@wrap_exception()
|
@wrap_exception()
|
||||||
|
@wrap_instance_event
|
||||||
@wrap_instance_fault
|
@wrap_instance_fault
|
||||||
def live_migration_force_complete(self, context, instance, migration_id):
|
def live_migration_force_complete(self, context, instance, migration_id):
|
||||||
"""Force live migration to complete.
|
"""Force live migration to complete.
|
||||||
|
@@ -3353,8 +3353,9 @@ class _ComputeAPIUnitTestMixIn(object):
|
|||||||
host_statuses[instance.uuid])
|
host_statuses[instance.uuid])
|
||||||
|
|
||||||
@mock.patch.object(objects.Migration, 'get_by_id_and_instance')
|
@mock.patch.object(objects.Migration, 'get_by_id_and_instance')
|
||||||
|
@mock.patch.object(objects.InstanceAction, 'action_start')
|
||||||
def test_live_migrate_force_complete_succeeded(
|
def test_live_migrate_force_complete_succeeded(
|
||||||
self, get_by_id_and_instance):
|
self, action_start, get_by_id_and_instance):
|
||||||
|
|
||||||
if self.cell_type == 'api':
|
if self.cell_type == 'api':
|
||||||
# cell api has not been implemented.
|
# cell api has not been implemented.
|
||||||
@@ -3377,6 +3378,9 @@ class _ComputeAPIUnitTestMixIn(object):
|
|||||||
lm_force_complete.assert_called_once_with(self.context,
|
lm_force_complete.assert_called_once_with(self.context,
|
||||||
instance,
|
instance,
|
||||||
0)
|
0)
|
||||||
|
action_start.assert_called_once_with(
|
||||||
|
self.context, instance.uuid, 'live_migration_force_complete',
|
||||||
|
want_result=False)
|
||||||
|
|
||||||
@mock.patch.object(objects.Migration, 'get_by_id_and_instance')
|
@mock.patch.object(objects.Migration, 'get_by_id_and_instance')
|
||||||
def test_live_migrate_force_complete_invalid_migration_state(
|
def test_live_migrate_force_complete_invalid_migration_state(
|
||||||
|
@@ -4370,12 +4370,14 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase):
|
|||||||
migration.status = 'running'
|
migration.status = 'running'
|
||||||
migration.id = 0
|
migration.id = 0
|
||||||
|
|
||||||
|
@mock.patch.object(compute_utils.EventReporter, '__enter__')
|
||||||
@mock.patch.object(self.compute, '_notify_about_instance_usage')
|
@mock.patch.object(self.compute, '_notify_about_instance_usage')
|
||||||
@mock.patch.object(objects.Migration, 'get_by_id',
|
@mock.patch.object(objects.Migration, 'get_by_id',
|
||||||
return_value=migration)
|
return_value=migration)
|
||||||
@mock.patch.object(self.compute.driver,
|
@mock.patch.object(self.compute.driver,
|
||||||
'live_migration_force_complete')
|
'live_migration_force_complete')
|
||||||
def _do_test(force_complete, get_by_id, _notify_about_instance_usage):
|
def _do_test(force_complete, get_by_id, _notify_about_instance_usage,
|
||||||
|
enter_event_reporter):
|
||||||
self.compute.live_migration_force_complete(
|
self.compute.live_migration_force_complete(
|
||||||
self.context, instance, migration.id)
|
self.context, instance, migration.id)
|
||||||
|
|
||||||
@@ -4389,6 +4391,7 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase):
|
|||||||
]
|
]
|
||||||
|
|
||||||
_notify_about_instance_usage.assert_has_calls(_notify_usage_calls)
|
_notify_about_instance_usage.assert_has_calls(_notify_usage_calls)
|
||||||
|
enter_event_reporter.assert_called_once_with()
|
||||||
|
|
||||||
_do_test()
|
_do_test()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user