jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/389937 )
Change subject: docker: handle signals in tox entrypoint
......................................................................
docker: handle signals in tox entrypoint
bash shallows signals and does not relay them to the underlying command.
A typical way to solve it is to use 'exec' and replace bash with the
process. Once the process exits that is the end, the capture_tox_logs
trap does not get executed since bash is long gone.
Instead background the process, that lets bash handle the trap
immediately.
Upon receiving a signal, wait returns immediately. Thus setup trap to
catch SIGTERM/SIGINT and forward them to the tox process.
This way, when running with 'docker run -rm', the containerized process
receives SIGTERM/SIGINT properly, handles it and usually terminate.
Bug: T176747
Change-Id: I44d7c4309a70170d9c93feea5c67569122635b6a
---
M dockerfiles/tox/run.sh
M jjb/python-jobs.yaml
M jjb/search.yaml
3 files changed, 18 insertions(+), 6 deletions(-)
Approvals:
Hashar: Looks good to me, approved
jenkins-bot: Verified
diff --git a/dockerfiles/tox/run.sh b/dockerfiles/tox/run.sh
index d049627..2c71477 100755
--- a/dockerfiles/tox/run.sh
+++ b/dockerfiles/tox/run.sh
@@ -23,6 +23,18 @@
trap capture_tox_logs EXIT
-# Run tests. Pass all environment variables to tox since the environment here
-# is already pretty restrictive.
-TOX_TESTENV_PASSENV="*" PY_COLORS=1 tox -v "${@}"
+function relay_signals() {
+ for signal ; do
+ trap 'kill -$signal $tox_pid; wait $tox_pid' "$signal"
+ done
+}
+
+# Run tests.
+# Pass all environment variables to tox since the environment here is already
+# pretty restrictive.
+# tox is backgrounded in bash job control to let bash handles traps (eg
+# SIGTERM) immediately. That is merely to capture the testenv log files.
+TOX_TESTENV_PASSENV="*" PY_COLORS=1 tox -v "${@}" &
+tox_pid=$!
+relay_signals SIGINT SIGTERM
+wait "$tox_pid"
diff --git a/jjb/python-jobs.yaml b/jjb/python-jobs.yaml
index 7c97652..0037750 100644
--- a/jjb/python-jobs.yaml
+++ b/jjb/python-jobs.yaml
@@ -68,7 +68,7 @@
name: 'tox-docker'
node: DebianJessieDocker
concurrent: true
- docker_image_var: 'wmfreleng/tox:v2017.11.10.16.17'
+ docker_image_var: 'wmfreleng/tox:v2017.11.10.21.35'
triggers:
- zuul
builders:
@@ -103,7 +103,7 @@
- docker-zuul-env
- docker-log-dir
- docker-run-with-log-and-workspace-cache:
- image: 'wmfreleng/tox:v2017.11.10.16.17'
+ image: 'wmfreleng/tox:v2017.11.10.21.35'
logdir: '/log'
run_args: ' -e "{toxenv}"'
diff --git a/jjb/search.yaml b/jjb/search.yaml
index 4575b35..7de8989 100644
--- a/jjb/search.yaml
+++ b/jjb/search.yaml
@@ -20,7 +20,7 @@
name: search-mjolnir
jobs:
- '{name}-tox-docker':
- docker_image_var: wmfreleng/tox-pyspark:v2017.11.10.11.49
+ docker_image_var: wmfreleng/tox-pyspark:v2017.11.10.21.37
build_timeout: 6 # minutes
# Sadly this does not test the python code with the jvm code, instead
# using the last release of the jvm code, But it's a good start.
--
To view, visit https://gerrit.wikimedia.org/r/389937
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I44d7c4309a70170d9c93feea5c67569122635b6a
Gerrit-PatchSet: 5
Gerrit-Project: integration/config
Gerrit-Branch: master
Gerrit-Owner: Hashar <[email protected]>
Gerrit-Reviewer: Hashar <[email protected]>
Gerrit-Reviewer: Paladox <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits