scheduler: Add 'socket' PCI NUMA affinity policy trait

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
This commit is contained in:
Artom Lifshitz 2021-01-27 10:56:47 -05:00 committed by Stephen Finucane
parent be80dfdc71
commit db7517d5a8
4 changed files with 33 additions and 2 deletions

View File

@ -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

View File

@ -188,6 +188,8 @@ class ResourceRequest(object):
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
@ -351,6 +353,16 @@ class ResourceRequest(object):
'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

View File

@ -1224,6 +1224,25 @@ class TestUtils(TestUtilsBase):
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,

View File

@ -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