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
This commit is contained in:
parent
f9a889e29d
commit
ca27dffea7
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue