Skip to content

Commit ccc8c58

Browse files
Junchao-Mellanoxjudyjoseph
authored andcommitted
[Mellanox] Adjust PSU voltage WA (#10619)
- Why I did it InvalidPsuVolWA.run might raise exception if user power off PSU when it is running. This exception is not caught and will be raised to psud which causes psud failed to update PSU data to DB. - How I did it 1. Change the log level when WA does not work. This could happen when user power off PSU, hence changing the log level from error to warning is better 2. Change the wait time from 5 to 1 to avoid introduce too much delay in psud. 1 second is usually enough per my test 3. Give a default return value for function get_voltage_low_threshold and get_voltage_high_threshold to avoid exception reach to psud - How to verify it Manual test. Run sonic-mgmt regression
1 parent 0dff46b commit ccc8c58

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ def get_temperature_high_threshold(self):
397397

398398
return None
399399

400+
@utils.default_return(None)
400401
def get_voltage_high_threshold(self):
401402
"""
402403
Retrieves the high threshold PSU voltage output
@@ -414,10 +415,12 @@ def get_voltage_high_threshold(self):
414415
if 'max' in capability:
415416
max_voltage = utils.read_int_from_file(self.psu_voltage_max, log_func=logger.log_info)
416417
max_voltage = InvalidPsuVolWA.run(self, max_voltage, self.psu_voltage_max)
417-
return float(max_voltage) / 1000
418+
if max_voltage:
419+
return float(max_voltage) / 1000
418420

419421
return None
420422

423+
@utils.default_return(None)
421424
def get_voltage_low_threshold(self):
422425
"""
423426
Retrieves the low threshold PSU voltage output
@@ -435,7 +438,8 @@ def get_voltage_low_threshold(self):
435438
if 'min' in capability:
436439
min_voltage = utils.read_int_from_file(self.psu_voltage_min, log_func=logger.log_info)
437440
min_voltage = InvalidPsuVolWA.run(self, min_voltage, self.psu_voltage_min)
438-
return float(min_voltage) / 1000
441+
if min_voltage:
442+
return float(min_voltage) / 1000
439443

440444
return None
441445

@@ -471,7 +475,7 @@ class InvalidPsuVolWA:
471475
EXPECT_PLATFORMS = ['x86_64-mlnx_msn3700-r0', 'x86_64-mlnx_msn3700c-r0', 'x86_64-mlnx_msn3800-r0', 'x86_64-mlnx_msn4600c-r0']
472476
MFR_FIELD = 'MFR_NAME'
473477
CAPACITY_FIELD = 'CAPACITY'
474-
WAIT_TIME = 5
478+
WAIT_TIME = 1
475479

476480
@classmethod
477481
def run(cls, psu, threshold_value, threshold_file):
@@ -499,8 +503,8 @@ def run(cls, psu, threshold_value, threshold_file):
499503
logger.log_warning('PSU {} threshold file {} value {}, but its capacity is {}'.format(psu.index, threshold_file, threshold_value, capacity))
500504
return threshold_value
501505

502-
# Run a sensor -s command to triger hardware to get the real threashold value
503-
utils.run_command('sensor -s')
506+
# Run a sensors -s command to triger hardware to get the real threashold value
507+
utils.run_command('sensors -s')
504508

505509
# Wait for the threshold value change
506510
return cls.wait_set_done(threshold_file)
@@ -516,5 +520,7 @@ def wait_set_done(cls, threshold_file):
516520
wait_time -= 1
517521
time.sleep(1)
518522

519-
logger.log_error('sensor -s does not recover PSU threshold sensor after {} seconds'.format(cls.WAIT_TIME))
523+
# It is enough to use warning here because user might power off/on the PSU which may cause threshold_file
524+
# does not exist
525+
logger.log_warning('sensors -s does not recover PSU threshold sensor after {} seconds'.format(cls.WAIT_TIME))
520526
return None

platform/mellanox/mlnx-platform-api/tests/test_psu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,4 @@ def get_entry_value(key):
152152
# Normal
153153
vpd_info[InvalidPsuVolWA.CAPACITY_FIELD] = InvalidPsuVolWA.EXPECT_CAPACITY
154154
assert InvalidPsuVolWA.run(psu, InvalidPsuVolWA.INVALID_VOLTAGE_VALUE, '') == 9999
155-
mock_run_command.assert_called_with('sensor -s')
155+
mock_run_command.assert_called_with('sensors -s')

0 commit comments

Comments
 (0)