You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2015/09/14 23:45:37 UTC

[1/2] mesos git commit: Maintenance Primitives: Added inverse offer test for hierarchical DRF.

Repository: mesos
Updated Branches:
  refs/heads/master 62be48ac2 -> 93c055474


Maintenance Primitives: Added inverse offer test for hierarchical DRF.

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


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

Branch: refs/heads/master
Commit: 4574bd26e848e1860b1e44f9970b428a09c68387
Parents: 62be48a
Author: Joseph Wu <jo...@mesosphere.io>
Authored: Sun Aug 30 14:21:48 2015 -0400
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Mon Sep 14 17:44:19 2015 -0400

----------------------------------------------------------------------
 src/tests/hierarchical_allocator_tests.cpp | 59 +++++++++++++++++++++++++
 1 file changed, 59 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/4574bd26/src/tests/hierarchical_allocator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/hierarchical_allocator_tests.cpp b/src/tests/hierarchical_allocator_tests.cpp
index 2f37c98..72e6273 100644
--- a/src/tests/hierarchical_allocator_tests.cpp
+++ b/src/tests/hierarchical_allocator_tests.cpp
@@ -416,6 +416,65 @@ TEST_F(HierarchicalAllocatorTest, ReservedDRF)
 }
 
 
+// This test ensures that agents which are scheduled for maintenance are
+// properly sent inverse offers after they have accepted or reserved resources.
+TEST_F(HierarchicalAllocatorTest, MaintenanceInverseOffers)
+{
+  // 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(vector<string>{});
+
+  // No initial resources.
+  hashmap<FrameworkID, Resources> EMPTY;
+
+  // Create an agent.
+  SlaveInfo agent = createSlaveInfo("cpus:2;mem:1024;disk:0");
+  allocator->addSlave(agent.id(), agent, None(), agent.resources(), EMPTY);
+
+  // This framework will be offered all of the resources.
+  FrameworkInfo framework1 = createFrameworkInfo("*");
+  allocator->addFramework(
+      framework1.id(), framework1, hashmap<SlaveID, Resources>());
+
+  // Check that the resources go to the framework.
+  Future<Allocation> allocation = allocations.get();
+  AWAIT_READY(allocation);
+  EXPECT_EQ(framework1.id(), allocation.get().frameworkId);
+  EXPECT_EQ(agent.resources(), Resources::sum(allocation.get().resources));
+
+  // TODO(jmlvanre): Replace Time(0.0) with `Clock::now()` once JSON double
+  // conversion is fixed. For now using a rounded time avoids the issue.
+  const process::Time start = process::Time::create(0.0).get() + Seconds(60);
+
+  // Give the agent some unavailability.
+  allocator->updateUnavailability(
+      agent.id(),
+      protobuf::maintenance::createUnavailability(
+          start));
+
+  // Check the resources get inverse offered.
+  Future<Deallocation> deallocation = deallocations.get();
+  AWAIT_READY(deallocation);
+  EXPECT_EQ(framework1.id(), deallocation.get().frameworkId);
+  EXPECT_TRUE(deallocation.get().resources.contains(agent.id()));
+
+  foreachvalue (
+      const UnavailableResources& unavailableResources,
+      deallocation.get().resources) {
+    // The resources in the inverse offer are unspecified.
+    // This means everything is being requested back.
+    EXPECT_EQ(Resources(), unavailableResources.resources);
+
+    EXPECT_EQ(
+        start.duration(),
+        Nanoseconds(unavailableResources.unavailability.start().nanoseconds()));
+  }
+}
+
+
 // This test ensures that allocation is done per slave. This is done
 // by having 2 slaves and 2 frameworks and making sure each framework
 // gets only one slave's resources during an allocation.


[2/2] mesos git commit: Fixed white-space issue in hierarchical allocator.

Posted by jo...@apache.org.
Fixed white-space issue in hierarchical allocator.


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

Branch: refs/heads/master
Commit: 93c0554748863e6e34e06a1f8538914c12673a1d
Parents: 4574bd2
Author: Joris Van Remoortere <jo...@gmail.com>
Authored: Mon Sep 14 17:43:22 2015 -0400
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Mon Sep 14 17:45:13 2015 -0400

----------------------------------------------------------------------
 src/master/allocator/mesos/hierarchical.hpp | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/93c05547/src/master/allocator/mesos/hierarchical.hpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/mesos/hierarchical.hpp b/src/master/allocator/mesos/hierarchical.hpp
index 8e3ec9c..3374d63 100644
--- a/src/master/allocator/mesos/hierarchical.hpp
+++ b/src/master/allocator/mesos/hierarchical.hpp
@@ -886,7 +886,6 @@ HierarchicalAllocatorProcess<RoleSorter, FrameworkSorter>::updateInverseOffer(
   // Only handle inverse offers that we currently have outstanding. If it is not
   // currently outstanding this means it is old and can be safely ignored.
   if (maintenance.offersOutstanding.contains(frameworkId)) {
-
     // We always remove the outstanding offer so that we will send a new offer
     // out the next time we schedule inverse offers.
     maintenance.offersOutstanding.erase(frameworkId);