osmith has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ci/+/35362?usp=email )


Change subject: jobs/osmo-gsm-tester-virtual: kill old instances
......................................................................

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
---
M jobs/osmo-gsm-tester-runner.yml
M scripts/docker-cleanup.sh
2 files changed, 31 insertions(+), 7 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ci refs/changes/62/35362/1

diff --git a/jobs/osmo-gsm-tester-runner.yml b/jobs/osmo-gsm-tester-runner.yml
index 83040dc..4909fe7 100644
--- a/jobs/osmo-gsm-tester-runner.yml
+++ b/jobs/osmo-gsm-tester-runner.yml
@@ -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'
diff --git a/scripts/docker-cleanup.sh b/scripts/docker-cleanup.sh
index b905d3c..982ccea 100755
--- a/scripts/docker-cleanup.sh
+++ b/scripts/docker-cleanup.sh
@@ -18,7 +18,7 @@
                fi

                case "$name" in
-               jenkins-*|*ttcn3*) ;;
+               jenkins-*|*ttcn3*|osmo-gsm-tester*) ;;
                *)
                        echo "$name: does not match name pattern"
                        continue

--
To view, visit https://gerrit.osmocom.org/c/osmo-ci/+/35362?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-Change-Id: I6fc874d319d74aabdc33c10910cbcca2978d5bbb
Gerrit-Change-Number: 35362
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osm...@sysmocom.de>
Gerrit-MessageType: newchange

Reply via email to