Skip to content

Commit a8229a5

Browse files
[config] config reload needs to handle exceptions while stopping sonic.target
The below error is seen when a 'config reload' operation is performed while the sonic.target is starting during system startup or a prior config reload command. Job for sonic.target canceled. This error can be ignored if we can try to stop all the services associated with sonic.target individually. Any processes which did not stop, will be restarted as part of the "systemctl restart sonic.target" command.
1 parent 38f8c06 commit a8229a5

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

config/main.py

+16-2
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,17 @@ def _get_disabled_services_list(config_db):
663663

664664
return disabled_services_list
665665

666+
def _stop_all_services():
667+
# stop all other services
668+
for s in _get_sonic_services():
669+
try:
670+
clicommon.run_command("sudo systemctl stop {}".format(s))
671+
except:
672+
click.echo("Error encountered while stopping service {}. Continuing..".format(s))
673+
try:
674+
clicommon.run_command("sudo systemctl stop swss")
675+
except:
676+
click.echo("Error encountered while stopping swss.service. Continuing..")
666677

667678
def _stop_services():
668679
try:
@@ -673,8 +684,11 @@ def _stop_services():
673684
pass
674685

675686
click.echo("Stopping SONiC target ...")
676-
clicommon.run_command("sudo systemctl stop sonic.target")
677-
687+
try:
688+
clicommon.run_command("sudo systemctl stop sonic.target")
689+
except:
690+
click.echo("Failed to stop sonic.target. Stopping all services individually.")
691+
_stop_all_services()
678692

679693
def _get_sonic_services():
680694
out = clicommon.run_command("systemctl list-dependencies --plain sonic.target | sed '1d'", return_cmd=True)

0 commit comments

Comments
 (0)