Change in ...docker-playground[master]: clean up the net and attached containers to ensure reliable test starts

Hoernchen gerrit-no-reply at lists.osmocom.org
Fri Jul 5 13:16:47 UTC 2019


Hoernchen has uploaded this change for review. ( https://gerrit.osmocom.org/c/docker-playground/+/14679


Change subject: clean up the net and attached containers to ensure reliable test starts
......................................................................

clean up the net and attached containers to ensure reliable test starts

We can't create the net if it exists, and it can't be removed until all
attached containers are dead, so ensure this is the case upon net
creation. This fixes test failures due to stale nets and half-killed
test runs.

Change-Id: Id6d13b233ebfd808d8dfe83b6d1d1ba20c3392c8
---
M jenkins-common.sh
1 file changed, 10 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/docker-playground refs/changes/79/14679/1

diff --git a/jenkins-common.sh b/jenkins-common.sh
index 25ae26f..9fd3857 100644
--- a/jenkins-common.sh
+++ b/jenkins-common.sh
@@ -28,8 +28,18 @@
 	done
 }
 
+#kills all containers attached to network
+network_clean() {
+	docker network inspect $NET_NAME | grep Name | cut -d : -f2 | awk -F\" 'NR>1{print $2}' | xargs -rn1 docker kill
+}
+
 network_create() {
 	NET=$1
+	if docker network ls | grep -q $NET_NAME; then
+		echo removing stale network and containers...
+		network_clean
+		network_remove
+	fi
 	echo Creating network $NET_NAME
 	docker network create --internal --subnet $NET $NET_NAME
 }

-- 
To view, visit https://gerrit.osmocom.org/c/docker-playground/+/14679
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: docker-playground
Gerrit-Branch: master
Gerrit-Change-Id: Id6d13b233ebfd808d8dfe83b6d1d1ba20c3392c8
Gerrit-Change-Number: 14679
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen <ewild at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190705/56c2d8bb/attachment.html>


More information about the gerrit-log mailing list