Catch the xcvrd exception returned by get_transceiver_info#632
Conversation
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Pull Request Overview
This PR updates the transceiver info retrieval logic to catch exceptions from get_transceiver_info in order to prevent the xcvrd process from crashing on EEPROM read failures.
- Added an exception handler to log errors and traceback before returning None
- Updated tests to simulate an exception scenario during transceiver info retrieval
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| sonic-xcvrd/xcvrd/xcvrd.py | Added exception handling and logging in get_transceiver_info wrapper |
| sonic-xcvrd/tests/test_xcvrd.py | Updated test cases to simulate exception scenarios |
sonic-xcvrd/xcvrd/xcvrd.py
Outdated
| except NotImplementedError: | ||
| pass | ||
| except Exception: | ||
| helper_logger.log_error("Failed to get transceiver info for physical port {}".format(physical_port)) |
There was a problem hiding this comment.
@az-pz Can you print it out exception in the error message?
mihirpat1
left a comment
There was a problem hiding this comment.
Please attach the traceback as observed in the logs during the test.
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
@mihirpat1 , Addressed your comments. |
|
Cherry-pick PR to 202505: #636 |
|
Hey @az-pz, looks like there's a conflict with the msft-202405 branch, could you please manually resolve it? Thanks! |
|
Cherry-pick PR to msft-202412: Azure/sonic-platform-daemons.msft#25 |
|
@cyw233 , here's the manual cherry pick for 202405: Azure/sonic-platform-daemons.msft#26 |
Description
Catch the xcvrd exception returned by get_transceiver_info
Motivation and Context
xcvrd is repeatedly crashing if get_transceiver_info returns an exception when there's an EEPROM read failure.
The solution is to catch the exception and return None so that the port can be shown as Not Ready.
How Has This Been Tested?
Generated an exception inside the xcvrd for a particular port and checked the xcvrd process status. It wasn't crashing anymore.
Here's the traceback in the log as a result when
/root/testfile has11:xcvrddoesn't crash as a result of this exception.Additional Information (Optional)