From b9ed90bc8d8b311007983cad869238a1ea0f3691 Mon Sep 17 00:00:00 2001 From: Nidhi Rai Date: Tue, 24 Nov 2026 23:22:54 +0530 Subject: [PATCH] fix(enroll-fw): inspect a manageable HA mate again before providing it A failed inspection keeps the node's old ports, and node manage returns it to manageable. The pair checks then passed on those old ports and provided a mate with a missing data link. --- .../tests/test_enroll_fw.py | 15 ++++++++----- .../understack_workflows/main/enroll_fw.py | 22 ++++++++++++++----- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/python/understack-workflows/tests/test_enroll_fw.py b/python/understack-workflows/tests/test_enroll_fw.py index d2c672613..aacb39292 100644 --- a/python/understack-workflows/tests/test_enroll_fw.py +++ b/python/understack-workflows/tests/test_enroll_fw.py @@ -737,7 +737,14 @@ def _pair(this_role, *, this=None, mate=None, traits=None, ports=None): def _promote(mocker, ironic, ha_role): - transition = mocker.patch.object(enroll_fw.ironic_node, "transition") + def transition(node, target_state, **_): + # A healthy mate passes its own HA check when inspected again. + if (node.uuid, target_state) == ("fw-mate", "inspect"): + node.extra["ha_operational"] = True + + transition = mocker.patch.object( + enroll_fw.ironic_node, "transition", side_effect=transition + ) enroll_fw._inspect_and_provide(ironic, "fw-this", PHYSNET, ha_role) return [(c.args[0].uuid, c.kwargs["target_state"]) for c in transition.mock_calls] @@ -774,12 +781,10 @@ def test_ha_pair_is_linked_then_both_are_provided( steps = _promote(mocker, ironic, this_role) # One update links the secondary with power coupling off, before provide. - assert ironic.updates == [ - (secondary, _link_to(primary)), - ("fw-mate", SET_HA_OPERATIONAL), - ] + assert ironic.updates == [(secondary, _link_to(primary))] assert steps == [ ("fw-this", "inspect"), + ("fw-mate", "inspect"), ("fw-mate", "provide"), ("fw-this", "provide"), ] diff --git a/python/understack-workflows/understack_workflows/main/enroll_fw.py b/python/understack-workflows/understack_workflows/main/enroll_fw.py index 7d4e1444e..8d2dcf1aa 100644 --- a/python/understack-workflows/understack_workflows/main/enroll_fw.py +++ b/python/understack-workflows/understack_workflows/main/enroll_fw.py @@ -236,8 +236,7 @@ def _inspect_and_provide( (extra.ha_operational); then both units are linked and provided together. """ node = client.get_node(node_uuid) - logger.info("[node:%s] Inspecting to discover and check the ports", node.uuid) - ironic_node.transition(node, target_state="inspect", expected_state="manageable") + _inspect(node) role_ports = _checked_role_ports(client, node) _set_physical_network(client, node, role_ports.values(), physical_network) @@ -295,11 +294,18 @@ def _promote_ha_pair( """Link a confirmed HA pair, and provide both units. This node's inspection checked both boxes, so the mate's ha_operational - is set from here. Every check runs before the first write, so a failed - check leaves both units as they were. The mate is provided first. An - active mate (carrying a router) only gets its metadata updated. + is set from here. A manageable mate is inspected again first. Every + check runs before the first write, so a failed check leaves both units + as they were. The mate is provided first. An active mate (carrying a + router) only gets its metadata updated. """ mate = _find_mate(client, node) + if mate.provision_state == "manageable": + # Inspection rebuilds its HA, so its own check must pass. + _inspect(mate) + mate = client.get_node(mate.uuid) + if _extra(mate).get("ha_operational") is not True: + raise _left_manageable(node, f"The mate's HA check: {mate.last_error}") if ha_role == "primary": primary, secondary, mate_role = node, mate, "secondary" else: @@ -490,6 +496,12 @@ def _add(path: str, value) -> dict: return {"op": "add", "path": path, "value": value} +def _inspect(node) -> None: + """Inspect a manageable node.""" + logger.info("[node:%s] Inspecting to discover and check the ports", node.uuid) + ironic_node.transition(node, target_state="inspect", expected_state="manageable") + + def _provide(node) -> None: """Make a manageable node available.""" ironic_node.transition(node, target_state="provide", expected_state="available")