# UNDF: UNDF-2026-000000188 --- a/nova/scheduler/manager.py +++ b/nova/scheduler/manager.py @@ -587,7 +587,8 @@ class SchedulerManager(manager.Manager): Additionally, we may be working with older conductors that don't pass in instance_uuids. """ - # The list of hosts selected for each instance - selected_hosts = [] + # The list of hosts selected for each instance (list preserves order) + selected_hosts = [] + selected_hosts_set = set() # O(1) membership; avoids O(N²) in _schedule_alt @@ -605,7 +607,8 @@ class SchedulerManager(manager.Manager): selected_host = hosts[0] selected_hosts.append(selected_host) + selected_hosts_set.add(selected_host) self._consume_selected_host( @@ -699,7 +703,7 @@ class SchedulerManager(manager.Manager): if len(selected_plus_alts) >= num_alts + 1: break - if host.cell_uuid == cell_uuid and host not in selected_hosts: + if host.cell_uuid == cell_uuid and host not in selected_hosts_set: if alloc_reqs_by_rp_uuid is not None: