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 2016/01/28 02:53:57 UTC
[1/2] mesos git commit: Relaxed the subsystem check for cgroups
net_cls isolator.
Repository: mesos
Updated Branches:
refs/heads/master db6e26d6c -> 46956319d
Relaxed the subsystem check for cgroups net_cls isolator.
The check ensures that only the net_cls and net_prio subsystem can be
mounted in the same hierarchy.
Review: https://reviews.apache.org/r/42872/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/856957cd
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/856957cd
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/856957cd
Branch: refs/heads/master
Commit: 856957cdaed80dfe759b378182862ee4fc8504fc
Parents: db6e26d
Author: Avinash sridharan <av...@mesosphere.io>
Authored: Wed Jan 27 17:22:59 2016 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed Jan 27 17:30:00 2016 -0800
----------------------------------------------------------------------
.../mesos/isolators/cgroups/net_cls.cpp | 22 ++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/856957cd/src/slave/containerizer/mesos/isolators/cgroups/net_cls.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/cgroups/net_cls.cpp b/src/slave/containerizer/mesos/isolators/cgroups/net_cls.cpp
index 03a488e..ddc1bf0 100644
--- a/src/slave/containerizer/mesos/isolators/cgroups/net_cls.cpp
+++ b/src/slave/containerizer/mesos/isolators/cgroups/net_cls.cpp
@@ -72,16 +72,26 @@ Try<Isolator*> CgroupsNetClsIsolatorProcess::create(const Flags& flags)
return Error("Failed to create net_cls cgroup: " + hierarchy.error());
}
- // Ensure that no other subsystem is attached to the hierarchy.
+ // Ensure that no unexpected subsystem is attached to the hierarchy.
Try<set<string>> subsystems = cgroups::subsystems(hierarchy.get());
if (subsystems.isError()) {
return Error(
- "Failed to get the list of attached subsystems for hierarchy " +
- hierarchy.get());
+ "Failed to get the list of attached subsystems for hierarchy "
+ "'" + hierarchy.get() + "'");
} else if (subsystems.get().size() != 1) {
- return Error(
- "Unexpected subsystems found attached to the hierarchy " +
- hierarchy.get());
+ // Some Linux distributions mount net_cls and net_prio subsystems
+ // to the same hierarchy.
+ // TODO(jieyu): If we ever introduce a cgroups net_prio isolator,
+ // we need to make sure it will not conflict with this isolator if
+ // two subsystems are co-mounted into the same hierarchy. For
+ // instance, we should not remove a cgroup twice.
+ foreach (const string& subsystem, subsystems.get()) {
+ if (subsystem != "net_cls" && subsystem != "net_prio") {
+ return Error(
+ "Unexpected subsystems found attached to hierarchy "
+ "'" + hierarchy.get() + "'");
+ }
+ }
}
process::Owned<MesosIsolatorProcess> process(
[2/2] mesos git commit: Fixed the NetClsIsolatorTest to correctly
learn the net_cls hierarchy.
Posted by ji...@apache.org.
Fixed the NetClsIsolatorTest to correctly learn the net_cls hierarchy.
The test relied on the flags.cgroups_hierarchy to learn the net_cls
hierarchy, instead it should be making a call to cgroups::hierarchy to
learn the hierarchy.
Review: https://reviews.apache.org/r/42878/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/46956319
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/46956319
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/46956319
Branch: refs/heads/master
Commit: 46956319de210af6d5a763f02901005c4879810b
Parents: 856957c
Author: Avinash sridharan <av...@mesosphere.io>
Authored: Wed Jan 27 17:31:14 2016 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed Jan 27 17:44:20 2016 -0800
----------------------------------------------------------------------
src/tests/containerizer/isolator_tests.cpp | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/46956319/src/tests/containerizer/isolator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/isolator_tests.cpp b/src/tests/containerizer/isolator_tests.cpp
index 7033ac1..8d101df 100644
--- a/src/tests/containerizer/isolator_tests.cpp
+++ b/src/tests/containerizer/isolator_tests.cpp
@@ -867,6 +867,7 @@ TEST_F(NetClsIsolatorTest, ROOT_CGROUPS_NetClsIsolate)
Try<MesosContainerizer*> containerizer =
MesosContainerizer::create(flags, true, &fetcher);
+
ASSERT_SOME(containerizer);
Try<PID<Slave>> slave = StartSlave(containerizer.get(), flags);
@@ -914,15 +915,16 @@ TEST_F(NetClsIsolatorTest, ROOT_CGROUPS_NetClsIsolate)
const ContainerID& containerID = *(containers.get().begin());
- // Check if the net_cls cgroup for this container exists, by checking for the
- // processes associated with this cgroup.
- string container_cgroup = path::join(
+ Result<string> hierarchy = cgroups::hierarchy("net_cls");
+ ASSERT_SOME(hierarchy);
+
+ // Check if the net_cls cgroup for this container exists, by
+ // checking for the processes associated with this cgroup.
+ string cgroup = path::join(
flags.cgroups_root,
containerID.value());
- Try<set<pid_t>> pids = cgroups::processes(
- path::join(flags.cgroups_hierarchy, "net_cls"),
- container_cgroup);
+ Try<set<pid_t>> pids = cgroups::processes(hierarchy.get(), cgroup);
ASSERT_SOME(pids);
// There should be at least one TGID associated with this cgroup.
@@ -945,7 +947,7 @@ TEST_F(NetClsIsolatorTest, ROOT_CGROUPS_NetClsIsolate)
// If the cleanup is successful the net_cls cgroup for this container should
// not exist.
- ASSERT_FALSE(os::exists(container_cgroup));
+ ASSERT_FALSE(os::exists(cgroup));
driver.stop();
driver.join();