-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[services] Restart SwSS service upon unexpected critical process exit #2845
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
cfcbfd2
[service] Restart SwSS Docker container if orchagent exits unexpectedly
jleveque 3877850
Move supervisor-proc-exit-listener script
jleveque c847c98
Configure systemd to stop restarting swss if it attempts to restart m…
jleveque 0db6c24
[docker-dhcp-relay] Enhance wait_for_intf.sh.j2 to utilize STATEDB
jleveque c61151b
Ensure dependent services stop/start/restart with SwSS
jleveque afb1fc6
Change 'StartLimitInterval' to 'StartLimitIntervalSec', as Stretch in…
jleveque 0e312e2
Also update journald.conf options
jleveque 7c361a6
Remove 'PartOf' option from unit files
jleveque b4cf4b4
Add '$(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT)' to new shared docker-or…
jleveque cd690d8
Make supervisor-proc-exit-listener script read from 'critical_process…
jleveque f3dcce7
Update critical_processes file for swss container
jleveque File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,40 @@ | ||
#!/usr/bin/env bash | ||
|
||
function wait_until_iface_ready | ||
{ | ||
IFACE=$1 | ||
STATE_DB_IDX="6" | ||
|
||
echo "Waiting until interface $IFACE is up..." | ||
|
||
# Wait for the interface to come up (i.e., 'ip link show' returns 0) | ||
until ip link show dev $IFACE up > /dev/null 2>&1; do | ||
sleep 1 | ||
done | ||
PORT_TABLE_PREFIX="PORT_TABLE" | ||
VLAN_TABLE_PREFIX="VLAN_TABLE" | ||
LAG_TABLE_PREFIX="LAG_TABLE" | ||
|
||
echo "Interface $IFACE is up" | ||
function wait_until_iface_ready | ||
{ | ||
TABLE_PREFIX=$1 | ||
IFACE=$2 | ||
|
||
echo "Waiting until interface $IFACE has an IPv4 address..." | ||
echo "Waiting until interface $IFACE is ready..." | ||
|
||
# Wait until the interface gets assigned an IPv4 address | ||
# Wait for the interface to come up | ||
# (i.e., interface is present in STATE_DB and state is "ok") | ||
while true; do | ||
IP=$(ip -4 addr show dev $IFACE | grep "inet " | awk '{ print $2 }' | cut -d '/' -f1) | ||
|
||
if [ -n "$IP" ]; then | ||
RESULT=$(redis-cli -n ${STATE_DB_IDX} HGET "${TABLE_PREFIX}|${IFACE}" "state" 2> /dev/null) | ||
if [ x"$RESULT" == x"ok" ]; then | ||
break | ||
fi | ||
|
||
sleep 1 | ||
done | ||
|
||
echo "Interface $IFACE is configured with IP $IP" | ||
echo "Interface ${IFACE} is ready!" | ||
} | ||
|
||
|
||
# Wait for all interfaces to come up and have IPv4 addresses assigned | ||
# Wait for all interfaces to be up and ready | ||
{% for (name, prefix) in INTERFACE %} | ||
wait_until_iface_ready {{ name }} | ||
wait_until_iface_ready ${PORT_TABLE_PREFIX} {{ name }} | ||
{% endfor %} | ||
{% for (name, prefix) in VLAN_INTERFACE %} | ||
wait_until_iface_ready {{ name }} | ||
wait_until_iface_ready ${VLAN_TABLE_PREFIX} {{ name }} | ||
{% endfor %} | ||
{% for (name, prefix) in PORTCHANNEL_INTERFACE %} | ||
wait_until_iface_ready {{ name }} | ||
wait_until_iface_ready ${LAG_TABLE_PREFIX} {{ name }} | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
orchagent | ||
portsyncd | ||
neighsyncd | ||
vlanmgrd | ||
intfmgrd | ||
portmgrd | ||
buffermgrd | ||
vrfmgrd | ||
nbrmgrd | ||
vxlanmgrd | ||
intfsyncd | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env python | ||
|
||
import os | ||
import signal | ||
import sys | ||
import syslog | ||
|
||
from supervisor import childutils | ||
|
||
# Contents of file should be the names of critical processes (as defined in | ||
# supervisor.conf file), one per line | ||
CRITICAL_PROCESSES_FILE = '/etc/supervisor/critical_processes' | ||
|
||
def main(): | ||
# Read the list of critical processes from a file | ||
with open(CRITICAL_PROCESSES_FILE, 'r') as f: | ||
critical_processes = [line.rstrip('\n') for line in f] | ||
|
||
while True: | ||
# Transition from ACKNOWLEDGED to READY | ||
childutils.listener.ready() | ||
|
||
line = sys.stdin.readline() | ||
headers = childutils.get_headers(line) | ||
payload = sys.stdin.read(int(headers['len'])) | ||
|
||
# Transition from READY to ACKNOWLEDGED | ||
childutils.listener.ok() | ||
|
||
# We only care about PROCESS_STATE_EXITED events | ||
if headers['eventname'] == 'PROCESS_STATE_EXITED': | ||
payload_headers, payload_data = childutils.eventdata(payload + '\n') | ||
|
||
expected = int(payload_headers['expected']) | ||
processname = payload_headers['processname'] | ||
|
||
# If a critical process exited unexpectedly, terminate supervisor | ||
if expected == 0 and processname in critical_processes: | ||
MSG_FORMAT_STR = "Process {} exited unxepectedly. Terminating supervisor..." | ||
msg = MSG_FORMAT_STR.format(payload_headers['processname']) | ||
syslog.syslog(syslog.LOG_INFO, msg) | ||
os.kill(os.getppid(), signal.SIGTERM) | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 24 additions & 26 deletions
50
src/sonic-config-engine/tests/sample_output/wait_for_intf.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,41 @@ | ||
#!/usr/bin/env bash | ||
|
||
function wait_until_iface_ready | ||
{ | ||
IFACE=$1 | ||
STATE_DB_IDX="6" | ||
|
||
echo "Waiting until interface $IFACE is up..." | ||
|
||
# Wait for the interface to come up (i.e., 'ip link show' returns 0) | ||
until ip link show dev $IFACE up > /dev/null 2>&1; do | ||
sleep 1 | ||
done | ||
PORT_TABLE_PREFIX="PORT_TABLE" | ||
VLAN_TABLE_PREFIX="VLAN_TABLE" | ||
LAG_TABLE_PREFIX="LAG_TABLE" | ||
|
||
echo "Interface $IFACE is up" | ||
function wait_until_iface_ready | ||
{ | ||
TABLE_PREFIX=$1 | ||
IFACE=$2 | ||
|
||
echo "Waiting until interface $IFACE has an IPv4 address..." | ||
echo "Waiting until interface $IFACE is ready..." | ||
|
||
# Wait until the interface gets assigned an IPv4 address | ||
# Wait for the interface to come up | ||
# (i.e., interface is present in STATE_DB and state is "ok") | ||
while true; do | ||
IP=$(ip -4 addr show dev $IFACE | grep "inet " | awk '{ print $2 }' | cut -d '/' -f1) | ||
|
||
if [ -n "$IP" ]; then | ||
RESULT=$(redis-cli -n ${STATE_DB_IDX} HGET "${TABLE_PREFIX}|${IFACE}" "state" 2> /dev/null) | ||
if [ x"$RESULT" == x"ok" ]; then | ||
break | ||
fi | ||
|
||
sleep 1 | ||
done | ||
|
||
echo "Interface $IFACE is configured with IP $IP" | ||
echo "Interface ${IFACE} is ready!" | ||
} | ||
|
||
|
||
# Wait for all interfaces to come up and have IPv4 addresses assigned | ||
wait_until_iface_ready Vlan1000 | ||
wait_until_iface_ready PortChannel01 | ||
wait_until_iface_ready PortChannel01 | ||
wait_until_iface_ready PortChannel02 | ||
wait_until_iface_ready PortChannel02 | ||
wait_until_iface_ready PortChannel03 | ||
wait_until_iface_ready PortChannel03 | ||
wait_until_iface_ready PortChannel04 | ||
wait_until_iface_ready PortChannel04 | ||
# Wait for all interfaces to be up and ready | ||
wait_until_iface_ready ${VLAN_TABLE_PREFIX} Vlan1000 | ||
wait_until_iface_ready ${LAG_TABLE_PREFIX} PortChannel01 | ||
wait_until_iface_ready ${LAG_TABLE_PREFIX} PortChannel01 | ||
wait_until_iface_ready ${LAG_TABLE_PREFIX} PortChannel02 | ||
wait_until_iface_ready ${LAG_TABLE_PREFIX} PortChannel02 | ||
wait_until_iface_ready ${LAG_TABLE_PREFIX} PortChannel03 | ||
wait_until_iface_ready ${LAG_TABLE_PREFIX} PortChannel03 | ||
wait_until_iface_ready ${LAG_TABLE_PREFIX} PortChannel04 | ||
wait_until_iface_ready ${LAG_TABLE_PREFIX} PortChannel04 | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
intfsyncd is no longer present.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I meant to delete that line, but forgot. It won't cause any issues, but I'll open a new PR to remove it soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR here: #2850