Update scheduler instance info at confirm resize
When a resize is confirmed the instance does not belong to the source
compute any more. In the past the scheduler instance info is only
updated by the _sync_scheduler_instance_info periodic. This caused that
server boots with anti-affinity did not consider the source host.
But now at the end of the confirm_resize call the compute also updates
the scheduler about the move.
Change-Id: Ic50e72e289b56ac54720ad0b719ceeb32487b8c8
Closes-Bug: #1869050
(cherry picked from commit 738110db74
)
This commit is contained in:
parent
016eeec984
commit
e8b3927c92
|
@ -4309,6 +4309,10 @@ class ComputeManager(manager.Manager):
|
|||
# allocations in placement, delete them here.
|
||||
self._delete_allocation_after_move(
|
||||
context, instance, migration)
|
||||
# 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)
|
||||
|
||||
|
|
|
@ -371,7 +371,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')
|
||||
|
||||
|
@ -400,23 +400,12 @@ class ServerGroupTestV21(ServerGroupTestBase):
|
|||
self.admin_api.post_server_action(servers[1]['id'], post)
|
||||
self._wait_for_state_change(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)
|
||||
|
|
|
@ -8568,7 +8568,8 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase,
|
|||
mock_network_migrate_finish.assert_called_once_with(
|
||||
self.context, self.instance, self.migration, None)
|
||||
|
||||
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')
|
||||
|
@ -8580,7 +8581,8 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase,
|
|||
@mock.patch.object(self.instance, 'save')
|
||||
def do_confirm_resize(mock_save, mock_drop, mock_delete,
|
||||
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):
|
||||
|
||||
def fake_drop_move_claim(*args, **kwargs):
|
||||
# RT.drop_move_claim must be called before
|
||||
|
@ -8605,6 +8607,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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue