fix: tolerate dead ipmitool EOF when deactivating SoL session - #48
Open
KarolinaPomian wants to merge 2 commits into
Open
fix: tolerate dead ipmitool EOF when deactivating SoL session#48KarolinaPomian wants to merge 2 commits into
KarolinaPomian wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
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 fromsol -das “already deactivated” and wrapspexpect.TIMEOUTas aSolException._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 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 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.", | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: