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 2017/02/27 23:24:01 UTC

[3/6] mesos git commit: Prevent resource of old agents being allocated to MULTI_ROLE frameworks.

Prevent resource of old agents being allocated to MULTI_ROLE frameworks.

In a mixed cluster, when an old agent (not MULTI_ROLE capable)
registers with new master (MULTI_ROLE capable), it cannot correctly
handle tasks from a MULTI_ROLE framework. Therefore, we should
disallow resources from these agents being allocated to MULTI_ROLE
frameworks.

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


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

Branch: refs/heads/master
Commit: 6e60272134f3c1c37787aa91b6571017d62a5875
Parents: fa49f6c
Author: Jay Guo <gu...@gmail.com>
Authored: Mon Feb 27 14:24:26 2017 -0800
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Mon Feb 27 15:09:44 2017 -0800

----------------------------------------------------------------------
 src/master/allocator/mesos/hierarchical.cpp | 13 ++++++++++
 src/tests/hierarchical_allocator_tests.cpp  | 30 ++++++++++++++++++++++++
 2 files changed, 43 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/6e602721/src/master/allocator/mesos/hierarchical.cpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/mesos/hierarchical.cpp b/src/master/allocator/mesos/hierarchical.cpp
index 25fb7c5..a406c31 100644
--- a/src/master/allocator/mesos/hierarchical.cpp
+++ b/src/master/allocator/mesos/hierarchical.cpp
@@ -2025,6 +2025,19 @@ bool HierarchicalAllocatorProcess::isFiltered(
   CHECK(slaves.contains(slaveId));
 
   const Framework& framework = frameworks.at(frameworkId);
+  const Slave& slave = slaves.at(slaveId);
+
+  // Prevent offers from non-MULTI_ROLE agents to be allocated
+  // to MULTI_ROLE frameworks.
+  if (framework.capabilities.multiRole &&
+      !slave.capabilities.multiRole) {
+    LOG(WARNING)
+      << "Implicitly filtering agent " << slaveId << " from framework"
+      << frameworkId << " because the framework is MULTI_ROLE capable"
+      << " but the agent is not";
+
+    return true;
+  }
 
   // Since this is a performance-sensitive piece of code,
   // we use find to avoid the doing any redundant lookups.

http://git-wip-us.apache.org/repos/asf/mesos/blob/6e602721/src/tests/hierarchical_allocator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/hierarchical_allocator_tests.cpp b/src/tests/hierarchical_allocator_tests.cpp
index b52964a..f360bf7 100644
--- a/src/tests/hierarchical_allocator_tests.cpp
+++ b/src/tests/hierarchical_allocator_tests.cpp
@@ -4137,6 +4137,36 @@ TEST_F(HierarchicalAllocatorTest, SuppressAndReviveOffersWithMultiRole)
 }
 
 
+// This test ensures that resources from non-MULTI_ROLE should not be
+// allocated to MULTI_ROLE framework.
+TEST_F(HierarchicalAllocatorTest, DontOfferOldAgentToMultiRoleFramework)
+{
+  // Pausing the clock is not necessary, but ensures that the test
+  // doesn't rely on the batch allocation in the allocator, which
+  // would slow down the test.
+  Clock::pause();
+
+  initialize();
+
+  FrameworkInfo framework = createFrameworkInfo(
+      {"foo"},
+      {FrameworkInfo::Capability::MULTI_ROLE});
+
+  allocator->addFramework(framework.id(), framework, {}, true);
+
+  // Total cluster resources will become cpus=2, mem=1024.
+  SlaveInfo agent = createSlaveInfo("cpus:2;mem:1024;disk:0");
+  allocator->addSlave(agent.id(), agent, {}, None(), agent.resources(), {});
+
+  // Advance the clock to trigger a batch allocation.
+  Clock::advance(flags.allocation_interval);
+  Clock::settle();
+
+  Future<Allocation> allocation = allocations.get();
+  EXPECT_TRUE(allocation.isPending());
+}
+
+
 // This tests the behavior of quota when the allocation and
 // quota are disproportionate. The current approach (see MESOS-6432)
 // is to stop allocation quota once one of the resource