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

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Hoernchen gerrit-no-reply at lists.osmocom.org
Mon Jul 8 09:59:52 UTC 2019


Hoernchen has submitted this change and it was merged. ( 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(-)

Approvals:
  pespin: Looks good to me, but someone else must approve
  fixeria: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved
  Hoernchen: Verified



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-Reviewer: Hoernchen <ewild at sysmocom.de>
Gerrit-Reviewer: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: laforge <laforge at gnumonks.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190708/1752b8f7/attachment.htm>


More information about the gerrit-log mailing list