[Mellanox] Redirect ethtool stderr to subprocess for better error log (#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
This commit is contained in:
parent
c674b3c634
commit
9750cb48c6
@ -359,7 +359,8 @@ class SFP(NvidiaSFPCommon):
|
|||||||
try:
|
try:
|
||||||
output = subprocess.check_output(ethtool_cmd,
|
output = subprocess.check_output(ethtool_cmd,
|
||||||
shell=True,
|
shell=True,
|
||||||
universal_newlines=True)
|
universal_newlines=True,
|
||||||
|
stderr=subprocess.PIPE)
|
||||||
output_lines = output.splitlines()
|
output_lines = output.splitlines()
|
||||||
first_line_raw = output_lines[0]
|
first_line_raw = output_lines[0]
|
||||||
if "Offset" in first_line_raw:
|
if "Offset" in first_line_raw:
|
||||||
@ -367,6 +368,7 @@ class SFP(NvidiaSFPCommon):
|
|||||||
line_split = line.split()
|
line_split = line.split()
|
||||||
eeprom_raw = eeprom_raw + line_split[1:]
|
eeprom_raw = eeprom_raw + line_split[1:]
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
|
logger.log_notice("Failed to get EEPROM data for sfp {}: {}".format(self.index, e.stderr))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
eeprom_raw = list(map(lambda h: int(h, base=16), eeprom_raw))
|
eeprom_raw = list(map(lambda h: int(h, base=16), eeprom_raw))
|
||||||
|
Reference in New Issue
Block a user