From 74675a33342b111420374950f6d31a72d9327f0b Mon Sep 17 00:00:00 2001 From: marian-pritsak Date: Mon, 27 Mar 2017 16:03:33 +0300 Subject: [PATCH 1/3] [docker-teamd]: Refactor cleanup procedure. Signed-off-by: marian-pritsak --- dockers/docker-teamd/Dockerfile.j2 | 3 +-- dockers/docker-teamd/start.sh | 30 +++++++++--------------------- rules/swss.mk | 3 ++- 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/dockers/docker-teamd/Dockerfile.j2 b/dockers/docker-teamd/Dockerfile.j2 index b3f35dd3c2e5..f85119491029 100644 --- a/dockers/docker-teamd/Dockerfile.j2 +++ b/dockers/docker-teamd/Dockerfile.j2 @@ -26,5 +26,4 @@ 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"] +ENTRYPOINT ["/usr/bin/start.sh"] diff --git a/dockers/docker-teamd/start.sh b/dockers/docker-teamd/start.sh index 5397475defb7..f38f28dc1855 100755 --- a/dockers/docker-teamd/start.sh +++ b/dockers/docker-teamd/start.sh @@ -1,18 +1,12 @@ #!/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 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 @@ -20,7 +14,11 @@ function start_app { } function clean_up { - pkill -9 teamd + if [ -d $TEAMD_CONF_PATH ]; then + for f in $TEAMD_CONF_PATH/*; do + teamd -f $f -k + done + fi pkill -9 teamsyncd service rsyslog stop exit @@ -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 diff --git a/rules/swss.mk b/rules/swss.mk index c3f50e617e92..e704d55c76fe 100644 --- a/rules/swss.mk +++ b/rules/swss.mk @@ -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 From 65bffb60c4e8ecc90ab909942766660e43be6ebf Mon Sep 17 00:00:00 2001 From: marian-pritsak Date: Wed, 12 Apr 2017 14:14:25 +0300 Subject: [PATCH 2/3] [docker-teamd]: Set start.sh as CMD. Signed-off-by: marian-pritsak --- dockers/docker-teamd/Dockerfile.j2 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dockers/docker-teamd/Dockerfile.j2 b/dockers/docker-teamd/Dockerfile.j2 index f85119491029..8fa045ff9e9c 100644 --- a/dockers/docker-teamd/Dockerfile.j2 +++ b/dockers/docker-teamd/Dockerfile.j2 @@ -26,4 +26,5 @@ ENV DEBIAN_FRONTEND=noninteractive RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y RUN rm -rf /debs -ENTRYPOINT ["/usr/bin/start.sh"] +ENTRYPOINT ["/bin/bash"] +CMD ["start.sh"] From b1a12cba52010fe2991660f8cab3da9a0957fbca Mon Sep 17 00:00:00 2001 From: marian-pritsak Date: Thu, 27 Apr 2017 19:39:32 +0300 Subject: [PATCH 3/3] [docker-teamd]: Check if teamd directory is not empty Signed-off-by: marian-pritsak --- dockers/docker-teamd/start.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dockers/docker-teamd/start.sh b/dockers/docker-teamd/start.sh index f38f28dc1855..51a16075c1ad 100755 --- a/dockers/docker-teamd/start.sh +++ b/dockers/docker-teamd/start.sh @@ -5,7 +5,7 @@ TEAMD_CONF_PATH=/etc/teamd function start_app { - if [ -d $TEAMD_CONF_PATH ]; then + if [ "$(ls $TEAMD_CONF_PATH)" ]; then for f in $TEAMD_CONF_PATH/*; do teamd -f $f -d done @@ -14,7 +14,7 @@ function start_app { } function clean_up { - if [ -d $TEAMD_CONF_PATH ]; then + if [ "$(ls $TEAMD_CONF_PATH)" ]; then for f in $TEAMD_CONF_PATH/*; do teamd -f $f -k done