Skip to content

Commit 428d6da

Browse files
authoredDec 26, 2024
Fix monit connection failure when doing routeCheck/contianerCheck monitor enable after config reload (#3698)
Fix: sonic-net/sonic-buildimage#21268 How I did: Reorder the sequence of doing enabling container_cheek and routeCheck before doing monit reload to avoid transient issue of monit sock error. Also I add a sleep of 1 sec to make sure monitor enable configuration takes effect before we do reload.
1 parent 34d2c8c commit 428d6da

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed
 

‎config/main.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -949,18 +949,17 @@ def _restart_services():
949949
# If load_minigraph exit before eth0 restart, commands after load_minigraph may failed
950950
wait_service_restart_finish('interfaces-config', last_interface_config_timestamp)
951951
wait_service_restart_finish('networking', last_networking_timestamp)
952-
953-
# Reload Monit configuration to pick up new hostname in case it changed
954-
click.echo("Reloading Monit configuration ...")
955-
clicommon.run_command(['sudo', 'monit', 'reload'])
956-
957952
try:
958953
subprocess.check_call(['sudo', 'monit', 'status'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
959954
click.echo("Enabling container and routeCheck monitoring ...")
960-
clicommon.run_command(['sudo', 'monit', 'monitor', 'container_checker'])
961955
clicommon.run_command(['sudo', 'monit', 'monitor', 'routeCheck'])
956+
clicommon.run_command(['sudo', 'monit', 'monitor', 'container_checker'])
957+
time.sleep(1)
962958
except subprocess.CalledProcessError as err:
963959
pass
960+
# Reload Monit configuration to pick up new hostname in case it changed
961+
click.echo("Reloading Monit configuration ...")
962+
clicommon.run_command(['sudo', 'monit', 'reload'])
964963

965964
def _per_namespace_swss_ready(service_name):
966965
out, _ = clicommon.run_command(['systemctl', 'show', str(service_name), '--property', 'ActiveState', '--value'], return_cmd=True)

‎tests/config_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@
5656
Running command: config qos reload --no-dynamic-buffer --no-delay
5757
Running command: pfcwd start_default
5858
Restarting SONiC target ...
59-
Reloading Monit configuration ...
6059
Enabling container and routeCheck monitoring ...
60+
Reloading Monit configuration ...
6161
Please note setting loaded from minigraph will be lost after system reboot. To preserve setting, run `config save`.
6262
Released lock on {0}
6363
"""

0 commit comments

Comments
 (0)