Skip to content

Commit 18fbca8

Browse files
Junchao-Mellanoxmssonicbld
authored andcommitted
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.
1 parent 6a76a73 commit 18fbca8

File tree

1 file changed

+12
-8
lines changed
  • platform/mellanox/mlnx-platform-api/sonic_platform

1 file changed

+12
-8
lines changed

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

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES.
2+
# Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES.
33
# Apache-2.0
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -215,15 +215,15 @@ def create_indexable_thermal(rule, index, sysfs_folder, position, presence_cb=No
215215
index += rule.get('start_index', 1)
216216
name = rule['name'].format(index)
217217
temp_file = os.path.join(sysfs_folder, rule['temperature'].format(index))
218-
_check_thermal_sysfs_existence(temp_file)
218+
_check_thermal_sysfs_existence(temp_file, presence_cb)
219219
if 'high_threshold' in rule:
220220
high_th_file = os.path.join(sysfs_folder, rule['high_threshold'].format(index))
221-
_check_thermal_sysfs_existence(high_th_file)
221+
_check_thermal_sysfs_existence(high_th_file, presence_cb)
222222
else:
223223
high_th_file = None
224224
if 'high_critical_threshold' in rule:
225225
high_crit_th_file = os.path.join(sysfs_folder, rule['high_critical_threshold'].format(index))
226-
_check_thermal_sysfs_existence(high_crit_th_file)
226+
_check_thermal_sysfs_existence(high_crit_th_file, presence_cb)
227227
else:
228228
high_crit_th_file = None
229229
if not presence_cb:
@@ -244,15 +244,15 @@ def create_single_thermal(rule, sysfs_folder, position, presence_cb=None):
244244
return None
245245

246246
temp_file = os.path.join(sysfs_folder, temp_file)
247-
_check_thermal_sysfs_existence(temp_file)
247+
_check_thermal_sysfs_existence(temp_file, presence_cb)
248248
if 'high_threshold' in rule:
249249
high_th_file = os.path.join(sysfs_folder, rule['high_threshold'])
250-
_check_thermal_sysfs_existence(high_th_file)
250+
_check_thermal_sysfs_existence(high_th_file, presence_cb)
251251
else:
252252
high_th_file = None
253253
if 'high_critical_threshold' in rule:
254254
high_crit_th_file = os.path.join(sysfs_folder, rule['high_critical_threshold'])
255-
_check_thermal_sysfs_existence(high_crit_th_file)
255+
_check_thermal_sysfs_existence(high_crit_th_file, presence_cb)
256256
else:
257257
high_crit_th_file = None
258258
name = rule['name']
@@ -262,7 +262,11 @@ def create_single_thermal(rule, sysfs_folder, position, presence_cb=None):
262262
return RemovableThermal(name, temp_file, high_th_file, high_crit_th_file, position, presence_cb)
263263

264264

265-
def _check_thermal_sysfs_existence(file_path):
265+
def _check_thermal_sysfs_existence(file_path, presence_cb):
266+
if presence_cb:
267+
status, _ = presence_cb()
268+
if not status:
269+
return
266270
if not os.path.exists(file_path):
267271
logger.log_error('Thermal sysfs {} does not exist'.format(file_path))
268272

0 commit comments

Comments
 (0)