Skip to content
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

[docker-orchagent]: Properly manage with supervisord #589

Merged
merged 1 commit into from
May 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dockers/docker-orchagent/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ debs/{{ deb }}{{' '}}
RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y
RUN rm -rf /debs

COPY ["start.sh", "orchagent.sh", "/usr/bin/"]
COPY ["start.sh", "orchagent.sh", "swssconfig.sh", "/usr/bin/"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to rename it just to config.sh? swssconfig.sh will be confused with swssconfig script.

Copy link
Contributor Author

@jleveque jleveque May 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stcheng: I've been using this naming convention for supervisord. Basically, if a process requires more than one command to start properly, I've been wrapping them in a shell script named after the process. I think "config.sh" is not descriptive enough and can't be used as a convention. Maybe orchagent_start.sh and swssconfig_start.sh?

Also, is this really necessary? /usr/bin/orchagent and /usr/bin/swssconfig are binaries, not scripts, so do you think there could really be that much confusion?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay. i see your point.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see yours as well. This has the potential to get confusing in the future. I'll consider submitting a PR that changes the names of all of these new process start scripts at once.

COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
COPY ["ipinip.json.j2", "/usr/share/sonic/templates/"]
COPY ["mirror.json.j2", "/usr/share/sonic/templates/"]
Expand Down
56 changes: 1 addition & 55 deletions dockers/docker-orchagent/orchagent.sh
Original file line number Diff line number Diff line change
@@ -1,80 +1,26 @@
#!/usr/bin/env bash

# Exit immediately upon error
set -e

function start_app {
orchagent $ORCHAGENT_ARGS &
portsyncd $PORTSYNCD_ARGS &
intfsyncd &
neighsyncd &
for file in $SWSSCONFIG_ARGS
do
swssconfig /etc/swss/config.d/$file
sleep 1
done
}

function config_acl {
if [ -f "/etc/sonic/acl.json" ]; then
mkdir -p /etc/swss/config.d/acl
rm -rf /etc/swss/config.d/acl/*
translate_acl -m /etc/sonic/minigraph.xml -o /etc/swss/config.d/acl /etc/sonic/acl.json
for filename in /etc/swss/config.d/acl/*.json; do
[ -e "$filename" ] || break
swssconfig $filename
done
fi
}

function clean_up {
pkill -9 orchagent
pkill -9 portsyncd
pkill -9 intfsyncd
pkill -9 neighsyncd
exit
}

trap clean_up SIGTERM SIGKILL

HWSKU=`sonic-cfggen -m /etc/sonic/minigraph.xml -v minigraph_hwsku`

MAC_ADDRESS=`ip link show eth0 | grep ether | awk '{print $2}'`

ORCHAGENT_ARGS=""

PORTSYNCD_ARGS="-p /usr/share/sonic/hwsku/port_config.ini"

SWSSCONFIG_ARGS="00-copp.config.json ipinip.json mirror.json "

if [ "$HWSKU" == "Force10-S6000" ]; then
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
SWSSCONFIG_ARGS+="td2.32ports.buffers.json td2.32ports.qos.json "
elif [ "$HWSKU" == "Force10-S6100" ]; then
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
elif [ "$HWSKU" == "Force10-Z9100" ]; then
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
elif [ "$HWSKU" == "Arista-7050-QX32" ]; then
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
SWSSCONFIG_ARGS+="td2.32ports.buffers.json td2.32ports.qos.json "
elif [ "$HWSKU" == "Arista-7060-CX32S" ]; then
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
elif [ "$HWSKU" == "AS7512" ]; then
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
elif [ "$HWSKU" == "INGRASYS-S9100-C32" ]; then
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
elif [ "$HWSKU" == "ACS-MSN2700" ]; then
SWSSCONFIG_ARGS+="msn2700.32ports.buffers.json msn2700.32ports.qos.json "
fi

while true; do
# Check if syncd starts
result=`echo -en "SELECT 1\nHLEN HIDDEN" | redis-cli | sed -n 2p`
if [ "$result" != "0" ]; then
start_app
config_acl
read
fi
sleep 1
done
exec /usr/bin/orchagent ${ORCHAGENT_ARGS}

19 changes: 19 additions & 0 deletions dockers/docker-orchagent/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,24 @@ rm -f /var/run/rsyslogd.pid

supervisorctl start rsyslogd

# Wait for syncd to start
while true; do
RESULT=$(echo -en "SELECT 1\nHLEN HIDDEN" | redis-cli | sed -n 2p)

if [ "$RESULT" != "0" ]; then
break
fi

sleep 1
done

supervisorctl start orchagent

supervisorctl start portsyncd

supervisorctl start intfsyncd

supervisorctl start neighsyncd

supervisorctl start swssconfig

32 changes: 32 additions & 0 deletions dockers/docker-orchagent/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,35 @@ autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog

[program:portsyncd]
command=/usr/bin/portsyncd -p /usr/share/sonic/hwsku/port_config.ini
priority=4
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog

[program:intfsyncd]
command=/usr/bin/intfsyncd
priority=5
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog

[program:neighsyncd]
command=/usr/bin/neighsyncd
priority=6
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog

[program:swssconfig]
command=/usr/bin/swssconfig.sh
priority=7
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog

33 changes: 33 additions & 0 deletions dockers/docker-orchagent/swssconfig.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

function config_acl {
if [ -f "/etc/sonic/acl.json" ]; then
mkdir -p /etc/swss/config.d/acl
rm -rf /etc/swss/config.d/acl/*
translate_acl -m /etc/sonic/minigraph.xml -o /etc/swss/config.d/acl /etc/sonic/acl.json
for filename in /etc/swss/config.d/acl/*.json; do
[ -e "$filename" ] || break
swssconfig $filename
done
fi
}

HWSKU=`sonic-cfggen -m /etc/sonic/minigraph.xml -v minigraph_hwsku`

SWSSCONFIG_ARGS="00-copp.config.json ipinip.json mirror.json "

if [ "$HWSKU" == "Force10-S6000" ]; then
SWSSCONFIG_ARGS+="td2.32ports.buffers.json td2.32ports.qos.json "
elif [ "$HWSKU" == "Arista-7050-QX32" ]; then
SWSSCONFIG_ARGS+="td2.32ports.buffers.json td2.32ports.qos.json "
elif [ "$HWSKU" == "ACS-MSN2700" ]; then
SWSSCONFIG_ARGS+="msn2700.32ports.buffers.json msn2700.32ports.qos.json "
fi

for file in $SWSSCONFIG_ARGS; do
swssconfig /etc/swss/config.d/$file
sleep 1
done

config_acl