You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2018/01/24 01:33:37 UTC
[1/2] mesos git commit: Fixed resource statistics for Docker
containers being destroyed.
Repository: mesos
Updated Branches:
refs/heads/1.3.x a3513fcc0 -> 762a73578
Fixed resource statistics for Docker containers being destroyed.
If a process has exited, but not reaped yet (zombie procses),
`/proc/<pid>/cgroup` will still exist, but the process's cgroup will be
reset to the root cgroup. In DockerContainerizer, we rely on
`/proc/<pid>/cgroup` to get the cpu/memory statistics of the container.
If the `usage` call happens when the process is a zombie, the cpu/memory
statistics will actually be that of the root cgroup, which is obviously
not correct. See more details in MESOS-8480.
This patch fixed the issue by checking if the cgroup of a given pid is
root cgroup or not.
Review: https://reviews.apache.org/r/65301/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/51ac0ca2
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/51ac0ca2
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/51ac0ca2
Branch: refs/heads/1.3.x
Commit: 51ac0ca25bb0955327fea17f2cfd2eac5b36f6ef
Parents: a3513fc
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
Authored: Tue Jan 23 17:13:05 2018 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Tue Jan 23 17:32:05 2018 -0800
----------------------------------------------------------------------
src/slave/containerizer/docker.cpp | 36 +++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/51ac0ca2/src/slave/containerizer/docker.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/docker.cpp b/src/slave/containerizer/docker.cpp
index 58a85be..c300584 100644
--- a/src/slave/containerizer/docker.cpp
+++ b/src/slave/containerizer/docker.cpp
@@ -1711,6 +1711,13 @@ Future<Nothing> DockerContainerizerProcess::__update(
static Result<string> cpuHierarchy = cgroups::hierarchy("cpu");
static Result<string> memoryHierarchy = cgroups::hierarchy("memory");
+ // NOTE: Normally, a Docker container should be in its own cgroup.
+ // However, a zombie process (exited but not reaped) will be
+ // temporarily moved into the system root cgroup. We add some
+ // defensive check here to make sure we are not changing the knobs
+ // in the root cgroup. See MESOS-8480 for details.
+ const string systemRootCgroup = stringify(os::PATH_SEPARATOR);
+
if (cpuHierarchy.isError()) {
return Failure("Failed to determine the cgroup hierarchy "
"where the 'cpu' subsystem is mounted: " +
@@ -1739,11 +1746,16 @@ Future<Nothing> DockerContainerizerProcess::__update(
LOG(WARNING) << "Container " << containerId
<< " does not appear to be a member of a cgroup"
<< " where the 'cpu' subsystem is mounted";
+ } else if (cpuCgroup.get() == systemRootCgroup) {
+ LOG(WARNING)
+ << "Process '" << pid
+ << "' should not be in the system root cgroup (being destroyed?)";
}
// And update the CPU shares (if applicable).
if (cpuHierarchy.isSome() &&
cpuCgroup.isSome() &&
+ cpuCgroup.get() != systemRootCgroup &&
_resources.cpus().isSome()) {
double cpuShares = _resources.cpus().get();
@@ -1801,11 +1813,16 @@ Future<Nothing> DockerContainerizerProcess::__update(
LOG(WARNING) << "Container " << containerId
<< " does not appear to be a member of a cgroup"
<< " where the 'memory' subsystem is mounted";
+ } else if (memoryCgroup.get() == systemRootCgroup) {
+ LOG(WARNING)
+ << "Process '" << pid
+ << "' should not be in the system root cgroup (being destroyed?)";
}
// And update the memory limits (if applicable).
if (memoryHierarchy.isSome() &&
memoryCgroup.isSome() &&
+ memoryCgroup.get() != systemRootCgroup &&
_resources.mem().isSome()) {
// TODO(tnachen): investigate and handle OOM with docker.
Bytes mem = _resources.mem().get();
@@ -1952,6 +1969,13 @@ Try<ResourceStatistics> DockerContainerizerProcess::cgroupsStatistics(
const Result<string> cpuacctHierarchy = cgroups::hierarchy("cpuacct");
const Result<string> memHierarchy = cgroups::hierarchy("memory");
+ // NOTE: Normally, a Docker container should be in its own cgroup.
+ // However, a zombie process (exited but not reaped) will be
+ // temporarily moved into the system root cgroup. We add some
+ // defensive check here to make sure we are not reporting statistics
+ // for the root cgroup. See MESOS-8480 for details.
+ const string systemRootCgroup = stringify(os::PATH_SEPARATOR);
+
if (cpuacctHierarchy.isError()) {
return Error(
"Failed to determine the cgroup 'cpuacct' subsystem hierarchy: " +
@@ -1971,6 +1995,10 @@ Try<ResourceStatistics> DockerContainerizerProcess::cgroupsStatistics(
cpuacctCgroup.error());
} else if (cpuacctCgroup.isNone()) {
return Error("Unable to find 'cpuacct' cgroup subsystem");
+ } else if (cpuacctCgroup.get() == systemRootCgroup) {
+ return Error(
+ "Process '" + stringify(pid) +
+ "' should not be in the system root cgroup (being destroyed?)");
}
const Result<string> memCgroup = cgroups::memory::cgroup(pid);
@@ -1980,6 +2008,10 @@ Try<ResourceStatistics> DockerContainerizerProcess::cgroupsStatistics(
memCgroup.error());
} else if (memCgroup.isNone()) {
return Error("Unable to find 'memory' cgroup subsystem");
+ } else if (memCgroup.get() == systemRootCgroup) {
+ return Error(
+ "Process '" + stringify(pid) +
+ "' should not be in the system root cgroup (being destroyed?)");
}
const Try<cgroups::cpuacct::Stats> cpuAcctStat =
@@ -2025,6 +2057,10 @@ Try<ResourceStatistics> DockerContainerizerProcess::cgroupsStatistics(
cpuCgroup.error());
} else if (cpuCgroup.isNone()) {
return Error("Unable to find 'cpu' cgroup subsystem");
+ } else if (cpuCgroup.get() == systemRootCgroup) {
+ return Error(
+ "Process '" + stringify(pid) +
+ "' should not be in the system root cgroup (being destroyed?)");
}
const Try<hashmap<string, uint64_t>> stat =
[2/2] mesos git commit: Added MESOS-8480 to the 1.3.2 CHANGELOG.
Posted by ji...@apache.org.
Added MESOS-8480 to the 1.3.2 CHANGELOG.
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/762a7357
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/762a7357
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/762a7357
Branch: refs/heads/1.3.x
Commit: 762a73578fb5567a5d06d4d294dedf561258ed03
Parents: 51ac0ca
Author: Jie Yu <yu...@gmail.com>
Authored: Tue Jan 23 17:33:11 2018 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Tue Jan 23 17:33:31 2018 -0800
----------------------------------------------------------------------
CHANGELOG | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/762a7357/CHANGELOG
----------------------------------------------------------------------
diff --git a/CHANGELOG b/CHANGELOG
index 98af8b5..26a8b58 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -22,6 +22,7 @@ All Issues:
* [MESOS-8135] - Masters can lose track of tasks' executor IDs.
* [MESOS-8237] - Strip (Offer|Resource).allocation_info for non-MULTI_ROLE schedulers.
* [MESOS-8356] - Persistent volume ownership is set to root despite of sandbox owner (frameworkInfo.user) when docker executor is used.
+ * [MESOS-8480] - Mesos returns high resource usage when killing a Docker task.
Release Notes - Mesos - Version 1.3.1