Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mellanox] Adjust log level to avoid too many thermal logs #15

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions platform/mellanox/mlnx-platform-api/sonic_platform/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ def set_speed(self, speed):
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:
Expand Down
2 changes: 2 additions & 0 deletions platform/mellanox/mlnx-platform-api/sonic_platform/psu.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ def _read_generic_file(self, filename, len):
"""
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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,12 +495,15 @@ def set_thermal_algorithm_status(cls, status, force=True):
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"
Expand All @@ -521,6 +524,7 @@ def set_thermal_algorithm_status(cls, status, force=True):
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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,17 @@ def execute(self, thermal_info_dict):
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)

# 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))
logger.log_info('Changed thermal algorithm status to {}'.format(self.status))


class ChangeMinCoolingLevelAction(ThermalPolicyActionBase):
Expand Down