jobs/osmo-gsm-tester-virtual: kill old instances

Make sure osmo-gsm-tester gets killed eventually, even if a bug causes
it to run forever or if aborted manually.

* add a name to the docker container
* kill the docker container if it runs longer than 24h with
  docker-cleanup.sh
* rename fix_permissions_trap to clean_up_trap and kill it there, when
  it is still running before the job starts and after it is done
  (in my testing this did not kill it after pressing abort, but it would
  be killed either at the start of the next job running on the same
  jenkins node, or after 24h by docker-cleanup.sh)

Related: OS#6304
Change-Id: I6fc874d319d74aabdc33c10910cbcca2978d5bbb
This commit is contained in:
Oliver Smith 2023-12-14 11:00:58 +01:00
parent 0e2604dae0
commit a9c93850c3
2 changed files with 9 additions and 7 deletions

View File

@ -226,14 +226,15 @@
- copy_artifact:
repo: osmo-gsm-tester_build-osmocom-bb
- shell: |
# Set a trap to fix workspace permissions on exit
fix_permissions() {
# Set a trap to fix workspace permissions / kill the docker container on exit
clean_up() {
docker kill "osmo-gsm-tester-virtual" || true
docker run --rm \
-v "$WORKSPACE":/workspace \
debian:bullseye \
chmod -R a+rwX /workspace/
}
fix_permissions_trap() {
clean_up_trap() {
set +x
echo
echo "### Clean up ###"
@ -241,12 +242,12 @@
set -x
trap - EXIT INT TERM 0
fix_permissions
clean_up
}
trap fix_permissions_trap EXIT INT TERM 0
trap clean_up_trap EXIT INT TERM 0
# Make sure no test results from a previous run remain
fix_permissions
clean_up
rm -rf trial-*
# Build the docker image
@ -277,6 +278,7 @@
-w /build -i \
-v "$PWD:/build" \
-v "$HOME/.ssh:/home/build/.ssh:ro" \
--name=osmo-gsm-tester-virtual \
--cap-add=sys_nice \
$USER/osmo-gsm-tester \
/bin/bash -c 'LANG="en_US.utf8" LC_ALL="en_US.UTF-8" LC_LANG="en_US.UTF-8" PATH="$PWD/osmo-gsm-tester/src:${PATH}" ./osmo-gsm-tester/contrib/jenkins-run.sh'

View File

@ -18,7 +18,7 @@ kill_docker_containers_running_longer_than_24h() {
fi
case "$name" in
jenkins-*|*ttcn3*) ;;
jenkins-*|*ttcn3*|osmo-gsm-tester*) ;;
*)
echo "$name: does not match name pattern"
continue