Merge "Update scheduler instance info at confirm resize" into stable/rocky

This commit is contained in:
Zuul 2020-05-28 14:39:13 +00:00 committed by Gerrit Code Review
commit 005c3b702e
3 changed files with 16 additions and 19 deletions

View File

@ -4078,6 +4078,10 @@ class ComputeManager(manager.Manager):
self._delete_allocation_after_move(
context, instance, migration, old_instance_type,
migration.source_node)
# Also as the instance is not any more on this host, update
# the scheduler about the move
self._delete_scheduler_instance_info(
context, instance.uuid)
do_confirm_resize(context, instance, migration.id)

View File

@ -369,7 +369,7 @@ class ServerGroupTestV21(ServerGroupTestBase):
self.assertNotEqual(servers[0]['OS-EXT-SRV-ATTR:host'],
migrated_server['OS-EXT-SRV-ATTR:host'])
def test_migrate_with_anti_affinity_stale_scheduler_instance_info(self):
def test_migrate_with_anti_affinity_confirm_updates_scheduler(self):
# Start additional host to test migration with anti-affinity
compute3 = self.start_service('compute', host='host3')
@ -398,23 +398,12 @@ class ServerGroupTestV21(ServerGroupTestBase):
self.admin_api.post_server_action(servers[1]['id'], post)
self._wait_for_state_change(self.admin_api, servers[1], 'ACTIVE')
# NOTE(gibi): This is bug 1869050. The confirm resize does to update
# the scheduler instance info so the migrate_server occupies two host
# according to the stale information in the scheduler.
# Alternatively waiting for the periodic _sync_scheduler_instance_info
# call would update the stale data.
server3 = self._boot_a_server_to_group(created_group)
server3 = self._boot_a_server_to_group(
created_group, expected_status='ERROR')
self.assertIn('No valid host', server3['fault']['message'])
# When bug 1869050 is fixed the following is expected:
# server3 = self._boot_a_server_to_group(created_group)
#
# # we have 3 servers that should occupy 3 different hosts
# hosts = {server['OS-EXT-SRV-ATTR:host']
# for server in [servers[0], migrated_server, server3]}
# self.assertEqual(3, len(hosts))
# we have 3 servers that should occupy 3 different hosts
hosts = {server['OS-EXT-SRV-ATTR:host']
for server in [servers[0], migrated_server, server3]}
self.assertEqual(3, len(hosts))
def test_resize_to_same_host_with_anti_affinity(self):
self.flags(allow_resize_to_same_host=True)

View File

@ -7481,7 +7481,8 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase):
do_revert_resize()
do_finish_revert_resize()
def test_confirm_resize_deletes_allocations(self):
def test_confirm_resize_deletes_allocations_and_update_scheduler(self):
@mock.patch.object(self.compute, '_delete_scheduler_instance_info')
@mock.patch('nova.objects.Instance.get_by_uuid')
@mock.patch('nova.objects.Migration.get_by_id')
@mock.patch.object(self.migration, 'save')
@ -7494,7 +7495,8 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase):
@mock.patch.object(self.instance, 'save')
def do_confirm_resize(mock_save, mock_drop, mock_delete, mock_get_rt,
mock_confirm, mock_nwapi, mock_notify,
mock_mig_save, mock_mig_get, mock_inst_get):
mock_mig_save, mock_mig_get, mock_inst_get,
mock_delete_scheduler_info):
self.instance.migration_context = objects.MigrationContext(
new_pci_devices=None,
old_pci_devices=None)
@ -7512,6 +7514,8 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase):
mock_save.assert_called_with(expected_task_state=
[None, task_states.DELETING,
task_states.SOFT_DELETING])
mock_delete_scheduler_info.assert_called_once_with(
self.context, self.instance.uuid)
do_confirm_resize()