summaryrefslogtreecommitdiff
path: root/start-container-docker.sh
diff options
context:
space:
mode:
authorChristophe Lyon <christophe.lyon@linaro.org>2017-03-30 12:53:59 +0000
committerChristophe Lyon <christophe.lyon@linaro.org>2017-03-30 12:55:14 +0000
commite1b6e0f887a1e67c53037e9de8d87405f3c03910 (patch)
tree0eccf078cd081581518db69e6f934031ce7634b1 /start-container-docker.sh
parent4fd25353fb7dc60630a34445ab5632a197383a5d (diff)
start-container-docker.sh: Add --weight option.
To control the resources limits of the docker container (memory, pids, cpu shares). start-container-none.sh, start-container-schroot.sh: Support, but ignore --weight option. (To keep the same interface as start-container-docker.sh). Change-Id: I3a495d9f9027a2a55449c7e03ad387c4681bfbdf
Diffstat (limited to 'start-container-docker.sh')
-rwxr-xr-xstart-container-docker.sh18
1 files changed, 16 insertions, 2 deletions
diff --git a/start-container-docker.sh b/start-container-docker.sh
index 8d26cffb..4ac36c7a 100755
--- a/start-container-docker.sh
+++ b/start-container-docker.sh
@@ -16,7 +16,7 @@ set -e
# and returns shell statements to export the related variables. In
# this case, it also defines ${SSH_AGENT_CLEANUP}.
usage() {
- echo "Usage: $0 --arch container-arch --distro flavour [--session-host host] [--session-name name] [--task {build|test}]"
+ echo "Usage: $0 --arch container-arch --distro flavour [--session-host host] [--session-name name] [--task {build|test}] [--weight weight]"
echo
echo " container-arch: architecture (eg: amd64, i386, arm64, armhf)"
echo " distro: distribution (eg: trusty)"
@@ -24,6 +24,7 @@ usage() {
echo " useful if the name resolution does not work correctly"
echo " session-name: session, in case the default '$BUILD_NUMBER-$JOB_NAME' is not suitable"
echo " task: type of container (build or test, default=build)"
+ echo " weight: container weight, reserves resources. Default=1"
exit 1
}
@@ -38,6 +39,7 @@ distro=
session_host=
session_name=
task="build"
+weight=1
while [ $# -ge 1 ]
do
@@ -67,6 +69,11 @@ do
[ x${task} = x ] && usage
shift 2
;;
+ --weight)
+ weight=$2
+ [ x${weight} = x ] && usage
+ shift 2
+ ;;
*)
echo "Unsupported option: $1"
usage
@@ -120,11 +127,18 @@ case ${container_arch} in
;;
esac
+# Reserve resources according to weight
+memory=$(( $weight * 7500 )) # 7.5GB per executor
+pids=$(( $weight * 5000 )) # 5000 processes per executor
+cpus=$(( $weight * 1000 )) # 1000 cpu shares per executor
+
session_id=$($DOCKER run --name $session_name -dtP \
-v $HOME/snapshots-ref:$HOME/snapshots-ref:ro \
-v $WORKSPACE:$WORKSPACE \
${SECURITY} \
- --memory=7500M --pids-limit=5000 \
+ --memory=${memory}M \
+ --pids-limit=${pids} \
+ --cpu-shares=${cpus} \
$image)
if [ x"$session_id" = x ]; then