Skip to content

Commit 8aea564

Browse files
authored
add support for MCLAG (sonic-net#453)
* add support for MCLAG Signed-off-by: shine.chen <[email protected]> * add warm-reboot support for ICCPd Signed-off-by: shine.chen <[email protected]> * ensure iccpd is there before stop iccpd Signed-off-by: shine.chen <[email protected]> * fix service function * remove unused comment * refactor code according to feature management mechanism Signed-off-by: shine.chen <[email protected]>
1 parent 118620f commit 8aea564

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

config/main.py

+41
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,14 @@ def _abort_if_false(ctx, param, value):
409409
if not value:
410410
ctx.abort()
411411

412+
def _get_optional_services():
413+
config_db = ConfigDBConnector()
414+
config_db.connect()
415+
optional_services_dict = config_db.get_table('FEATURE')
416+
if not optional_services_dict:
417+
return None
418+
return optional_services_dict.keys()
419+
412420
def _stop_services():
413421
# on Mellanox platform pmon is stopped by syncd
414422
services_to_stop = [
@@ -439,6 +447,17 @@ def _stop_services():
439447
log_error("Stopping {} failed with error {}".format(service, e))
440448
raise
441449

450+
# For optional services they don't start by default
451+
for service in _get_optional_services():
452+
(out, err) = run_command("systemctl status {}".format(service), return_output = True)
453+
if not err and 'Active: active (running)' in out:
454+
try:
455+
click.echo("Stopping service {} ...".format(service))
456+
run_command("systemctl stop {}".format(service))
457+
except SystemExit as e:
458+
log_error("Stopping {} failed with error {}".format(service, e))
459+
raise
460+
442461
def _reset_failed_services():
443462
services_to_reset = [
444463
'bgp',
@@ -474,6 +493,17 @@ def _reset_failed_services():
474493
log_error("Failed to reset failed status for service {}".format(service))
475494
raise
476495

496+
# For optional services they don't start by default
497+
for service in _get_optional_services():
498+
(out, err) = run_command("systemctl is-enabled {}".format(service), return_output = True)
499+
if not err and 'enabled' in out:
500+
try:
501+
click.echo("Resetting failed status for service {} ...".format(service))
502+
run_command("systemctl reset-failed {}".format(service))
503+
except SystemExit as e:
504+
log_error("Failed to reset failed status for service {}".format(service))
505+
raise
506+
477507
def _restart_services():
478508
# on Mellanox platform pmon is started by syncd
479509
services_to_restart = [
@@ -508,6 +538,17 @@ def _restart_services():
508538
log_error("Restart {} failed with error {}".format(service, e))
509539
raise
510540

541+
# For optional services they don't start by default
542+
for service in _get_optional_services():
543+
(out, err) = run_command("systemctl is-enabled {}".format(service), return_output = True)
544+
if not err and 'enabled' in out:
545+
try:
546+
click.echo("Restarting service {} ...".format(service))
547+
run_command("systemctl restart {}".format(service))
548+
except SystemExit as e:
549+
log_error("Restart {} failed with error {}".format(service, e))
550+
raise
551+
511552
def is_ipaddress(val):
512553
""" Validate if an entry is a valid IP """
513554
if not val:

scripts/fast-reboot

+18
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,24 @@ debug "Stopped bgp ..."
430430
docker kill lldp &> /dev/null || debug "Docker lldp is not running ($?) ..."
431431
systemctl stop lldp
432432
433+
if [[ "$REBOOT_TYPE" = "fast-reboot" ]]; then
434+
if echo $(docker ps) | grep -q iccpd; then
435+
docker kill iccpd > /dev/null || [ $? == 1 ]
436+
fi
437+
fi
438+
439+
# Stop iccpd gracefully
440+
if [[ "$REBOOT_TYPE" = "warm-reboot" || "$REBOOT_TYPE" = "fastfast-reboot" ]]; then
441+
if echo $(docker ps) | grep -q iccpd; then
442+
debug "Stopping iccpd ..."
443+
# Send USR1 signal to iccpd to stop it
444+
# It will prepare iccpd for warm-reboot
445+
# Note: We must send USR1 signal before syncd, or some state of iccpd maybe lost
446+
docker exec -i iccpd pkill -USR1 iccpd || [ $? == 1 ] > /dev/null
447+
debug "Stopped iccpd ..."
448+
fi
449+
fi
450+
433451
if [[ "$REBOOT_TYPE" = "fast-reboot" ]]; then
434452
# Kill teamd processes inside of teamd container with SIGUSR2 to allow them to send last LACP frames
435453
# We call `docker kill teamd` to ensure the container stops as quickly as possible,

0 commit comments

Comments
 (0)