osmith has uploaded this change for review. (
https://gerrit.osmocom.org/c/docker-playground/+/31598 )
Change subject: docker kill: wait until containers are stopped
......................................................................
docker kill: wait until containers are stopped
As "docker kill" / "docker container kill" (alias) doesn't block
until
the given container stops, make sure to always run "docker wait"
afterwards.
Closes: OS#5928
Change-Id: I0242ece96541d8036ebbf8b0f498ebf231db26b5
---
M jenkins-common.sh
M osmo-cn-latest/run.sh
M osmo-ran/split/jenkins-split.sh
M scripts/regen_doc.sh
M ttcn3-bts-test/jenkins.sh
M ttcn3-fr-test/jenkins.sh
M ttcn3-hnbgw-test/jenkins.sh
M ttcn3-hnodeb-test/jenkins.sh
M ttcn3-remsim-test/jenkins.sh
9 files changed, 46 insertions(+), 17 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/docker-playground refs/changes/98/31598/1
diff --git a/jenkins-common.sh b/jenkins-common.sh
index b09db58..ec91b3f 100644
--- a/jenkins-common.sh
+++ b/jenkins-common.sh
@@ -190,9 +190,24 @@
done
}
+# Kill a docker container and ensure it doesn't exist anymore (OS#5928)
+docker_kill_wait() {
+ docker kill "$1"
+ docker wait "$1" || true
+}
+
#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
+ local containers="$(docker network inspect $NET_NAME | grep Name | cut -d : -f2 |
awk -F\" 'NR>1{print $2}')"
+ local container
+
+ if [ -z "$containers" ]; then
+ return
+ fi
+
+ for container in $containers; do
+ docker_kill_wait "$container"
+ done
}
# Create network and find a free subnet automatically. The global variables
diff --git a/osmo-cn-latest/run.sh b/osmo-cn-latest/run.sh
index d7bba95..4745ee3 100755
--- a/osmo-cn-latest/run.sh
+++ b/osmo-cn-latest/run.sh
@@ -28,6 +28,6 @@
echo Stopping containers
-docker container kill osmo-cn
+docker_kill_wait osmo-cn
network_remove
diff --git a/osmo-ran/split/jenkins-split.sh b/osmo-ran/split/jenkins-split.sh
index 5cecf4a..58c1aea 100755
--- a/osmo-ran/split/jenkins-split.sh
+++ b/osmo-ran/split/jenkins-split.sh
@@ -69,7 +69,7 @@
kill_containers() {
for i in "${docker_names[@]}"; do
- docker kill $i
+ docker_kill_wait $i
done
}
diff --git a/scripts/regen_doc.sh b/scripts/regen_doc.sh
index 27c3138..fdc9da2 100755
--- a/scripts/regen_doc.sh
+++ b/scripts/regen_doc.sh
@@ -51,6 +51,6 @@
-H "172.18.$SUBNET.23" \
-O "$VTYFILE"
-docker container kill "${BUILD_TAG}-$NAME-$IMAGE_SUFFIX"
+docker_kill_wait "${BUILD_TAG}-$NAME-$IMAGE_SUFFIX"
network_remove
diff --git a/ttcn3-bts-test/jenkins.sh b/ttcn3-bts-test/jenkins.sh
index 0c1cbb0..ed1e095 100755
--- a/ttcn3-bts-test/jenkins.sh
+++ b/ttcn3-bts-test/jenkins.sh
@@ -168,9 +168,9 @@
# 2) some GPRS tests require virt_phy
echo "Changing to virtphy configuration"
# switch from osmo-bts-trx + trxcon + faketrx to virtphy + osmo-bts-virtual
-docker container kill ${BUILD_TAG}-trxcon
-docker container kill ${BUILD_TAG}-fake_trx
-docker container kill ${BUILD_TAG}-bts
+docker_kill_wait ${BUILD_TAG}-trxcon
+docker_kill_wait ${BUILD_TAG}-fake_trx
+docker_kill_wait ${BUILD_TAG}-bts
cp virtphy/osmo-bts.gen.cfg $VOL_BASE_DIR/bts/
network_replace_subnet_in_configs
start_bts virtual 0
@@ -179,10 +179,10 @@
#start_testsuite virtphy
# 3) OML tests require us to run without BSC
-docker container kill ${BUILD_TAG}-bsc
+docker_kill_wait ${BUILD_TAG}-bsc
# switch back from virtphy + osmo-bts-virtual to osmo-bts-trx
-docker container kill ${BUILD_TAG}-virtphy
-docker container kill ${BUILD_TAG}-bts
+docker_kill_wait ${BUILD_TAG}-virtphy
+docker_kill_wait ${BUILD_TAG}-bts
cp oml/osmo-bts.gen.cfg $VOL_BASE_DIR/bts/
network_replace_subnet_in_configs
@@ -196,7 +196,7 @@
cp fh/osmo-bsc.gen.cfg $VOL_BASE_DIR/bsc/
cp generic/osmo-bts.gen.cfg $VOL_BASE_DIR/bts/
# restart the BSC/BTS and run the testsuite again
-docker container kill ${BUILD_TAG}-bts
+docker_kill_wait ${BUILD_TAG}-bts
network_replace_subnet_in_configs
start_bsc
start_bts trx 1
diff --git a/ttcn3-fr-test/jenkins.sh b/ttcn3-fr-test/jenkins.sh
index 12e14a5..36bb77b 100755
--- a/ttcn3-fr-test/jenkins.sh
+++ b/ttcn3-fr-test/jenkins.sh
@@ -10,7 +10,7 @@
clean_up() {
# kill the frnet container to avoid "You cannot remove a running container "
below in 'rm'
- docker kill ${BUILD_TAG}-frnet || true
+ docker_kill_wait ${BUILD_TAG}-frnet || true
# store execution logs for both containers
docker logs --timestamps ${BUILD_TAG}-ttcn3-fr-test >
$VOL_BASE_DIR/fr-tester/exec.log || true
diff --git a/ttcn3-hnbgw-test/jenkins.sh b/ttcn3-hnbgw-test/jenkins.sh
index f3c5694..e93c8af 100755
--- a/ttcn3-hnbgw-test/jenkins.sh
+++ b/ttcn3-hnbgw-test/jenkins.sh
@@ -74,8 +74,8 @@
$REPO_USER/ttcn3-hnbgw-test
echo Stopping containers
- docker container kill ${BUILD_TAG}-hnbgw
- docker container kill ${BUILD_TAG}-stp
+ docker_kill_wait ${BUILD_TAG}-hnbgw
+ docker_kill_wait ${BUILD_TAG}-stp
}
echo Testing without PFCP
diff --git a/ttcn3-hnodeb-test/jenkins.sh b/ttcn3-hnodeb-test/jenkins.sh
index 21e72c0..3b57fd8 100755
--- a/ttcn3-hnodeb-test/jenkins.sh
+++ b/ttcn3-hnodeb-test/jenkins.sh
@@ -45,4 +45,4 @@
$REPO_USER/ttcn3-hnodeb-test
echo Stopping containers
-docker container kill ${BUILD_TAG}-hnodeb
+docker_kill_wait ${BUILD_TAG}-hnodeb
diff --git a/ttcn3-remsim-test/jenkins.sh b/ttcn3-remsim-test/jenkins.sh
index a7325e7..158a352 100755
--- a/ttcn3-remsim-test/jenkins.sh
+++ b/ttcn3-remsim-test/jenkins.sh
@@ -80,7 +80,7 @@
network_replace_subnet_in_configs
start_server
start_testsuite
-docker container kill ${BUILD_TAG}-server
+docker_kill_wait ${BUILD_TAG}-server
# 2) bankd test suite
echo "Changing to bankd configuration"
@@ -89,7 +89,7 @@
network_replace_subnet_in_configs
start_bankd
start_testsuite
-docker container kill ${BUILD_TAG}-bankd
+docker_kill_wait ${BUILD_TAG}-bankd
# 3) client test suite
echo "Changing to client configuration"
--
To view, visit
https://gerrit.osmocom.org/c/docker-playground/+/31598
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: docker-playground
Gerrit-Branch: master
Gerrit-Change-Id: I0242ece96541d8036ebbf8b0f498ebf231db26b5
Gerrit-Change-Number: 31598
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-MessageType: newchange