You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2016/01/15 19:26:53 UTC
mesos git commit: Cleared `suppressed` in the allocator when the
framework is deactivated.
Repository: mesos
Updated Branches:
refs/heads/master 1d678bdf6 -> 195d5578a
Cleared `suppressed` in the allocator when the framework is deactivated.
Review: https://reviews.apache.org/r/39628/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/195d5578
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/195d5578
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/195d5578
Branch: refs/heads/master
Commit: 195d5578ac8747ee642430137ef178439578fc90
Parents: 1d678bd
Author: Guangya Liu <gy...@gmail.com>
Authored: Fri Jan 15 09:47:41 2016 -0800
Committer: Vinod Kone <vi...@gmail.com>
Committed: Fri Jan 15 10:26:36 2016 -0800
----------------------------------------------------------------------
src/master/allocator/mesos/hierarchical.cpp | 4 ++
src/tests/hierarchical_allocator_tests.cpp | 60 ++++++++++++++++++++++++
2 files changed, 64 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/195d5578/src/master/allocator/mesos/hierarchical.cpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/mesos/hierarchical.cpp b/src/master/allocator/mesos/hierarchical.cpp
index d541bfa..512aaed 100644
--- a/src/master/allocator/mesos/hierarchical.cpp
+++ b/src/master/allocator/mesos/hierarchical.cpp
@@ -362,6 +362,10 @@ void HierarchicalAllocatorProcess::deactivateFramework(
frameworks[frameworkId].offerFilters.clear();
frameworks[frameworkId].inverseOfferFilters.clear();
+ // Clear the suppressed flag to make sure the framework can be offered
+ // resources immediately after getting activated.
+ frameworks[frameworkId].suppressed = false;
+
LOG(INFO) << "Deactivated framework " << frameworkId;
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/195d5578/src/tests/hierarchical_allocator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/hierarchical_allocator_tests.cpp b/src/tests/hierarchical_allocator_tests.cpp
index e044f83..769b0e3 100644
--- a/src/tests/hierarchical_allocator_tests.cpp
+++ b/src/tests/hierarchical_allocator_tests.cpp
@@ -1841,6 +1841,66 @@ TEST_F(HierarchicalAllocatorTest, QuotaAbsentFramework)
}
+// This test checks that if a framework suppresses offers, disconnects and
+// reconnects again, it will start receiving resource offers again.
+TEST_F(HierarchicalAllocatorTest, DeactivateAndReactivateFramework)
+{
+ // Pausing the clock is not necessary, but ensures that the test
+ // doesn't rely on the periodic allocation in the allocator, which
+ // would slow down the test.
+ Clock::pause();
+
+ initialize();
+
+ hashmap<FrameworkID, Resources> EMPTY;
+
+ // 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(), EMPTY);
+
+ // Framework will be offered all of the agent's resources since it is
+ // the only framework running so far.
+ FrameworkInfo framework = createFrameworkInfo("role1");
+ allocator->addFramework(
+ framework.id(), framework, hashmap<SlaveID, Resources>());
+
+ Future<Allocation> allocation = allocations.get();
+ AWAIT_READY(allocation);
+ EXPECT_EQ(framework.id(), allocation.get().frameworkId);
+ EXPECT_EQ(agent.resources(), Resources::sum(allocation.get().resources));
+
+ allocator->recoverResources(
+ framework.id(),
+ agent.id(),
+ agent.resources(),
+ None());
+
+ // Suppress offers and disconnect framework.
+ allocator->suppressOffers(framework.id());
+ allocator->deactivateFramework(framework.id());
+
+ // Advance the clock and trigger a background allocation cycle.
+ Clock::advance(flags.allocation_interval);
+
+ // Wait for all the 'suppressOffers' and 'deactivateFramework'
+ // operations to be processed.
+ Clock::settle();
+
+ allocation = allocations.get();
+ EXPECT_TRUE(allocation.isPending());
+
+ // Reconnect the framework again.
+ allocator->activateFramework(framework.id());
+
+ // Framework will be offered all of agent1's resources again
+ // after getting activated.
+ Clock::settle();
+ AWAIT_READY(allocation);
+ EXPECT_EQ(framework.id(), allocation.get().frameworkId);
+ EXPECT_EQ(agent.resources(), Resources::sum(allocation.get().resources));
+}
+
+
class HierarchicalAllocator_BENCHMARK_Test
: public HierarchicalAllocatorTestBase,
public WithParamInterface<std::tr1::tuple<size_t, size_t>> {};