Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -842,7 +843,7 @@ def _validate_and_pair_ha(
)
LOG.warning("[node:%s] %s", node.uuid, reason)
node.last_error = reason
Comment thread
nidzrai marked this conversation as resolved.
Resolved
return
raise exception.HardwareInspectionFailure(reason)

LOG.info("[node:%s] HA peer connected: %s", node.uuid, peer_serial)

Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")

Expand Down
Loading