aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Smith <osmith@sysmocom.de>2023-02-28 17:59:17 +0100
committerosmith <osmith@sysmocom.de>2023-03-07 09:02:02 +0000
commit4f459b779ea22619610926ab2fcc71a6d64ed50b (patch)
treeaa506a13f575e46473f200d98508c223c24534f0
parentc163d5d854d9e7e555209db4b3b0661195e4a482 (diff)
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
-rw-r--r--jenkins-common.sh12
-rwxr-xr-xosmo-cn-latest/run.sh2
-rwxr-xr-xosmo-ran/split/jenkins-split.sh4
-rwxr-xr-xscripts/regen_doc.sh2
-rwxr-xr-xttcn3-bts-test/jenkins.sh14
-rwxr-xr-xttcn3-fr-test/jenkins.sh2
-rwxr-xr-xttcn3-hnbgw-test/jenkins.sh4
-rwxr-xr-xttcn3-hnodeb-test/jenkins.sh2
-rwxr-xr-xttcn3-remsim-test/jenkins.sh4
9 files changed, 27 insertions, 19 deletions
diff --git a/jenkins-common.sh b/jenkins-common.sh
index b09db58..e70c217 100644
--- a/jenkins-common.sh
+++ b/jenkins-common.sh
@@ -190,9 +190,19 @@ docker_images_require() {
done
}
+# Kill a docker container and ensure it has actually stopped (OS#5928)
+docker_kill_wait() {
+ docker kill "$@"
+ docker wait "$@" || 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}')"
+
+ if [ -n "$containers" ]; then
+ docker_kill_wait $containers
+ fi
}
# 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 @@ docker run --rm \
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..496508c 100755
--- a/osmo-ran/split/jenkins-split.sh
+++ b/osmo-ran/split/jenkins-split.sh
@@ -68,9 +68,7 @@ run_image() {
}
kill_containers() {
- for i in "${docker_names[@]}"; do
- docker kill $i
- done
+ docker_kill_wait "${docker_names[@]}"
}
remove_networks() {
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 @@ ${OSMO_INTERACT_VTY} \
-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 @@ start_testsuite generic
# 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_virtphy
#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 @@ start_testsuite oml
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 @@ set -e
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 @@ run_tests() {
$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 @@ docker run --rm \
$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 @@ write_mp_osmo_repo "$VOL_BASE_DIR/remsim-tester/REMSIM_Tests.cfg"
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 @@ write_mp_osmo_repo "$VOL_BASE_DIR/remsim-tester/REMSIM_Tests.cfg"
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"