JanZerebecki has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/258140

Change subject: Work around race condition in TMPDIR creation/cleanup
......................................................................

Work around race condition in TMPDIR creation/cleanup

Bug: T120824
Change-Id: I1ee035fd00dff2a5d495367b1b8437f523b60c3a
---
M bin/global-set-env.sh
M bin/global-setup.sh
2 files changed, 12 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/integration/jenkins 
refs/changes/40/258140/1

diff --git a/bin/global-set-env.sh b/bin/global-set-env.sh
index 59254fd..0bfb6cd 100755
--- a/bin/global-set-env.sh
+++ b/bin/global-set-env.sh
@@ -7,11 +7,21 @@
 # Dependent scripts/builders that have issues related to tmpfs, or a non-root
 # temporary filesystem, can set `SKIP_TMPFS` to keep keep the temporary
 # directory under /tmp.
+
+# to avoid race conditions the unique temporary directory for each executor is
+# created when setting the environment variable
+# it has an additional suffix because it seems while cleanup is running (during
+# publishers phase in jenkins job builder) jenkins already runs another job as
+# the same executor, see https://phabricator.wikimedia.org/T120824
 if [ -d "$HOME/tmpfs" ] && [ -z "${SKIP_TMPFS:-}" ]; then
        # All slaves should have tmpfs mounted, use if available
-       export TMPDIR="$HOME/tmpfs/jenkins-${EXECUTOR_NUMBER}"
+       mkdir -p "$HOME/tmpfs"
+       TMPDIR="$HOME/tmpfs/jenkins-${EXECUTOR_NUMBER}-tmp.XXXXXXXXXX"
+       export TMPDIR="$(mktemp --directory $TMPDIR)"
 else
-       export TMPDIR="/tmp/jenkins-${EXECUTOR_NUMBER}"
+       mkdir -p "/tmp"
+       TMPDIR="/tmp/jenkins-${EXECUTOR_NUMBER}-tmp.XXXXXXXXXX"
+       export TMPDIR="$(mktemp --directory $TMPDIR)"
 fi
 
 # Integration slaves have an Xvfb window with server number 94 reserved for
diff --git a/bin/global-setup.sh b/bin/global-setup.sh
index c35804d..354ccc3 100755
--- a/bin/global-setup.sh
+++ b/bin/global-setup.sh
@@ -2,5 +2,4 @@
 
 . /srv/deployment/integration/slave-scripts/bin/global-set-env.sh
 
-mkdir -p "$TMPDIR"
 chmod 777 "$TMPDIR"

-- 
To view, visit https://gerrit.wikimedia.org/r/258140
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1ee035fd00dff2a5d495367b1b8437f523b60c3a
Gerrit-PatchSet: 1
Gerrit-Project: integration/jenkins
Gerrit-Branch: master
Gerrit-Owner: JanZerebecki <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to