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-teamd]: Refactor cleanup procedure. #441

Closed
wants to merge 3 commits into from
Closed
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
4 changes: 2 additions & 2 deletions dockers/docker-teamd/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y
RUN rm -rf /debs

ENTRYPOINT ["/bin/bash", "-c"]
CMD ["/usr/bin/config.sh && /usr/bin/start.sh"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any special reason that we need to merge config.sh and start.sh back into one file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Reason for that is to correctly handle signals sent to container.
See #435

ENTRYPOINT ["/bin/bash"]
CMD ["start.sh"]
32 changes: 10 additions & 22 deletions dockers/docker-teamd/start.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
#!/bin/bash

. config.sh

TEAMD_CONF_PATH=/etc/teamd

# Before teamd could automatically add newly created host interfaces into the
# LAG, this workaround will be needed. It will remove the obsolete files and
# net devices that are failed to be removed in the previous run.
function start_app {
# Remove *.pid and *.sock files if there are any
rm -f /var/run/teamd/*
if [ -d $TEAMD_CONF_PATH ]; then
if [ "$(ls $TEAMD_CONF_PATH)" ]; then
for f in $TEAMD_CONF_PATH/*; do
# Remove netdevs if there are any
intf=`echo $f | awk -F'[/.]' '{print $4}'`
ip link del $intf
teamd -f $f -d
done
fi
teamsyncd &
}

function clean_up {
pkill -9 teamd
if [ "$(ls $TEAMD_CONF_PATH)" ]; then
for f in $TEAMD_CONF_PATH/*; do
teamd -f $f -k
done
fi
pkill -9 teamsyncd
service rsyslog stop
exit
Expand All @@ -31,15 +29,5 @@ trap clean_up SIGTERM SIGKILL
rm -f /var/run/rsyslogd.pid
service rsyslog start

# Before teamd could automatically add newly created host interfaces into the
# LAG, this workaround will wait until the host interfaces are created and then
# the processes will be started.
while true; do
# Check if front-panel ports are configured
result=`echo -en "SELECT 0\nHGETALL PORT_TABLE:ConfigDone" | redis-cli | sed -n 3p`
if [ "$result" == "0" ]; then
start_app
read
fi
sleep 1
done
start_app
read
3 changes: 2 additions & 1 deletion rules/swss.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ SWSS = swss_1.0.0_amd64.deb
$(SWSS)_SRC_PATH = $(SRC_PATH)/sonic-swss
$(SWSS)_DEPENDS += $(LIBSAIREDIS_DEV) $(LIBSAIMETADATA_DEV) $(LIBTEAM_DEV) \
$(LIBTEAMDCT) $(LIBTEAM_UTILS) $(LIBSWSSCOMMON_DEV)
$(SWSS)_RDEPENDS += $(LIBSAIREDIS) $(LIBSAIMETADATA) $(LIBTEAM) $(LIBSWSSCOMMON)
$(SWSS)_RDEPENDS += $(LIBSAIREDIS) $(LIBSAIMETADATA) $(LIBTEAM) $(LIBSWSSCOMMON) \
$(LIBTEAMDCT)
SONIC_DPKG_DEBS += $(SWSS)

SWSS_DBG = swss-dbg_1.0.0_amd64.deb
Expand Down