Skip to content

Commit 4f331ff

Browse files
authored
Merge pull request #298 from mssonicbld/sonicbld/202603-merge
```<br>* 706b311 - (HEAD -> 202603) Merge branch '202511' of https://github.com/sonic-net/sonic-utilities into 202603 (2026-04-01) [Sonic Automation] * 8fd05d5 - (origin/202511) [config reload] Skip routeCheck monit calls on DPU platforms (#4410) (2026-04-01) [mssonicbld]<br>```
2 parents 8ea9b11 + 706b311 commit 4f331ff

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

config/main.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -986,12 +986,25 @@ def _get_disabled_services_list(config_db):
986986
return disabled_services_list
987987

988988

989+
def _monit_service_exists(service):
990+
"""Return True if monit knows about the given service."""
991+
try:
992+
subprocess.check_call(
993+
['sudo', 'monit', 'status', service],
994+
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
995+
)
996+
return True
997+
except subprocess.CalledProcessError:
998+
return False
999+
1000+
9891001
def _stop_services():
9901002
try:
9911003
subprocess.check_call(['sudo', 'monit', 'status'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
9921004
click.echo("Disabling container and routeCheck monitoring ...")
9931005
clicommon.run_command(['sudo', 'monit', 'unmonitor', 'container_checker'])
994-
clicommon.run_command(['sudo', 'monit', 'unmonitor', 'routeCheck'])
1006+
if _monit_service_exists('routeCheck'):
1007+
clicommon.run_command(['sudo', 'monit', 'unmonitor', 'routeCheck'])
9951008
except subprocess.CalledProcessError as err:
9961009
pass
9971010

@@ -1080,10 +1093,13 @@ def _restart_services():
10801093
try:
10811094
subprocess.check_call(['sudo', 'monit', 'status'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
10821095
click.echo("Enabling container and routeCheck monitoring ...")
1083-
clicommon.run_command(['sudo', 'monit', 'monitor', 'routeCheck'])
1096+
has_route_check = _monit_service_exists('routeCheck')
1097+
if has_route_check:
1098+
clicommon.run_command(['sudo', 'monit', 'monitor', 'routeCheck'])
10841099
clicommon.run_command(['sudo', 'monit', 'monitor', 'container_checker'])
10851100
log.log_notice("Waiting for monit monitor actions to complete ...")
1086-
_wait_for_monit_service_monitored('routeCheck')
1101+
if has_route_check:
1102+
_wait_for_monit_service_monitored('routeCheck')
10871103
_wait_for_monit_service_monitored('container_checker')
10881104
except subprocess.CalledProcessError as err:
10891105
pass

0 commit comments

Comments
 (0)