From 2a55e8b359c7d1b9f7e74546c0e38c550fcf3714 Mon Sep 17 00:00:00 2001 From: Stephen Sun <5379172+stephenxs@users.noreply.github.com> Date: Sat, 15 Jul 2023 06:10:29 +0800 Subject: [PATCH] Update the description message of PSU power threshold checking in system health (#15289) - Why I did it Adjust PSU power threshold logic in system health. - How I did it Update the description message in PSU power threshold checking power of PSU x (xx w) exceeds threshold (xx w) => System power exceeds xx threshold (xx w) - How to verify it Manual test and unit test --- src/system-health/health_checker/hardware_checker.py | 5 +++-- src/system-health/tests/test_system_health.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/system-health/health_checker/hardware_checker.py b/src/system-health/health_checker/hardware_checker.py index 992bdbab545c..8f7a11f55c2e 100644 --- a/src/system-health/health_checker/hardware_checker.py +++ b/src/system-health/health_checker/hardware_checker.py @@ -257,12 +257,13 @@ def _check_psu_status(self, config): if not self._ignore_check(config.ignore_devices, 'psu', name, 'power_threshold'): power_overload = data_dict.get('power_overload', None) if power_overload == 'True': + try: power = data_dict['power'] power_critical_threshold = data_dict['power_critical_threshold'] - self.set_object_not_ok('PSU', name, 'power of {} ({}w) exceeds threshold ({}w)'.format(name, power, power_critical_threshold)) + self.set_object_not_ok('PSU', name, 'System power exceeds threshold ({}w)'.format(power_critical_threshold)) except KeyError: - self.set_object_not_ok('PSU', name, 'power of {} exceeds threshold but power or power_critical_threshold is invalid'.format(name)) + self.set_object_not_ok('PSU', name, 'System power exceeds threshold but power_critical_threshold is invalid') continue self.set_object_ok('PSU', name) diff --git a/src/system-health/tests/test_system_health.py b/src/system-health/tests/test_system_health.py index 10bdf3d7d9f8..2d46140e2ff6 100644 --- a/src/system-health/tests/test_system_health.py +++ b/src/system-health/tests/test_system_health.py @@ -444,12 +444,12 @@ def test_hardware_checker(): assert checker._info['PSU 5'][HealthChecker.INFO_FIELD_OBJECT_STATUS] == HealthChecker.STATUS_NOT_OK assert 'PSU 6' in checker._info - assert checker._info['PSU 6'][HealthChecker.INFO_FIELD_OBJECT_MSG] == 'power of PSU 6 (101.0w) exceeds threshold (100.0w)' + assert checker._info['PSU 6'][HealthChecker.INFO_FIELD_OBJECT_MSG] == 'System power exceeds threshold (100.0w)' assert checker._info['PSU 6'][HealthChecker.INFO_FIELD_OBJECT_STATUS] == HealthChecker.STATUS_NOT_OK assert 'PSU 7' in checker._info assert checker._info['PSU 7'][HealthChecker.INFO_FIELD_OBJECT_STATUS] == HealthChecker.STATUS_NOT_OK - assert checker._info['PSU 7'][HealthChecker.INFO_FIELD_OBJECT_MSG] == 'power of PSU 7 exceeds threshold but power or power_critical_threshold is invalid' + assert checker._info['PSU 7'][HealthChecker.INFO_FIELD_OBJECT_MSG] == 'System power exceeds threshold but power_critical_threshold is invalid' def test_config():