mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ji...@apache.org
Subject [1/3] mesos git commit: Fixed the cgroup issue in the Mesos mini container.
Date Sun, 25 Feb 2018 05:40:56 GMT
Repository: mesos
Updated Branches:
  refs/heads/master 3f01bd85c -> a566d0e29


Fixed the cgroup issue in the Mesos mini container.

For each cgroup subsystem, Docker does a bind mount from the current
cgroup to the root of the cgroup subsystem. For instance:
/sys/fs/cgroup/memory/docker/<cid> -> /sys/fs/cgroup/memory

This will confuse Mesos agent because it relies on proc file
'/proc/<pid>/cgroup` to determine the cgroup of a given process, and
this proc file is not affected by the bind mount.

This patch added a workaround to recreate the original cgroup
environment by doing another bind mount for each subsystem.


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

Branch: refs/heads/master
Commit: a566d0e292ddbb84959ab1605bcb8f3583588a00
Parents: 3b61c4b
Author: Jie Yu <yujie.jay@gmail.com>
Authored: Sat Feb 24 21:38:24 2018 -0800
Committer: Jie Yu <yujie.jay@gmail.com>
Committed: Sat Feb 24 21:40:50 2018 -0800

----------------------------------------------------------------------
 support/mesos-mini/Dockerfile    | 23 ++++++++++++-----------
 support/mesos-mini/entrypoint.sh | 26 ++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/a566d0e2/support/mesos-mini/Dockerfile
----------------------------------------------------------------------
diff --git a/support/mesos-mini/Dockerfile b/support/mesos-mini/Dockerfile
index 32ac895..29761a2 100644
--- a/support/mesos-mini/Dockerfile
+++ b/support/mesos-mini/Dockerfile
@@ -1,4 +1,5 @@
-FROM mesos/mesos-centos
+#FROM mesos/mesos-centos
+FROM jieyu/mesos
 
 RUN yum install -y java-1.8.0-openjdk iptables
 
@@ -27,16 +28,12 @@ RUN for service in\
     systemd-vconsole-setup.service\
     ; do systemctl mask $service; done
 
-CMD ["/usr/sbin/init"]
-
-STOPSIGNAL SIGRTMIN+3
-
 # Prepare Docker environment.
-ARG DOCKER_RUL=https://download.docker.com/linux/static/stable/x86_64/docker-17.12.0-ce.tgz
+ARG DOCKER_URL=https://download.docker.com/linux/static/stable/x86_64/docker-17.12.0-ce.tgz
 
 RUN mkdir -p /etc/docker && \
     touch /etc/docker/env && \
-    curl -s $DOCKER_RUL -o /docker.tgz && \
+    curl -s $DOCKER_URL -o /docker.tgz && \
     tar -xzvf /docker.tgz -C /usr/local/bin --strip 1 && \
     rm -f /docker.tgz
 
@@ -66,7 +63,11 @@ RUN mkdir -p $MARATHON_INSTALL_DIR && \
 COPY marathon.sh $MARATHON_INSTALL_DIR/bin/
 COPY marathon.service /usr/lib/systemd/system/marathon.service
 
-RUN systemctl enable docker && \
-    systemctl enable mesos-slave && \
-    systemctl enable mesos-master && \
-    systemctl enable marathon
+RUN systemctl enable docker mesos-slave mesos-master marathon
+
+# Prepare entrypoint.
+COPY entrypoint.sh /
+
+CMD ["/entrypoint.sh"]
+
+STOPSIGNAL SIGRTMIN+3

http://git-wip-us.apache.org/repos/asf/mesos/blob/a566d0e2/support/mesos-mini/entrypoint.sh
----------------------------------------------------------------------
diff --git a/support/mesos-mini/entrypoint.sh b/support/mesos-mini/entrypoint.sh
new file mode 100755
index 0000000..8f2d6ef
--- /dev/null
+++ b/support/mesos-mini/entrypoint.sh
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+
+set -o errexit -o nounset -o pipefail
+
+# For each cgroup subsystem, Docker does a bind mount from the current
+# cgroup to the root of the cgroup subsystem. For instance:
+#   /sys/fs/cgroup/memory/docker/<cid> -> /sys/fs/cgroup/memory
+#
+# This will confuse Mesos agent because it relies on proc file
+# '/proc/<pid>/cgroup` to determine the cgroup of a given process, and
+# this proc file is not affected by the bind mount.
+#
+# The following is a workaround to recreate the original cgroup
+# environment by doing another bind mount for each subsystem.
+MOUNT_TABLE=$(cat /proc/self/mountinfo)
+DOCKER_CGROUP_MOUNTS=$(echo "${MOUNT_TABLE}" | grep /sys/fs/cgroup | grep docker)
+DOCKER_CGROUP=$(echo "${DOCKER_CGROUP_MOUNTS}" | head -n 1 | cut -d' ' -f 4)
+CGROUP_SUBSYSTEMS=$(echo "${DOCKER_CGROUP_MOUNTS}" | cut -d' ' -f 5)
+
+echo "${CGROUP_SUBSYSTEMS}" |
+while IFS= read -r SUBSYSTEM; do
+  mkdir -p "${SUBSYSTEM}${DOCKER_CGROUP}"
+  mount --bind "${SUBSYSTEM}" "${SUBSYSTEM}${DOCKER_CGROUP}"
+done
+
+exec /usr/sbin/init


Mime
View raw message