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 2019/08/13 19:56:09 UTC

[mesos] branch master updated (1e1bf87 -> 11a7e71)

This is an automated email from the ASF dual-hosted git repository.

bmahler pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git.


    from 1e1bf87  Re-wrote the quota documentation to reflect quota limits.
     new 28a0bc2  Cleared filters upon unsuppressing a role.
     new 11a7e71  Added a test to ensure that filters are cleared upon unsuppression.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/master/allocator/mesos/hierarchical.cpp | 33 +++++++------
 src/master/allocator/mesos/hierarchical.hpp |  2 +-
 src/tests/master/update_framework_tests.cpp | 77 +++++++++++++++++++++++++++++
 3 files changed, 95 insertions(+), 17 deletions(-)


[mesos] 01/02: Cleared filters upon unsuppressing a role.

Posted by bm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bmahler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 28a0bc2284049e9a4765fd371f0c8a1293ff79c5
Author: Benjamin Mahler <bm...@apache.org>
AuthorDate: Fri Aug 9 17:31:55 2019 -0400

    Cleared filters upon unsuppressing a role.
    
    Per MESOS-9932, removal of a role from the suppression list does
    not currently clear filters. This means that schedulers have to
    issue a separate explicit REVIVE for the roles they want to remove.
    
    This ensures that filters are cleared upon removing a role from
    the suppression list.
    
    Review: https://reviews.apache.org/r/71264
---
 src/master/allocator/mesos/hierarchical.cpp | 33 +++++++++++++++--------------
 src/master/allocator/mesos/hierarchical.hpp |  2 +-
 2 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/src/master/allocator/mesos/hierarchical.cpp b/src/master/allocator/mesos/hierarchical.cpp
