yetus-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [1/2] yetus git commit: YETUS-580. build a wrapper around docker in jenkins mode
Date Fri, 10 Nov 2017 15:38:44 GMT
Repository: yetus
Updated Branches:
  refs/heads/master 1dcbbeb3f -> dae92001d


YETUS-580. build a wrapper around docker in jenkins mode

Signed-off-by: Sean Busbey <busbey@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/yetus/repo
Commit: http://git-wip-us.apache.org/repos/asf/yetus/commit/26dd3dd6
Tree: http://git-wip-us.apache.org/repos/asf/yetus/tree/26dd3dd6
Diff: http://git-wip-us.apache.org/repos/asf/yetus/diff/26dd3dd6

Branch: refs/heads/master
Commit: 26dd3dd6d6cfa106fd926b2220eb9557dc73877b
Parents: 1dcbbeb
Author: Allen Wittenauer <aw@apache.org>
Authored: Sat Nov 4 11:41:19 2017 -0700
Committer: Allen Wittenauer <aw@apache.org>
Committed: Fri Nov 10 07:36:56 2017 -0800

----------------------------------------------------------------------
 precommit/core.d/docker.sh | 72 ++++++++++++++++++++++++-----------------
 1 file changed, 43 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/yetus/blob/26dd3dd6/precommit/core.d/docker.sh
----------------------------------------------------------------------
diff --git a/precommit/core.d/docker.sh b/precommit/core.d/docker.sh
index 6b06892..a67e553 100755
--- a/precommit/core.d/docker.sh
+++ b/precommit/core.d/docker.sh
@@ -592,48 +592,62 @@ PatchSpecificDocker
     DOCKER_EXTRAARGS+=("-m" "${DOCKER_MEMORY}")
   fi
 
-  # make the kernel prefer to kill us if we run out of RAM
-  DOCKER_EXTRAARGS+=("--oom-score-adj" "500")
-
   client=$(docker_version Client)
   server=$(docker_version Server)
 
   dockerversion="Client=${client} Server=${server}"
+
+
+  # make the kernel prefer to kill us if we run out of RAM
+  DOCKER_EXTRAARGS+=("--oom-score-adj" "500")
+
+  DOCKER_EXTRAARGS+=("--cidfile=${PATCH_DIR}/cidfile")
+  DOCKER_EXTRAARGS+=(-v "${PWD}:/testptch/${PROJECT_NAME}")
+  DOCKER_EXTRAARGS+=(-u "${USER_NAME}")
+  DOCKER_EXTRAARGS+=(-w "/testptch/${PROJECT_NAME}")
+  DOCKER_EXTRAARGS+=("--env=BASEDIR=/testptch/${PROJECT_NAME}")
+  DOCKER_EXTRAARGS+=("--env=DOCKER_VERSION=${dockerversion} Image:${baseimagename}")
+  DOCKER_EXTRAARGS+=("--env=JAVA_HOME=${JAVA_HOME}")
+  DOCKER_EXTRAARGS+=("--env=PATCH_SYSTEM=${PATCH_SYSTEM}")
+  DOCKER_EXTRAARGS+=("--env=PROJECT_NAME=${PROJECT_NAME}")
+  DOCKER_EXTRAARGS+=("--env=TESTPATCHMODE=${TESTPATCHMODE}")
+  DOCKER_EXTRAARGS+=(--name "${containername}")
+
+
+  trap 'docker_signal_handler' SIGTERM
+  trap 'docker_signal_handler' SIGINT
+
   if [[ ${PATCH_DIR} =~ ^/ ]]; then
-    exec "${DOCKERCMD}" run --rm=true -i \
+    dockercmd run --rm=true -i \
       "${DOCKER_EXTRAARGS[@]}" \
-      -v "${PWD}:/testptch/${PROJECT_NAME}" \
       -v "${PATCH_DIR}:/testptch/patchprocess" \
-      -u "${USER_NAME}" \
-      -w "/testptch/${PROJECT_NAME}" \
-      --env=BASEDIR="/testptch/${PROJECT_NAME}" \
-      --env=DOCKER_VERSION="${dockerversion} Image:${baseimagename}" \
-      --env=JAVA_HOME="${JAVA_HOME}" \
       --env=PATCH_DIR=/testptch/patchprocess \
-      --env=PATCH_SYSTEM="${PATCH_SYSTEM}" \
-      --env=PROJECT_NAME="${PROJECT_NAME}" \
-      --env=TESTPATCHMODE="${TESTPATCHMODE}" \
-      --name "${containername}" \
-      "${patchimagename}"
+      "${patchimagename}" &
   else
-    exec "${DOCKERCMD}" run --rm=true -i \
+    dockercmd run --rm=true -i \
       "${DOCKER_EXTRAARGS[@]}" \
-      -v "${PWD}:/testptch/${PROJECT_NAME}" \
-      -u "${USER_NAME}" \
-      -w "/testptch/${PROJECT_NAME}" \
-      --env=BASEDIR="/testptch/${PROJECT_NAME}" \
-      --env=DOCKER_VERSION="${DOCKER_VERSION} Image:${baseimagename}" \
-      --env=JAVA_HOME="${JAVA_HOME}" \
       --env=PATCH_DIR="${PATCH_DIR}" \
-      --env=PATCH_SYSTEM="${PATCH_SYSTEM}" \
-      --env=PROJECT_NAME="${PROJECT_NAME}" \
-      --env=TESTPATCHMODE="${TESTPATCHMODE}" \
-      --name "${containername}" \
-      "${patchimagename}"
+      "${patchimagename}" &
   fi
 
-  # this should never get reached, but we put it here just in case
-  cleanup_and_exit 1
+  wait ${!}
+  cleanup_and_exit $?
+}
+
+## @description  docker kill the container on SIGTERM
+## @audience     private
+## @stability    evolving
+## @replaceable  no
+function docker_signal_handler
+{
+  declare cid
+
+  cid=$(cat "${PATCH_DIR}/cidfile")
+
+  yetus_error "ERROR: Caught signal. Killing docker container:"
+  dockercmd kill "${cid}"
+  yetus_error "ERROR: Exiting."
+  cleanup_and_exit 143 # 128 + 15 -- SIGTERM
 }
 
 ## @description  Switch over to a Docker container


Mime
View raw message