Skip to content

Commit 8a7e51a

Browse files
authored
Merge pull request #26 from az-pz/ariz/catch-xcvrd-exception-when-eeprom-read-is-unsuccessful-202405
(202405) Catch the xcvrd exception returned by get_transceiver_info
2 parents b1edb96 + edd2af8 commit 8a7e51a

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

sonic-xcvrd/tests/test_xcvrd.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3101,6 +3101,9 @@ def test_wrapper_get_transceiver_info(self, mock_sfputil, mock_chassis):
31013101
mock_sfputil.get_transceiver_info_dict = MagicMock(return_value=False)
31023102
assert not _wrapper_get_transceiver_info(1)
31033103

3104+
mock_chassis.get_sfp = MagicMock(side_effect=Exception)
3105+
assert not _wrapper_get_transceiver_info(1)
3106+
31043107
@patch('xcvrd.xcvrd.platform_chassis')
31053108
@patch('xcvrd.xcvrd.platform_sfputil')
31063109
def test_wrapper_get_transceiver_firmware_info(self, mock_sfputil, mock_chassis):

sonic-xcvrd/xcvrd/xcvrd.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,10 @@ def _wrapper_get_transceiver_info(physical_port):
268268
return platform_chassis.get_sfp(physical_port).get_transceiver_info()
269269
except NotImplementedError:
270270
pass
271+
except Exception as e:
272+
helper_logger.log_error("Failed to get transceiver info for physical port {}. Exception: {}".format(physical_port, e))
273+
log_exception_traceback()
274+
return None
271275
return platform_sfputil.get_transceiver_info_dict(physical_port)
272276

273277
def _wrapper_get_transceiver_firmware_info(physical_port):

0 commit comments

Comments
 (0)