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/03/01 23:28:30 UTC

[2/4] mesos git commit: Introduced the `--cgroups_net_cls_secondary_handles` flag in the agent.

Introduced the `--cgroups_net_cls_secondary_handles` flag in the agent.

Review: https://reviews.apache.org/r/43915/


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

Branch: refs/heads/master
Commit: c91d29996bafad04ac0b3ceb2d251a88f9b2c5eb
Parents: 10760c3
Author: Avinash sridharan <av...@mesosphere.io>
Authored: Tue Mar 1 14:27:50 2016 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Tue Mar 1 14:27:50 2016 -0800

----------------------------------------------------------------------
 .../mesos/isolators/cgroups/net_cls.cpp         | 45 ++++++++++++++++++++
 src/slave/flags.cpp                             |  6 +++
 src/slave/flags.hpp                             |  1 +
 3 files changed, 52 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/c91d2999/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 8f5e841..e886f7e 100644
--- a/src/slave/containerizer/mesos/isolators/cgroups/net_cls.cpp
+++ b/src/slave/containerizer/mesos/isolators/cgroups/net_cls.cpp
@@ -276,6 +276,7 @@ Try<Isolator*> CgroupsNetClsIsolatorProcess::create(const Flags& flags)
   IntervalSet<uint32_t> primaries;
   IntervalSet<uint32_t> secondaries;
 
+  // Primary handle.
   if (flags.cgroups_net_cls_primary_handle.isSome()) {
     Try<uint16_t> primary = numify<uint16_t>(
         flags.cgroups_net_cls_primary_handle.get());
@@ -290,6 +291,50 @@ Try<Isolator*> CgroupsNetClsIsolatorProcess::create(const Flags& flags)
     primaries +=
       (Bound<uint32_t>::closed(primary.get()),
        Bound<uint32_t>::closed(primary.get()));
+
+    // Range of valid secondary handles.
+    if (flags.cgroups_net_cls_secondary_handles.isSome()) {
+      vector<string> range =
+        strings::tokenize(flags.cgroups_net_cls_secondary_handles.get(), ",");
+
+      if (range.size() != 2) {
+        return Error(
+            "Failed to parse the range of secondary handles " +
+            flags.cgroups_net_cls_secondary_handles.get() +
+            " set in flag --cgroups_net_cls_secondary_handles");
+      }
+
+      Try<uint16_t> lower = numify<uint16_t>(range[0]);
+      if (lower.isError()) {
+        return Error(
+            "Failed to parse the lower bound of range of secondary handles" +
+            flags.cgroups_net_cls_secondary_handles.get() +
+            " set in flag --cgroups_net_cls_secondary_handles");
+      }
+
+      if (lower.get() == 0) {
+        return Error("The secondary handle has to be a non-zero value.");
+      }
+
+      Try<uint16_t> upper =  numify<uint16_t>(range[1]);
+      if (upper.isError()) {
+        return Error(
+            "Failed to parse the upper bound of range of secondary handles" +
+            flags.cgroups_net_cls_secondary_handles.get() +
+            " set in flag --cgroups_net_cls_secondary_handles");
+      }
+
+      secondaries +=
+        (Bound<uint32_t>::closed(lower.get()),
+         Bound<uint32_t>::closed(upper.get()));
+
+      if (secondaries.empty()) {
+        return Error(
+            "Secondary handle range specified " +
+            flags.cgroups_net_cls_secondary_handles.get() +
+            ", in flag --cgroups_net_cls_secondary_handles, is an empty set");
+      }
+    }
   }
 
   process::Owned<MesosIsolatorProcess> process(

http://git-wip-us.apache.org/repos/asf/mesos/blob/c91d2999/src/slave/flags.cpp
----------------------------------------------------------------------
diff --git a/src/slave/flags.cpp b/src/slave/flags.cpp
index b0bf3d5..6e3fd69 100644
--- a/src/slave/flags.cpp
+++ b/src/slave/flags.cpp
@@ -346,6 +346,12 @@ mesos::internal::slave::Flags::Flags()
       "A non-zero, 16-bit handle of the form `0xAAAA`. This will be \n"
       "used as the primary handle for the net_cls cgroup.");
 
+  add(&Flags::cgroups_net_cls_secondary_handles,
+      "cgroups_net_cls_secondary_handles",
+      "A range of the form 0xAAAA,0xBBBB, specifying the valid secondary\n"
+      "handles that can be used with the primary handle. This will take\n"
+      "effect only when the `--cgroups_net_cls_primary_handle is set.");
+
   add(&Flags::slave_subsystems,
       "slave_subsystems",
       "List of comma-separated cgroup subsystems to run the slave binary\n"

http://git-wip-us.apache.org/repos/asf/mesos/blob/c91d2999/src/slave/flags.hpp
----------------------------------------------------------------------
diff --git a/src/slave/flags.hpp b/src/slave/flags.hpp
index c079321..feb095d 100644
--- a/src/slave/flags.hpp
+++ b/src/slave/flags.hpp
@@ -88,6 +88,7 @@ public:
   bool cgroups_limit_swap;
   bool cgroups_cpu_enable_pids_and_tids_count;
   Option<std::string> cgroups_net_cls_primary_handle;
+  Option<std::string> cgroups_net_cls_secondary_handles;
   Option<std::string> slave_subsystems;
   Option<std::string> perf_events;
   Duration perf_interval;