Skip to content

Commit 9750cb4

Browse files
[Mellanox] Redirect ethtool stderr to subprocess for better error log (sonic-net#12038)
- Why I did it ethtool print error logs when EEPROM of a SFP is not available. It prints error like this: INFO pmon#/supervisord: xcvrd Cannot get module EEPROM information: Input/output error INFO pmon#/supervisord: xcvrd Cannot get Module EEPROM data: Invalid argument However, this log does not contain the relevant SFP index which is hard for developer/qa to find the exactly SFP. - How I did it Redirect ethtool stderr to subprocess and log it better - How to verify it Manual test
1 parent c674b3c commit 9750cb4

File tree

1 file changed

+3
-1
lines changed
  • platform/mellanox/mlnx-platform-api/sonic_platform

1 file changed

+3
-1
lines changed

platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,14 +359,16 @@ def _read_eeprom_specific_bytes(self, offset, num_bytes):
359359
try:
360360
output = subprocess.check_output(ethtool_cmd,
361361
shell=True,
362-
universal_newlines=True)
362+
universal_newlines=True,
363+
stderr=subprocess.PIPE)
363364
output_lines = output.splitlines()
364365
first_line_raw = output_lines[0]
365366
if "Offset" in first_line_raw:
366367
for line in output_lines[2:]:
367368
line_split = line.split()
368369
eeprom_raw = eeprom_raw + line_split[1:]
369370
except subprocess.CalledProcessError as e:
371+
logger.log_notice("Failed to get EEPROM data for sfp {}: {}".format(self.index, e.stderr))
370372
return None
371373

372374
eeprom_raw = list(map(lambda h: int(h, base=16), eeprom_raw))

0 commit comments

Comments
 (0)