Skip to content

fix(pssh): retry once with a fresh client on SessionError - #317

Open
speriaswamy-amd wants to merge 3 commits into
speriaswamy/xdit-03-mi350-detectionfrom
speriaswamy/xdit-04-pssh-session-retry
Open

fix(pssh): retry once with a fresh client on SessionError#317
speriaswamy-amd wants to merge 3 commits into
speriaswamy/xdit-03-mi350-detectionfrom
speriaswamy/xdit-04-pssh-session-retry

Conversation

@speriaswamy-amd

Copy link
Copy Markdown
Contributor

Part 4 of 12 in a stack that replaces #184. Base: #316.

Why

Long-running suites reuse a single ParallelSSHClient for the whole module. If the underlying session goes stale — common after a benchmark step that leaves the connection idle for tens of minutes — the next run_command raises SessionError and the test fails on a trivial follow-up command rather than on anything it was validating.

What changed

  • _recreate_parallel_client() — the client-construction block lifted out of __init__ verbatim; __init__ now calls it, so there is one construction path.
  • _run_command_with_session_retry() — logs, rebuilds the client, retries once. A second failure propagates unchanged, so a genuinely broken host still fails fast.
  • exec() and exec_cmd_list() route their run_command calls through it.

Tests

The two setUp methods move from a decorator-scoped @patch to patcher.start() + addCleanup, because the retry constructs a client during the test body, not just during setUp. New coverage: retry-then-succeed (with and without a timeout) and retry-then-fail, on both exec paths.

Long-running suites reuse a single ParallelSSHClient for the whole module. If
the underlying session goes stale — common after a benchmark step that keeps
the connection idle for tens of minutes — the next run_command raises
SessionError and the test fails on a trivial follow-up command rather than on
anything it was actually validating.

exec() and exec_cmd_list() now route through _run_command_with_session_retry,
which logs, rebuilds the client via the extracted _recreate_parallel_client,
and retries exactly once. A second failure propagates unchanged, so a genuinely
broken host still fails fast.

_recreate_parallel_client is the client-construction block lifted out of
__init__ verbatim; __init__ now calls it, so there is one construction path.

Tests: the two setUp methods move from a decorator-scoped patch to
patcher.start()/addCleanup, because the retry constructs a client during the
test body, not just during setUp. Adds coverage for retry-then-succeed (with
and without a timeout) and retry-then-fail on both exec paths.

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant