Skip to content

Commit 6c7df02

Browse files
Junchao-Mellanoxmssonicbld
authored andcommitted
[Mellanox] wait until hw-management watchdog files ready (#17618)
- Why I did it watchdog-control service always disarm watchdog during system startup stage. It could be the case that watchdog is not fully initialized while the watchdog-control service is accessing it. This PR adds a wait to make sure watchdog has been fully initialized. - How I did it adds a wait to make sure watchdog has been fully initialized. - How to verify it Manual test sonic regression
1 parent 9d91888 commit 6c7df02

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,8 @@ def get_watchdog():
283283
"""
284284
Return WatchdogType1 or WatchdogType2 based on system
285285
"""
286-
286+
287+
utils.wait_until(lambda: os.path.exists('/run/hw-management/watchdog/main/state'), timeout=10, interval=1)
287288
watchdog_main_device_name = None
288289

289290
for device in os.listdir("/dev/"):

platform/mellanox/mlnx-platform-api/tests/test_watchdog.py

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737

3838
class TestWatchdog:
39+
@mock.patch('sonic_platform.utils.wait_until', mock.MagicMock())
3940
@mock.patch('sonic_platform.watchdog.is_mlnx_wd_main')
4041
@mock.patch('sonic_platform.watchdog.os.listdir')
4142
def test_get_watchdog_no_device(self, mock_listdir, mock_is_main):
@@ -50,6 +51,7 @@ def test_get_watchdog_no_device(self, mock_listdir, mock_is_main):
5051
mock_is_main.return_value = False
5152
assert get_watchdog() is None
5253

54+
@mock.patch('sonic_platform.utils.wait_until', mock.MagicMock())
5355
@mock.patch('sonic_platform.watchdog.is_mlnx_wd_main')
5456
@mock.patch('sonic_platform.watchdog.is_wd_type2')
5557
@mock.patch('sonic_platform.watchdog.os.listdir', mock.MagicMock(return_value=['watchdog1', 'watchdog2']))

0 commit comments

Comments
 (0)