index f1fa838..87b03d3 100644
--- a/src/master/allocator/mesos/hierarchical.cpp
+++ b/src/master/allocator/mesos/hierarchical.cpp
@@ -499,6 +499,8 @@ void HierarchicalAllocatorProcess::updateFramework(
     if (!isFrameworkTrackedUnderRole(frameworkId, role)) {
       trackFrameworkUnderRole(frameworkId, role);
     }
+
+    frameworkSorters.at(role)->activate(frameworkId.value());
   }
 
   foreach (const string& role, oldRoles - newRoles) {
@@ -525,8 +527,10 @@ void HierarchicalAllocatorProcess::updateFramework(
   framework.minAllocatableResources =
     unpackFrameworkOfferFilters(frameworkInfo.offer_filters());
 
-  suppressRoles(frameworkId, suppressedRoles);
-  unsuppressRoles(frameworkId, newRoles - suppressedRoles);
+  suppressRoles(
+      frameworkId, suppressedRoles - oldSuppressedRoles);
+  reviveRoles(
+      frameworkId, (oldSuppressedRoles - suppressedRoles) & newRoles);
 
   CHECK(framework.suppressedRoles == suppressedRoles)
     << "After updating framework " << frameworkId
@@ -1340,7 +1344,7 @@ void HierarchicalAllocatorProcess::suppressOffers(
 }
 
 
-void HierarchicalAllocatorProcess::unsuppressRoles(
+void HierarchicalAllocatorProcess::reviveRoles(
     const FrameworkID& frameworkId,
     const set<string>& roles)
 {
@@ -1349,6 +1353,12 @@ void HierarchicalAllocatorProcess::unsuppressRoles(
 
   Framework& framework = frameworks.at(frameworkId);
 
+  framework.inverseOfferFilters.clear();
+
+  foreach (const string& role, roles) {
+    framework.offerFilters.erase(role);
+  }
+
   // Activating the framework in the sorter is fine as long as
   // SUPPRESS is not parameterized. When parameterization is added,
   // we may need to differentiate between the cases here.
@@ -1362,30 +1372,21 @@ void HierarchicalAllocatorProcess::unsuppressRoles(
 
   // TODO(bmahler): This logs roles that were already unsuppressed,
   // only log roles that transitioned from suppressed -> unsuppressed.
-  LOG(INFO) << "Unsuppressed offers for roles " << stringify(roles)
-            << " of framework " << frameworkId;
+  LOG(INFO) << "Unsuppressed offers and cleared filters for roles "
+            << stringify(roles) << " of framework " << frameworkId;
 }
 
 
 void HierarchicalAllocatorProcess::reviveOffers(
     const FrameworkID& frameworkId,
-    const set<string>& roles_)
+    const set<string>& roles)
 {
   CHECK(initialized);
   CHECK_CONTAINS(frameworks, frameworkId);
 
   Framework& framework = frameworks.at(frameworkId);
-  framework.inverseOfferFilters.clear();
 
-  const set<string>& roles = roles_.empty() ? framework.roles : roles_;
-  foreach (const string& role, roles) {
-    framework.offerFilters.erase(role);
-  }
-
-  unsuppressRoles(frameworkId, roles);
-
-  LOG(INFO) << "Revived roles " << stringify(roles)
-            << " of framework " << frameworkId;
+  reviveRoles(frameworkId, roles.empty() ? framework.roles : roles);
 
   allocate();
 }
diff --git a/src/master/allocator/mesos/hierarchical.hpp b/src/master/allocator/mesos/hierarchical.hpp
index 29dfa9f..dee5baf 100644
--- a/src/master/allocator/mesos/hierarchical.hpp
+++ b/src/master/allocator/mesos/hierarchical.hpp
@@ -638,7 +638,7 @@ private:
   void suppressRoles(
       const FrameworkID& frameworkId,
       const std::set<std::string>& roles);
-  void unsuppressRoles(
+  void reviveRoles(
       const FrameworkID& frameworkId,
       const std::set<std::string>& roles);
 


[mesos] 02/02: Added a test to ensure that filters are cleared upon unsuppression.

Posted by bm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bmahler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 11a7e71532a7c9b3a1032a178e3d7562577575a6
Author: Benjamin Mahler <bm...@apache.org>
AuthorDate: Fri Aug 9 17:33:23 2019 -0400

    Added a test to ensure that filters are cleared upon unsuppression.
    
    Review: https://reviews.apache.org/r/71265
---
 src/tests/master/update_framework_tests.cpp | 77 +++++++++++++++++++++++++++++
 1 file changed, 77 insertions(+)

diff --git a/src/tests/master/update_framework_tests.cpp b/src/tests/master/update_framework_tests.cpp
index 79aac41..514647d 100644
--- a/src/tests/master/update_framework_tests.cpp
+++ b/src/tests/master/update_framework_tests.cpp
@@ -1135,6 +1135,83 @@ TEST_F(UpdateFrameworkV0Test, SuppressedRoles)
 }
 
 
+// Test that when a framework removes a role from the
+// suppressed roles, it clears filters (same as REVIVE):
+// - start a master, a driver and an agent
+// - wait for offer and decline it for a long timeout
+// - add / remove suppressed roles via updateFramework
+// - ensure we get an offer for the agent again
+TEST_F(UpdateFrameworkV0Test, UnsuppressClearsFilters)
+{
+  mesos::internal::master::Flags masterFlags = CreateMasterFlags();
+  Try<Owned<cluster::Master>> master = StartMaster(masterFlags);
+  ASSERT_SOME(master);
+
+  v1::MockMasterAPISubscriber masterAPISubscriber;
+  AWAIT_READY(masterAPISubscriber.subscribe(master.get()->pid));
+
+  Future<v1::master::Event::FrameworkUpdated> frameworkUpdated1;
+  Future<v1::master::Event::FrameworkUpdated> frameworkUpdated2;
+  EXPECT_CALL(masterAPISubscriber, frameworkUpdated(_))
+    .WillOnce(FutureArg<0>(&frameworkUpdated1))
+    .WillOnce(FutureArg<0>(&frameworkUpdated2));
+
+  Owned<MasterDetector> detector = master->get()->createDetector();
+
+  Try<Owned<cluster::Slave>> slave = StartSlave(detector.get());
+  ASSERT_SOME(slave);
+
+  MockScheduler sched;
+  TestingMesosSchedulerDriver driver(
+      &sched, detector.get(), DEFAULT_FRAMEWORK_INFO);
+
+  Future<FrameworkID> frameworkId;
+  EXPECT_CALL(sched, registered(&driver, _, _))
+    .WillOnce(FutureArg<1>(&frameworkId));
+
+  Future<vector<Offer>> offers1;
+  Future<vector<Offer>> offers2;
+  EXPECT_CALL(sched, resourceOffers(&driver, _))
+    .WillOnce(FutureArg<1>(&offers1))
+    .WillOnce(FutureArg<1>(&offers2));
+
+  driver.start();
+
+  AWAIT_READY(frameworkId);
+
+  AWAIT_READY(offers1);
+  ASSERT_EQ(1u, offers1->size());
+
+  Filters filters;
+  filters.set_refuse_seconds(Days(1).secs());
+
+  driver.declineOffer(offers1->at(0).id(), filters);
+
+  // Suppress and unsuppress the role.
+  FrameworkInfo update = DEFAULT_FRAMEWORK_INFO;
+  *update.mutable_id() = frameworkId.get();
+
+  vector<string> suppressedRoles(
+    update.roles().begin(), update.roles().end());
+
+  driver.updateFramework(update, suppressedRoles);
+  AWAIT_READY(frameworkUpdated1);
+
+  driver.updateFramework(update, {});
+  AWAIT_READY(frameworkUpdated2);
+
+  // Now the previously declined agent should be re-offered.
+  Clock::pause();
+  Clock::settle();
+  Clock::advance(masterFlags.allocation_interval);
+
+  AWAIT_READY(offers2);
+
+  driver.stop();
+  driver.join();
+}
+
+
 } // namespace tests {
 } // namespace internal {
 } // namespace mesos {