Skip to content
Merged
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
7 changes: 5 additions & 2 deletions sonic-thermalctld/scripts/thermalctld
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,8 @@ class ThermalControlDaemon(daemon_base.DaemonBase):
self.thermal_manager.initialize()
self.thermal_manager.load(ThermalControlDaemon.POLICY_FILE)
self.thermal_manager.init_thermal_algorithm(self.chassis)
# Use thermal manager interval if it's available
self.wait_time = self.thermal_manager.get_interval()
except NotImplementedError:
self.log_warning('Thermal manager is not supported on this platform')
except Exception as e:
Expand Down Expand Up @@ -832,9 +834,10 @@ class ThermalControlDaemon(daemon_base.DaemonBase):
except Exception as e:
self.log_error('Caught exception while running thermal policy - {}'.format(repr(e)))

interval = self.thermal_manager.get_interval() if self.thermal_manager else self.INTERVAL
elapsed = time.time() - begin
if elapsed < self.INTERVAL:
self.wait_time = self.INTERVAL - elapsed
if elapsed < interval:
self.wait_time = interval - elapsed
else:
self.wait_time = self.FAST_START_INTERVAL

Expand Down
2 changes: 2 additions & 0 deletions sonic-thermalctld/tests/test_thermalctld.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,12 +651,14 @@ def test_signal_handler():
def test_daemon_run():
daemon_thermalctld = thermalctld.ThermalControlDaemon()
daemon_thermalctld.stop_event.wait = mock.MagicMock(return_value=True)
daemon_thermalctld.thermal_manager.get_interval = mock.MagicMock(return_value=60)
ret = daemon_thermalctld.run()
daemon_thermalctld.deinit() # Deinit becuase the test will hang if we assert
assert ret is False

daemon_thermalctld = thermalctld.ThermalControlDaemon()
daemon_thermalctld.stop_event.wait = mock.MagicMock(return_value=False)
daemon_thermalctld.thermal_manager.get_interval = mock.MagicMock(return_value=60)
ret = daemon_thermalctld.run()
daemon_thermalctld.deinit() # Deinit becuase the test will hang if we assert
assert ret is True
Expand Down