Fix error log while creating PSU thermal object (#17789)
- Why I did it If a PSU is not present, there could be error log while restarting psud or thermalctld: Jan 8 17:15:52.689616 sonic ERR pmon#psud: Thermal sysfs /run/hw-management/thermal/psu2_temp1_max does not exist Jan 8 17:15:57.747723 sonic ERR pmon#thermalctld: Thermal sysfs /run/hw-management/thermal/psu2_temp1 does not exist - How I did it if a PSU is not present, we should not check the PSU temperature sysfs.
This commit is contained in:
parent
da0f4ace7a
commit
91d77fe7ae
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES.
|
# Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES.
|
||||||
# Apache-2.0
|
# Apache-2.0
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -220,15 +220,15 @@ def create_indexable_thermal(rule, index, sysfs_folder, position, presence_cb=No
|
|||||||
name = rule['name'].format(index)
|
name = rule['name'].format(index)
|
||||||
sysfs_folder = rule.get('sysfs_folder', sysfs_folder)
|
sysfs_folder = rule.get('sysfs_folder', sysfs_folder)
|
||||||
temp_file = os.path.join(sysfs_folder, rule['temperature'].format(index))
|
temp_file = os.path.join(sysfs_folder, rule['temperature'].format(index))
|
||||||
_check_thermal_sysfs_existence(temp_file)
|
_check_thermal_sysfs_existence(temp_file, presence_cb)
|
||||||
if 'high_threshold' in rule:
|
if 'high_threshold' in rule:
|
||||||
high_th_file = os.path.join(sysfs_folder, rule['high_threshold'].format(index))
|
high_th_file = os.path.join(sysfs_folder, rule['high_threshold'].format(index))
|
||||||
_check_thermal_sysfs_existence(high_th_file)
|
_check_thermal_sysfs_existence(high_th_file, presence_cb)
|
||||||
else:
|
else:
|
||||||
high_th_file = None
|
high_th_file = None
|
||||||
if 'high_critical_threshold' in rule:
|
if 'high_critical_threshold' in rule:
|
||||||
high_crit_th_file = os.path.join(sysfs_folder, rule['high_critical_threshold'].format(index))
|
high_crit_th_file = os.path.join(sysfs_folder, rule['high_critical_threshold'].format(index))
|
||||||
_check_thermal_sysfs_existence(high_crit_th_file)
|
_check_thermal_sysfs_existence(high_crit_th_file, presence_cb)
|
||||||
else:
|
else:
|
||||||
high_crit_th_file = None
|
high_crit_th_file = None
|
||||||
high_th_default = rule.get('high_threshold_default')
|
high_th_default = rule.get('high_threshold_default')
|
||||||
@ -253,15 +253,15 @@ def create_single_thermal(rule, sysfs_folder, position, presence_cb=None):
|
|||||||
|
|
||||||
sysfs_folder = rule.get('sysfs_folder', sysfs_folder)
|
sysfs_folder = rule.get('sysfs_folder', sysfs_folder)
|
||||||
temp_file = os.path.join(sysfs_folder, temp_file)
|
temp_file = os.path.join(sysfs_folder, temp_file)
|
||||||
_check_thermal_sysfs_existence(temp_file)
|
_check_thermal_sysfs_existence(temp_file, presence_cb)
|
||||||
if 'high_threshold' in rule:
|
if 'high_threshold' in rule:
|
||||||
high_th_file = os.path.join(sysfs_folder, rule['high_threshold'])
|
high_th_file = os.path.join(sysfs_folder, rule['high_threshold'])
|
||||||
_check_thermal_sysfs_existence(high_th_file)
|
_check_thermal_sysfs_existence(high_th_file, presence_cb)
|
||||||
else:
|
else:
|
||||||
high_th_file = None
|
high_th_file = None
|
||||||
if 'high_critical_threshold' in rule:
|
if 'high_critical_threshold' in rule:
|
||||||
high_crit_th_file = os.path.join(sysfs_folder, rule['high_critical_threshold'])
|
high_crit_th_file = os.path.join(sysfs_folder, rule['high_critical_threshold'])
|
||||||
_check_thermal_sysfs_existence(high_crit_th_file)
|
_check_thermal_sysfs_existence(high_crit_th_file, presence_cb)
|
||||||
else:
|
else:
|
||||||
high_crit_th_file = None
|
high_crit_th_file = None
|
||||||
high_th_default = rule.get('high_threshold_default')
|
high_th_default = rule.get('high_threshold_default')
|
||||||
@ -274,7 +274,11 @@ def create_single_thermal(rule, sysfs_folder, position, presence_cb=None):
|
|||||||
return RemovableThermal(name, temp_file, high_th_file, high_crit_th_file, high_th_default, high_crit_th_default, scale, position, presence_cb)
|
return RemovableThermal(name, temp_file, high_th_file, high_crit_th_file, high_th_default, high_crit_th_default, scale, position, presence_cb)
|
||||||
|
|
||||||
|
|
||||||
def _check_thermal_sysfs_existence(file_path):
|
def _check_thermal_sysfs_existence(file_path, presence_cb):
|
||||||
|
if presence_cb:
|
||||||
|
status, _ = presence_cb()
|
||||||
|
if not status:
|
||||||
|
return
|
||||||
if not os.path.exists(file_path):
|
if not os.path.exists(file_path):
|
||||||
logger.log_error('Thermal sysfs {} does not exist'.format(file_path))
|
logger.log_error('Thermal sysfs {} does not exist'.format(file_path))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user