Skip to content

Commit

Permalink
scheduler: Add 'socket' PCI NUMA affinity policy trait
Browse files Browse the repository at this point in the history
Since only Wallaby compute nodes will support the 'socket' PCI NUMA
affinity policy, this patch adds a ResourceRequest translator that adds
a required trait if the value of '(hw_|hw:)pci_numa_affinity_policy' is
'socket'.

The actual trait reporting by the libvirt driver will be added in a
future patch. Until then the 'socket' value remains a hidden no-op.

Implements: blueprint pci-socket-affinity
Change-Id: I908ff07e1107304ca5926cc04d2fdc8fe0da5ed9
  • Loading branch information
notartom authored and stephenfin committed Feb 24, 2021
1 parent be80dfd commit db7517d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lower-constraints.txt
Expand Up @@ -62,7 +62,7 @@ os-brick==3.1.0
os-client-config==1.29.0
os-resource-classes==0.4.0
os-service-types==1.7.0
os-traits==2.4.0
os-traits==2.5.0
os-vif==1.14.0
os-win==4.2.0
os-xenapi==0.3.4
Expand Down
12 changes: 12 additions & 0 deletions nova/scheduler/utils.py
Expand Up @@ -188,6 +188,8 @@ def from_request_spec(

res_req._translate_vtpm_request(request_spec.flavor, image)

res_req._translate_pci_numa_affinity_policy(request_spec.flavor, image)

res_req.strip_zeros()

return res_req
Expand Down Expand Up @@ -351,6 +353,16 @@ def _translate_pinning_policies(self, flavor, image):
'value': trait})
self._add_trait(os_traits.HW_CPU_HYPERTHREADING, trait)

def _translate_pci_numa_affinity_policy(self, flavor, image):
policy = hardware.get_pci_numa_policy_constraint(flavor, image)
# only the socket policy supports a trait
if policy == objects.fields.PCINUMAAffinityPolicy.SOCKET:
trait = os_traits.COMPUTE_SOCKET_PCI_NUMA_AFFINITY
self._add_trait(trait, 'required')
LOG.debug(
"Requiring 'socket' PCI NUMA affinity support via trait %s.",
trait)

@property
def group_policy(self):
return self._group_policy
Expand Down
19 changes: 19 additions & 0 deletions nova/tests/unit/scheduler/test_utils.py
Expand Up @@ -1224,6 +1224,25 @@ def test_resource_request_from_request_spec_with_vpmems(self):
rr = utils.ResourceRequest.from_request_spec(rs)
self.assertResourceRequestsEqual(expected, rr)

def test_resource_request_from_request_spec_with_pci_numa_policy(self):
flavor = objects.Flavor(
vcpus=1, memory_mb=1024, root_gb=10, ephemeral_gb=5, swap=0,
extra_specs={'hw:pci_numa_affinity_policy': 'socket'},
)
expected = FakeResourceRequest()
expected._rg_by_id[None] = objects.RequestGroup(
use_same_provider=False,
required_traits={'COMPUTE_SOCKET_PCI_NUMA_AFFINITY'},
resources={
'VCPU': 1,
'MEMORY_MB': 1024,
'DISK_GB': 15,
},
)
rs = objects.RequestSpec(flavor=flavor, is_bfv=False)
rr = utils.ResourceRequest.from_request_spec(rs)
self.assertResourceRequestsEqual(expected, rr)

def test_resource_request_from_request_spec_with_vtpm_1_2(self):
flavor = objects.Flavor(
vcpus=1, memory_mb=1024, root_gb=10, ephemeral_gb=5, swap=0,
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Expand Up @@ -53,7 +53,7 @@ psutil>=3.2.2 # BSD
oslo.versionedobjects>=1.35.0 # Apache-2.0
os-brick>=3.1.0 # Apache-2.0
os-resource-classes>=0.4.0 # Apache-2.0
os-traits>=2.4.0 # Apache-2.0
os-traits>=2.5.0 # Apache-2.0
os-vif>=1.14.0 # Apache-2.0
os-win>=4.2.0 # Apache-2.0
castellan>=0.16.0 # Apache-2.0
Expand Down

0 comments on commit db7517d

Please sign in to comment.