You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2018/07/02 06:23:55 UTC

[5/7] mesos git commit: Updated flags to support choosing the random sorter.

Updated flags to support choosing the random sorter.

This deprecates `--user_sorter` in favor of `--role_sorter`.

This patch also modifies the `--allocator` default to exclude "DRF"
from the value, while still ensuring the previous default works.

For now, both sorter flags must be set to `drf` or `random`.

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


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

Branch: refs/heads/1.4.x
Commit: 1addca384b0382361bcf960ac4c2c2732d4589cd
Parents: 1aa69d0
Author: Benjamin Mahler <bm...@apache.org>
Authored: Mon Jun 4 15:17:39 2018 -0400
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Sun Jul 1 15:03:41 2018 -0700

----------------------------------------------------------------------
 include/mesos/allocator/allocator.hpp |  8 +++++++-
 src/master/allocator/allocator.cpp    | 24 +++++++++++++++++++++---
 src/master/constants.hpp              |  4 ++--
 src/master/flags.cpp                  | 12 +++++++-----
 src/master/flags.hpp                  |  2 +-
 src/master/main.cpp                   | 12 +++++++-----
 6 files changed, 45 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/1addca38/include/mesos/allocator/allocator.hpp
----------------------------------------------------------------------
diff --git a/include/mesos/allocator/allocator.hpp b/include/mesos/allocator/allocator.hpp
index 537658b..8bbd7fb 100644
--- a/include/mesos/allocator/allocator.hpp
+++ b/include/mesos/allocator/allocator.hpp
@@ -60,9 +60,15 @@ public:
    * allocator instance from a module using the given name. If `Try`
    * does not report an error, the wrapped `Allocator*` is not null.
    *
+   * TODO(bmahler): Figure out how to pass parameters without
+   * burning in the built-in module arguments.
+   *
    * @param name Name of the allocator.
    */
-  static Try<Allocator*> create(const std::string& name);
+  static Try<Allocator*> create(
+      const std::string& name,
+      const std::string& roleSorter,
+      const std::string& frameworkSorter);
 
   Allocator() {}
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/1addca38/src/master/allocator/allocator.cpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/allocator.cpp b/src/master/allocator/allocator.cpp
index e3dd737..4357436 100644
--- a/src/master/allocator/allocator.cpp
+++ b/src/master/allocator/allocator.cpp
@@ -27,18 +27,36 @@
 using std::string;
 
 using mesos::internal::master::allocator::HierarchicalDRFAllocator;
