summaryrefslogtreecommitdiff
path: root/nova/pci
diff options
context:
space:
mode:
authorBalazs Gibizer <gibi@redhat.com>2022-08-17 18:19:15 +0200
committerBalazs Gibizer <gibi@redhat.com>2022-08-25 10:00:10 +0200
commit2b447b7236f95752d00ebcee8c32cfef4850cf5d (patch)
treeef41ec5ed96d70bcf165b57cc869dc189f5f9902 /nova/pci
parent2aeb0a96b77e05172b13b4d1f692ff2b08f10bc9 (diff)
downloadnova-2b447b7236f95752d00ebcee8c32cfef4850cf5d.tar.gz
Trigger reschedule if PCI consumption fail on compute
The PciPassthroughFilter logic checks each InstancePCIRequest individually against the available PCI pools of a given host and given boot request. So it is possible that the scheduler accepts a host that has a single PCI device available even if two devices are requested for a single instance via two separate PCI aliases. Then the PCI claim on the compute detects this but does not stop the boot just logs an ERROR. This results in the instance booted without any PCI device. This patch does two things: 1) changes the PCI claim to fail with an exception and trigger a re-schedule instead of just logging an ERROR. 2) change the PciDeviceStats.support_requests that is called during scheduling to not just filter pools for individual requests but also consume the request from the pool within the scope of a single boot request. The fix in #2) would not be enough alone as two parallel scheduling request could race for a single device on the same host. #1) is the ultimate place where we consume devices under a compute global lock so we need the fix there too. Closes-Bug: #1986838 Change-Id: Iea477be57ae4e95dfc03acc9368f31d4be895343
Diffstat (limited to 'nova/pci')
-rw-r--r--nova/pci/stats.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/nova/pci/stats.py b/nova/pci/stats.py
index ae15cf29ef..3518b95289 100644
--- a/nova/pci/stats.py
+++ b/nova/pci/stats.py
@@ -249,7 +249,7 @@ class PciDeviceStats(object):
"on the compute node semaphore.")
for d in range(len(alloc_devices)):
self.add_device(alloc_devices.pop())
- return None
+ raise exception.PciDeviceRequestFailed(requests=pci_requests)
for pool in pools:
if pool['count'] >= count:
@@ -639,11 +639,22 @@ class PciDeviceStats(object):
corresponds to the ``id`` of host NUMACells, or None.
:returns: Whether this compute node can satisfy the given request.
"""
- # NOTE(yjiang5): this function has high possibility to fail,
- # so no exception should be triggered for performance reason.
- return all(
- self._filter_pools(self.pools, r, numa_cells) for r in requests
- )
+
+ # try to apply the requests on the copy of the stats if it applies
+ # cleanly then we know that the requests is supported. We call apply
+ # only on a copy as we don't want to actually consume resources from
+ # the pool as at this point this is just a test during host filtering.
+ # Later the scheduler will call apply_request to consume on the
+ # selected host. The compute will call consume_request during PCI claim
+ # to consume not just from the pools but also consume PciDevice
+ # objects.
+ stats = copy.deepcopy(self)
+ try:
+ stats.apply_requests(requests, numa_cells)
+ except exception.PciDeviceRequestFailed:
+ return False
+
+ return True
def _apply_request(
self,