diff --git a/components/ironic/values.yaml b/components/ironic/values.yaml index 9fe31b8d6..236dea2fe 100644 --- a/components/ironic/values.yaml +++ b/components/ironic/values.yaml @@ -92,7 +92,7 @@ conf: hooks: "ramdisk-error,validate-interfaces,architecture,pci-devices,validate-interfaces,parse-lldp,resource-class,update-baremetal-port" redfish: # Redfish inspection hooks run after inspecting out-of-band using the BMC: - inspection_hooks: "validate-interfaces,ports,port-bios-name,architecture,pci-devices" + inspection_hooks: "validate-interfaces,ports,port-bios-name,architecture,pci-devices,resource-class" add_ports: "all" # enable sensors and metrics for redfish metrics - https://docs.openstack.org/ironic/latest/admin/drivers/redfish/metrics.html sensor_data: diff --git a/python/ironic-understack/ironic_understack/resource_class.py b/python/ironic-understack/ironic_understack/resource_class.py index ca180ddaa..03b6dd9f1 100644 --- a/python/ironic-understack/ironic_understack/resource_class.py +++ b/python/ironic-understack/ironic_understack/resource_class.py @@ -25,6 +25,9 @@ class ResourceClassHook(base.InspectionHook): def __call__(self, task, inventory, plugin_data): """Update node resource_class with matched resource class.""" + # clear the existing resource_class + task.node.resource_class = None + try: memory_mb = inventory["memory"]["physical_mb"] disk_size_gb = int(int(inventory["disks"][0]["size"]) / 10**9) @@ -60,7 +63,6 @@ def __call__(self, task, inventory, plugin_data): task.node.uuid, ) task.node.resource_class = resource_class_name - task.node.save() except (KeyError, ValueError, TypeError): msg = ( f"Inventory has missing hardware information for node {task.node.uuid}." @@ -73,6 +75,9 @@ def __call__(self, task, inventory, plugin_data): msg = f"No matching resource class found for {task.node.uuid}" LOG.error(msg) + # always save so that we clear it if we failed to find a match + task.node.save() + def classify(self, machine): matcher = Matcher(device_types=DEVICE_TYPES) match_result = matcher.match(machine)