+using mesos::internal::master::allocator::HierarchicalRandomAllocator;
 
 namespace mesos {
 namespace allocator {
 
-Try<Allocator*> Allocator::create(const string& name)
+Try<Allocator*> Allocator::create(
+    const string& name,
+    const string& roleSorter,
+    const string& frameworkSorter)
 {
   // Create an instance of the default allocator. If other than the
   // default allocator is requested, search for it in loaded modules.
+  //
   // NOTE: We do not need an extra not-null check, because both
   // ModuleManager and built-in allocator factory do that already.
-  if (name == mesos::internal::master::DEFAULT_ALLOCATOR) {
-    return HierarchicalDRFAllocator::create();
+  //
+  // We also look for "HierarchicalDRF" since that was the
+  // previous value for `DEFAULT_ALLOCATOR`.
+  if (name == "HierarchicalDRF" ||
+      name == mesos::internal::master::DEFAULT_ALLOCATOR) {
+    if (roleSorter == "drf" && frameworkSorter == "drf") {
+      return HierarchicalDRFAllocator::create();
+    }
+
+    if (roleSorter == "random" && frameworkSorter == "random") {
+      return HierarchicalRandomAllocator::create();
+    }
+
+    return Error("Unsupported combination of 'role_sorter'"
+                 " and 'framework_sorter': must be equal (for now)");
   }
 
   return modules::ModuleManager::create<Allocator>(name);

http://git-wip-us.apache.org/repos/asf/mesos/blob/1addca38/src/master/constants.hpp
----------------------------------------------------------------------
diff --git a/src/master/constants.hpp b/src/master/constants.hpp
index 725680b..c35ed45 100644
--- a/src/master/constants.hpp
+++ b/src/master/constants.hpp
@@ -125,8 +125,8 @@ constexpr Duration ZOOKEEPER_SESSION_TIMEOUT = Seconds(10);
 // Name of the default, CRAM-MD5 authenticator.
 constexpr char DEFAULT_AUTHENTICATOR[] = "crammd5";
 
-// Name of the default, HierarchicalDRF authenticator.
-constexpr char DEFAULT_ALLOCATOR[] = "HierarchicalDRF";
+// Name of the default hierarchical allocator.
+constexpr char DEFAULT_ALLOCATOR[] = "hierarchical";
 
 // The default interval between allocations.
 constexpr Duration DEFAULT_ALLOCATION_INTERVAL = Seconds(1);

http://git-wip-us.apache.org/repos/asf/mesos/blob/1addca38/src/master/flags.cpp
----------------------------------------------------------------------
diff --git a/src/master/flags.cpp b/src/master/flags.cpp
index fa6d274..ffd9d7e 100644
--- a/src/master/flags.cpp
+++ b/src/master/flags.cpp
@@ -176,15 +176,17 @@ mesos::internal::master::Flags::Flags()
       "machines are accepted. Path can be of the form\n"
       "`file:///path/to/file` or `/path/to/file`.\n");
 
-  add(&Flags::user_sorter,
-      "user_sorter",
-      "Policy to use for allocating resources between users. May be one of:\n"
-      "  dominant_resource_fairness (drf)",
+  add(&Flags::role_sorter,
+      "role_sorter",
+      flags::DeprecatedName("user_sorter"),
+      "Policy to use for allocating resources between roles when\n"
+      "allocating up to quota guarantees as well as when allocating\n"
+      "up to quota limits. May be one of: [drf, random]",
       "drf");
 
   add(&Flags::framework_sorter,
       "framework_sorter",
-      "Policy to use for allocating resources between a given user's\n"
+      "Policy to use for allocating resources between a given role's\n"
       "frameworks. Options are the same as for `--user_sorter`.",
       "drf");
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/1addca38/src/master/flags.hpp
----------------------------------------------------------------------
diff --git a/src/master/flags.hpp b/src/master/flags.hpp
index edda71a..8b1944c 100644
--- a/src/master/flags.hpp
+++ b/src/master/flags.hpp
@@ -60,7 +60,7 @@ public:
   Option<std::string> agent_removal_rate_limit;
   std::string webui_dir;
   Option<Path> whitelist;
-  std::string user_sorter;
+  std::string role_sorter;
   std::string framework_sorter;
   Duration allocation_interval;
   Option<std::string> cluster;

http://git-wip-us.apache.org/repos/asf/mesos/blob/1addca38/src/master/main.cpp
----------------------------------------------------------------------
diff --git a/src/master/main.cpp b/src/master/main.cpp
index 1a78a55..b701870 100644
--- a/src/master/main.cpp
+++ b/src/master/main.cpp
@@ -327,17 +327,19 @@ int main(int argc, char** argv)
   }
 
   // Create an instance of allocator.
-  const string allocatorName = flags.allocator;
-  Try<Allocator*> allocator = Allocator::create(allocatorName);
+  Try<Allocator*> allocator = Allocator::create(
+      flags.allocator,
+      flags.role_sorter,
+      flags.framework_sorter);
 
   if (allocator.isError()) {
     EXIT(EXIT_FAILURE)
-      << "Failed to create '" << allocatorName
-      << "' allocator: " << allocator.error();
+      << "Failed to create allocator '" << flags.allocator << "'"
+      << ": " << allocator.error();
   }
 
   CHECK_NOTNULL(allocator.get());
-  LOG(INFO) << "Using '" << allocatorName << "' allocator";
+  LOG(INFO) << "Using '" << flags.allocator << "' allocator";
 
   Storage* storage = nullptr;
 #ifndef __WINDOWS__