diff --git a/python/ironic-understack/ironic_understack/drivers/panos_inspect.py b/python/ironic-understack/ironic_understack/drivers/panos_inspect.py index 7bddfb21f..584285e97 100644 --- a/python/ironic-understack/ironic_understack/drivers/panos_inspect.py +++ b/python/ironic-understack/ironic_understack/drivers/panos_inspect.py @@ -798,7 +798,8 @@ def _validate_and_pair_ha( The enroll-fw workflow will read ha_operational from both devices and decide whether to promote. - :raises: Logs warnings but does not raise - allows inspection to complete + :raises: HardwareInspectionFailure for a cabling fault (wrong peer, same + switch). Other failures are recorded and inspection completes. """ # Default to False - only set True if all checks pass extra["ha_operational"] = False @@ -842,7 +843,7 @@ def _validate_and_pair_ha( ) LOG.warning("[node:%s] %s", node.uuid, reason) node.last_error = reason - return + raise exception.HardwareInspectionFailure(reason) LOG.info("[node:%s] HA peer connected: %s", node.uuid, peer_serial) @@ -983,6 +984,8 @@ def _validate_and_pair_ha( # Clear any previous failure reason node.last_error = None + except exception.HardwareInspectionFailure: + raise # a cabling fault stops inspection except Exception as e: LOG.exception( "[node:%s] HA validation/pairing failed: %s", diff --git a/python/ironic-understack/ironic_understack/tests/test_panos_inspect.py b/python/ironic-understack/ironic_understack/tests/test_panos_inspect.py index b8ca95c8d..65d36807c 100644 --- a/python/ironic-understack/ironic_understack/tests/test_panos_inspect.py +++ b/python/ironic-understack/ironic_understack/tests/test_panos_inspect.py @@ -221,12 +221,10 @@ def test_a_healthy_pair_is_operational(mocker, task): ("change", "reason"), [ ({"peer": ("S2", "down")}, "HA peer connection not up"), - ({"peer": ("S9", "up")}, "HA peer serial mismatch"), ({"mate_peer": ("S9", "up")}, "Mate peer serial mismatch"), ({"mate_peer": ("S1", "down")}, "Mate peer connection not up"), - ({"mate_switch": "leaf-1"}, "same switch"), ], - ids=["peer-down", "wrong-peer", "mate-sees-other", "mate-down", "same-switch"], + ids=["peer-down", "mate-sees-other", "mate-down"], ) def test_an_unhealthy_pair_is_not_operational(mocker, task, change, reason): device = _ha_pair(mocker, task, **change) @@ -237,6 +235,25 @@ def test_an_unhealthy_pair_is_not_operational(mocker, task, change, reason): assert reason in node.last_error +@pytest.mark.parametrize( + ("change", "reason"), + [ + ({"peer": ("S9", "up")}, "HA peer serial mismatch"), + ({"mate_switch": "leaf-1"}, "same switch"), + ], + ids=["wrong-peer", "same-switch"], +) +def test_a_cabling_fault_fails_inspection(mocker, task, change, reason): + device = _ha_pair(mocker, task, **change) + + with pytest.raises(exception.HardwareInspectionFailure, match=reason): + _validate_ha(task, device) + + assert task.node.extra["ha_operational"] is False + assert reason in task.node.last_error + task.node.save.assert_called_once() + + def test_a_local_link_down_never_contacts_the_mate(mocker, task): device = _ha_pair(mocker, task, hsci="down")