Skip to content

Commit

Permalink
add support for MCLAG (#453)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
shine4chen authored Feb 24, 2020
1 parent 118620f commit 8aea564
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
41 changes: 41 additions & 0 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,14 @@ def _abort_if_false(ctx, param, value):
if not value:
ctx.abort()

def _get_optional_services():
config_db = ConfigDBConnector()
config_db.connect()
optional_services_dict = config_db.get_table('FEATURE')
if not optional_services_dict:
return None
return optional_services_dict.keys()

def _stop_services():
# on Mellanox platform pmon is stopped by syncd
services_to_stop = [
Expand Down Expand Up @@ -439,6 +447,17 @@ def _stop_services():
log_error("Stopping {} failed with error {}".format(service, e))
raise

# For optional services they don't start by default
for service in _get_optional_services():
(out, err) = run_command("systemctl status {}".format(service), return_output = True)

This comment has been minimized.

Copy link
@lguohan

lguohan Mar 22, 2020

Contributor

there is no return_output arg. please fix.

05:38:07.787  fatal: [vlab-01]: FAILED! => {"changed": true, "cmd": "config load_minigraph -y", "delta": "0:00:57.536746", "end": "2020-03-22 12:16:11.315604", "msg": "non-zero return code", "rc": 1, "start": "2020-03-22 12:15:13.778858", "stderr": "Traceback (most recent call last):\n  File \"/usr/bin/config\", line 12, in <module>\n    sys.exit(config())\n  File \"/usr/lib/python2.7/dist-packages/click/core.py\", line 722, in __call__\n    return self.main(*args, **kwargs)\n  File \"/usr/lib/python2.7/dist-packages/click/core.py\", line 697, in main\n    rv = self.invoke(ctx)\n  File \"/usr/lib/python2.7/dist-packages/click/core.py\", line 1066, in invoke\n    return _process_result(sub_ctx.command.invoke(sub_ctx))\n  File \"/usr/lib/python2.7/dist-packages/click/core.py\", line 895, in invoke\n    return ctx.invoke(self.callback, **ctx.params)\n  File \"/usr/lib/python2.7/dist-packages/click/core.py\", line 535, in invoke\n    return callback(*args, **kwargs)\n  File \"/usr/lib/python2.7/dist-packages/config/main.py\", line 684, in load_minigraph\n    _stop_services()\n  File \"/usr/lib/python2.7/dist-packages/config/main.py\", line 452, in _stop_services\n    (out, err) = run_command(\"systemctl status {}\".format(service), return_output = True)\nTypeError: run_command() got an unexpected keyword argument 'return_output'", "stderr_lines": ["Traceback (most recent call last):", "  File \"/usr/bin/config\", line 12, in <module>", "    sys.exit(config())", "  File \"/usr/lib/python2.7/dist-packages/click/core.py\", line 722, in __call__", "    return self.main(*args, **kwargs)", "  File \"/usr/lib/python2.7/dist-packages/click/core.py\", line 697, in main", "    rv = self.invoke(ctx)", "  File \"/usr/lib/python2.7/dist-packages/click/core.py\", line 1066, in invoke", "    return _process_result(sub_ctx.command.invoke(sub_ctx))", "  File \"/usr/lib/python2.7/dist-packages/click/core.py\", line 895, in invoke", "    return ctx.invoke(self.callback, **ctx.params)", "  File \"/usr/lib/python2.7/dist-packages/click/core.py\", line 535, in invoke", "    return callback(*args, **kwargs)", "  File \"/usr/lib/python2.7/dist-packages/config/main.py\", line 684, in load_minigraph", "    _stop_services()", "  File \"/usr/lib/python2.7/dist-packages/config/main.py\", line 452, in _stop_services", "    (out, err) = run_command(\"systemctl status {}\".format(service), return_output = True)", "TypeError: run_command() got an unexpected keyword argument 'return_output'"], "stdout": "Stopping service swss ...\nStopping service lldp ...\nStopping service pmon ...\nStopping service bgp ...\nStopping service hostcfgd ...\nStopping service nat ...", "stdout_lines": ["Stopping service swss ...", "Stopping service lldp ...", "Stopping service pmon ...", "Stopping service bgp ...", "Stopping service hostcfgd ...", "Stopping service nat ..."]}
if not err and 'Active: active (running)' in out:
try:
click.echo("Stopping service {} ...".format(service))
run_command("systemctl stop {}".format(service))
except SystemExit as e:
log_error("Stopping {} failed with error {}".format(service, e))
raise

def _reset_failed_services():
services_to_reset = [
'bgp',
Expand Down Expand Up @@ -474,6 +493,17 @@ def _reset_failed_services():
log_error("Failed to reset failed status for service {}".format(service))
raise

# For optional services they don't start by default
for service in _get_optional_services():
(out, err) = run_command("systemctl is-enabled {}".format(service), return_output = True)
if not err and 'enabled' in out:
try:
click.echo("Resetting failed status for service {} ...".format(service))
run_command("systemctl reset-failed {}".format(service))
except SystemExit as e:
log_error("Failed to reset failed status for service {}".format(service))
raise

def _restart_services():
# on Mellanox platform pmon is started by syncd
services_to_restart = [
Expand Down Expand Up @@ -508,6 +538,17 @@ def _restart_services():
log_error("Restart {} failed with error {}".format(service, e))
raise

# For optional services they don't start by default
for service in _get_optional_services():
(out, err) = run_command("systemctl is-enabled {}".format(service), return_output = True)
if not err and 'enabled' in out:
try:
click.echo("Restarting service {} ...".format(service))
run_command("systemctl restart {}".format(service))
except SystemExit as e:
log_error("Restart {} failed with error {}".format(service, e))
raise

def is_ipaddress(val):
""" Validate if an entry is a valid IP """
if not val:
Expand Down
18 changes: 18 additions & 0 deletions scripts/fast-reboot
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,24 @@ debug "Stopped bgp ..."
docker kill lldp &> /dev/null || debug "Docker lldp is not running ($?) ..."
systemctl stop lldp
if [[ "$REBOOT_TYPE" = "fast-reboot" ]]; then
if echo $(docker ps) | grep -q iccpd; then
docker kill iccpd > /dev/null || [ $? == 1 ]
fi
fi
# Stop iccpd gracefully
if [[ "$REBOOT_TYPE" = "warm-reboot" || "$REBOOT_TYPE" = "fastfast-reboot" ]]; then
if echo $(docker ps) | grep -q iccpd; then
debug "Stopping iccpd ..."
# Send USR1 signal to iccpd to stop it
# It will prepare iccpd for warm-reboot
# Note: We must send USR1 signal before syncd, or some state of iccpd maybe lost
docker exec -i iccpd pkill -USR1 iccpd || [ $? == 1 ] > /dev/null
debug "Stopped iccpd ..."
fi
fi
if [[ "$REBOOT_TYPE" = "fast-reboot" ]]; then
# Kill teamd processes inside of teamd container with SIGUSR2 to allow them to send last LACP frames
# We call `docker kill teamd` to ensure the container stops as quickly as possible,
Expand Down

0 comments on commit 8aea564

Please sign in to comment.