[Mellanox] Adjust log level to avoid too many thermal logs (#4631)
* Trigger thermal action log only if thermal condition changes * test file existence before read file content * fix error for set psu fan speed * Remove logs because it print too frequently
This commit is contained in:
parent
767152f09b
commit
f277d13cd6
@ -221,6 +221,8 @@ class Fan(FanBase):
|
||||
status = True
|
||||
|
||||
if self.is_psu_fan:
|
||||
if not self.get_presence():
|
||||
return False
|
||||
from .thermal import logger
|
||||
try:
|
||||
with open(self.psu_i2c_bus_path, 'r') as f:
|
||||
|
@ -122,6 +122,8 @@ class Psu(PsuBase):
|
||||
"""
|
||||
result = 0
|
||||
try:
|
||||
if not os.path.exists(filename):
|
||||
return result
|
||||
with open(filename, 'r') as fileobj:
|
||||
result = int(fileobj.read().strip())
|
||||
except Exception as e:
|
||||
|
@ -495,12 +495,15 @@ class Thermal(ThermalBase):
|
||||
We usually disable the algorithm when we want to set a fix speed. E.g, when
|
||||
a fan unit is removed from system, we will set fan speed to 100% and disable
|
||||
the algorithm to avoid it adjust the speed.
|
||||
|
||||
Returns:
|
||||
True if thermal algorithm status changed.
|
||||
"""
|
||||
if not cls.thermal_profile:
|
||||
raise Exception("Fail to get thermal profile for this switch")
|
||||
|
||||
if not force and cls.thermal_algorithm_status == status:
|
||||
return
|
||||
return False
|
||||
|
||||
cls.thermal_algorithm_status = status
|
||||
content = "enabled" if status else "disabled"
|
||||
@ -521,6 +524,7 @@ class Thermal(ThermalBase):
|
||||
for index in range(count):
|
||||
cls._write_generic_file(join(THERMAL_ZONE_GEARBOX_PATH.format(start + index), THERMAL_ZONE_MODE), content)
|
||||
cls._write_generic_file(join(THERMAL_ZONE_GEARBOX_PATH.format(start + index), THERMAL_ZONE_POLICY), policy)
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
def check_thermal_zone_temperature(cls):
|
||||
|
@ -66,9 +66,6 @@ class SetAllFanSpeedAction(SetFanSpeedAction):
|
||||
for psu_fan in psu.get_all_fans():
|
||||
psu_fan.set_speed(speed)
|
||||
|
||||
logger.log_info('Updated PSU FAN speed to {}%'.format(speed))
|
||||
|
||||
|
||||
|
||||
@thermal_json_object('fan.all.check_and_set_speed')
|
||||
class CheckAndSetAllFanSpeedAction(SetAllFanSpeedAction):
|
||||
@ -131,14 +128,17 @@ class ControlThermalAlgoAction(ThermalPolicyActionBase):
|
||||
from .thermal import Thermal
|
||||
from .thermal_conditions import UpdateCoolingLevelToMinCondition
|
||||
from .fan import Fan
|
||||
Thermal.set_thermal_algorithm_status(self.status, False)
|
||||
if self.status:
|
||||
# Check thermal zone temperature, if all thermal zone temperature
|
||||
# back to normal, set it to minimum allowed speed to
|
||||
# save power
|
||||
UpdateCoolingLevelToMinAction.update_cooling_level_to_minimum(thermal_info_dict)
|
||||
status_changed = Thermal.set_thermal_algorithm_status(self.status, False)
|
||||
|
||||
logger.log_info('Changed thermal algorithm status to {}'.format(self.status))
|
||||
# Only update cooling level if thermal algorithm status changed
|
||||
if status_changed:
|
||||
if self.status:
|
||||
# Check thermal zone temperature, if all thermal zone temperature
|
||||
# back to normal, set it to minimum allowed speed to
|
||||
# save power
|
||||
UpdateCoolingLevelToMinAction.update_cooling_level_to_minimum(thermal_info_dict)
|
||||
|
||||
logger.log_info('Changed thermal algorithm status to {}'.format(self.status))
|
||||
|
||||
|
||||
class ChangeMinCoolingLevelAction(ThermalPolicyActionBase):
|
||||
@ -174,8 +174,6 @@ class ChangeMinCoolingLevelAction(ThermalPolicyActionBase):
|
||||
Fan.set_cooling_level(Fan.min_cooling_level, current_cooling_level)
|
||||
UpdateCoolingLevelToMinAction.update_cooling_level_to_minimum(thermal_info_dict)
|
||||
|
||||
logger.log_info('Changed minimum cooling level to {}'.format(Fan.min_cooling_level))
|
||||
|
||||
|
||||
class UpdatePsuFanSpeedAction(ThermalPolicyActionBase):
|
||||
def execute(self, thermal_info_dict):
|
||||
|
Loading…
Reference in New Issue
Block a user