diff options
author | Balazs Gibizer <gibi@redhat.com> | 2023-01-05 19:32:13 +0100 |
---|---|---|
committer | Balazs Gibizer <gibi@redhat.com> | 2023-01-20 17:17:48 +0100 |
commit | 87c0602537688c3da2291792a98caf9d9faf9d6c (patch) | |
tree | 95a9a8d5230bb54931ff27f419c7513c1254ce09 /nova/scheduler/filters/numa_topology_filter.py | |
parent | 6abbcc5033c86c1503d2e8018687476c16ebf6f2 (diff) | |
download | nova-87c0602537688c3da2291792a98caf9d9faf9d6c.tar.gz |
Factor out a mixin class for candidate aware filters
blueprint: pci-device-tracking-in-placement
Change-Id: Id044131162e582cef41e424aa751e3cd3618ed0c
Diffstat (limited to 'nova/scheduler/filters/numa_topology_filter.py')
-rw-r--r-- | nova/scheduler/filters/numa_topology_filter.py | 40 |
1 files changed, 14 insertions, 26 deletions
diff --git a/nova/scheduler/filters/numa_topology_filter.py b/nova/scheduler/filters/numa_topology_filter.py index 7ec9ca5648..ae50db90e5 100644 --- a/nova/scheduler/filters/numa_topology_filter.py +++ b/nova/scheduler/filters/numa_topology_filter.py @@ -20,7 +20,10 @@ from nova.virt import hardware LOG = logging.getLogger(__name__) -class NUMATopologyFilter(filters.BaseHostFilter): +class NUMATopologyFilter( + filters.BaseHostFilter, + filters.CandidateFilterMixin, +): """Filter on requested NUMA topology.""" # NOTE(sean-k-mooney): In change I0322d872bdff68936033a6f5a54e8296a6fb343 @@ -97,34 +100,19 @@ class NUMATopologyFilter(filters.BaseHostFilter): if network_metadata: limits.network_metadata = network_metadata - good_candidates = [] - for candidate in host_state.allocation_candidates: - LOG.debug( - 'NUMATopologyFilter tries allocation candidate: %s, %s', - candidate, requested_topology - ) - instance_topology = (hardware.numa_fit_instance_to_host( - host_topology, requested_topology, + good_candidates = self.filter_candidates( + host_state, + lambda candidate: hardware.numa_fit_instance_to_host( + host_topology, + requested_topology, limits=limits, pci_requests=pci_requests, pci_stats=host_state.pci_stats, - provider_mapping=candidate['mappings'], - )) - if instance_topology: - LOG.debug( - 'NUMATopologyFilter accepted allocation candidate: %s', - candidate - ) - good_candidates.append(candidate) - else: - LOG.debug( - 'NUMATopologyFilter rejected allocation candidate: %s', - candidate - ) - - host_state.allocation_candidates = good_candidates - - if not host_state.allocation_candidates: + provider_mapping=candidate["mappings"], + ), + ) + + if not good_candidates: LOG.debug("%(host)s, %(node)s fails NUMA topology " "requirements. The instance does not fit on this " "host.", {'host': host_state.host, |