summaryrefslogtreecommitdiff
path: root/nova/compute
diff options
context:
space:
mode:
authorBalazs Gibizer <gibi@redhat.com>2022-07-20 10:51:56 +0200
committerBalazs Gibizer <gibi@redhat.com>2022-08-25 10:00:10 +0200
commit3e68e19d6ebaf12cb88c7dcd9f61c342d2c8d12d (patch)
treef8d3ca89673dbd2703056b7f89ed16c49c2805bc /nova/compute
parent5860541bd7ba7978d3080b2a7c5515a9db534c9b (diff)
downloadnova-3e68e19d6ebaf12cb88c7dcd9f61c342d2c8d12d.tar.gz
Stop if tracking is disable after it was enabled before
We don't support enabling and then later disabling [pci]report_in_placement. This patch adds a check that kills the nova-compute service is such situation. The implementation rely on an extra trait COMPUTE_MANAGED_PCI_DEVICE that is added to every PCI RP automatically. Note that we cannot use the existing OWNER_NOVA standard trait as that will be exists on other RPs in RP three. Also we cannot use the naming scheme of the PCI RPs as cyborg is free to use the same scheme and also nova might want to use that for VGPUs / MDEVs in the future. Depends-On: https://review.opendev.org/c/openstack/os-traits/+/850538 blueprint: pci-device-tracking-in-placement Change-Id: I6e68d7754cee51525894c14a74a554d82a648d8d
Diffstat (limited to 'nova/compute')
-rw-r--r--nova/compute/pci_placement_translator.py29
1 files changed, 26 insertions, 3 deletions
diff --git a/nova/compute/pci_placement_translator.py b/nova/compute/pci_placement_translator.py
index c97647be47..078a0b354f 100644
--- a/nova/compute/pci_placement_translator.py
+++ b/nova/compute/pci_placement_translator.py
@@ -73,10 +73,12 @@ def _get_traits_for_dev(
# traits is a comma separated list of placement trait names
traits_str = dev_spec_tags.get("traits")
if not traits_str:
- return set()
+ return {os_traits.COMPUTE_MANAGED_PCI_DEVICE}
traits = traits_str.split(',')
- return set(_normalize_traits(traits))
+ return set(_normalize_traits(traits)) | {
+ os_traits.COMPUTE_MANAGED_PCI_DEVICE
+ }
def _get_rc_for_dev(
@@ -211,7 +213,7 @@ class PciResourceProvider:
if self.devs:
return (
f"RP({self.name}, {self.resource_class}={len(self.devs)}, "
- f"traits={','.join(self.traits or set())})"
+ f"traits={','.join(sorted(self.traits or set()))})"
)
else:
return f"RP({self.name}, <EMPTY>)"
@@ -357,6 +359,26 @@ def ensure_no_dev_spec_with_devname(dev_specs: ty.List[devspec.PciDeviceSpec]):
raise exception.PlacementPciException(error=msg)
+def ensure_tracking_was_not_enabled_before(
+ provider_tree: provider_tree.ProviderTree
+) -> None:
+ # If placement tracking was enabled before then we do not support
+ # disabling it later. To check for that we can look for RPs with
+ # the COMPUTE_MANAGED_PCI_DEVICE trait. If any then we raise to
+ # kill the service
+ for rp_uuid in provider_tree.get_provider_uuids():
+ if (
+ os_traits.COMPUTE_MANAGED_PCI_DEVICE
+ in provider_tree.data(rp_uuid).traits
+ ):
+ msg = _(
+ "The [pci]report_in_placement is False but it was enabled "
+ "before on this compute. Nova does not support disabling "
+ "it after it is enabled."
+ )
+ raise exception.PlacementPciException(error=msg)
+
+
def update_provider_tree_for_pci(
provider_tree: provider_tree.ProviderTree,
nodename: str,
@@ -393,6 +415,7 @@ def update_provider_tree_for_pci(
}
"""
if not _is_placement_tracking_enabled():
+ ensure_tracking_was_not_enabled_before(provider_tree)
# If tracking is not enabled we just return without touching anything
return False