diff options
author | Eric Wild <ewild@sysmocom.de> | 2019-07-05 15:16:17 +0200 |
---|---|---|
committer | Eric Wild <ewild@sysmocom.de> | 2019-07-05 15:16:17 +0200 |
commit | ca27dffea7acb2682c09e912f7390c6c94260537 (patch) | |
tree | 4bebd2933cd05e0b55caf05dc787a8406efb54f1 /jenkins-common.sh | |
parent | f9a889e29da98325ef42a435098f44627fbef45c (diff) |
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
Diffstat (limited to 'jenkins-common.sh')
-rw-r--r-- | jenkins-common.sh | 10 |
1 files changed, 10 insertions, 0 deletions
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 @@ docker_images_require() { 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 } |