Skip to content

fix: tolerate dead ipmitool EOF when deactivating SoL session - #48

Open
KarolinaPomian wants to merge 2 commits into
intel:mainfrom
KarolinaPomian:kpomian/fix-sol-deactivate-eof
Open

fix: tolerate dead ipmitool EOF when deactivating SoL session#48
KarolinaPomian wants to merge 2 commits into
intel:mainfrom
KarolinaPomian:kpomian/fix-sol-deactivate-eof

Conversation

@KarolinaPomian

Copy link
Copy Markdown

SolConnection._deactivate_sol_session raised an uncaught pexpect.exceptions.EOF when ipmitool exits without a live SoL session to close (e.g. BMC already dropped it), instead of treating that as already-deactivated. This also skipped the retry_count logic entirely in _establish_connection, since the deactivate call was never wrapped in try/except.

Changes:

  • Treat pexpect.EOF from ipmitool sol -d as already-deactivated (not fatal).
  • Real pexpect.TIMEOUT still raises SolException.
  • _establish_connection now retries retry_count times if deactivation fails, instead of propagating immediately with zero retries.
  • Added unit tests for the EOF-tolerant path, the TIMEOUT-raises path, and the retry-on-deactivate-failure path.

Copilot AI lite review requested due to automatic review settings August 27, 2026 11:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves robustness of the IPMI Serial-over-LAN (SoL) connection flow by handling edge cases where ipmitool/ipmiutil sol -d exits unexpectedly and by ensuring _establish_connection() actually uses its retry budget when deactivation fails.

Changes:

  • _deactivate_sol_session() now treats an EOF from sol -d as “already deactivated” and wraps pexpect.TIMEOUT as a SolException.
  • _establish_connection() now retries when deactivation fails, instead of failing immediately.
  • Added unit tests covering EOF-tolerant deactivation, TIMEOUT error behavior, and retry-on-deactivate-failure.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
mfd_connect/sol.py Adds deactivation error handling and integrates deactivation failures into the connection retry loop.
tests/unit/test_mfd_connect/test_sol.py Adds unit tests for EOF tolerance, TIMEOUT raising, and retry behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread mfd_connect/sol.py
Comment on lines +350 to +351
except pexpect.TIMEOUT as e:
raise SolException(f"Timed out while deactivating previous SoL session! \n{e}") from e
Comment thread mfd_connect/sol.py
Comment on lines 343 to +357
correct_responses = [
"completed successfully",
"Invalid Session Handle or Empty Buffer",
pexpect.EOF,
]
expect_index = process.expect(correct_responses)
if expect_index > len(correct_responses) - 1:
raise SolException(f"Fatal Error while deactivating previous SoL session! \n{process.before}")
try:
expect_index = process.expect(correct_responses)
except pexpect.TIMEOUT as e:
raise SolException(f"Timed out while deactivating previous SoL session! \n{e}") from e
if expect_index == len(correct_responses) - 1:
# ipmitool already exited (e.g. no live SoL session to close) - treat as already deactivated.
logger.log(
level=log_levels.MODULE_DEBUG,
msg="ipmitool exited without a response while deactivating SoL session, assuming already closed.",
)
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.

2 participants