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

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

commit 73831ecd9d28a9a33077716f8643ae4ebae5fa6c
Author: Andrei Sekretenko <asekrete...@apache.org>
AuthorDate: Thu Jul 16 20:45:43 2020 +0200

    Introduced a `FrameworkOptions` struct into the allocator interface.
    
    This patch supersedes the `suppressedRoles` parameter of the
    `addFramework()`/`updateFramework()` allocator methods with a more
    general `FrameworkOptions` struct that will allow to add more
    allocation options that are of no interest to agents (and thus are
    not included into the `FrameworkInfo` protobuf).
    
    Review: https://reviews.apache.org/r/72739
---
 include/mesos/allocator/allocator.hpp       | 30 ++++++----
 src/master/allocator/mesos/allocator.hpp    | 16 ++---
 src/master/allocator/mesos/hierarchical.cpp | 26 +++++----
 src/master/allocator/mesos/hierarchical.hpp |  6 +-
 src/master/master.cpp                       | 90 ++++++++++++++++-------------
 src/master/master.hpp                       | 17 +++---
 src/tests/allocator.hpp                     | 44 ++++++++++----
 src/tests/master_allocator_tests.cpp        | 44 +++++++-------
 src/tests/reservation_tests.cpp             |  4 +-
 src/tests/resource_offers_tests.cpp         |  2 +-
 src/tests/slave_recovery_tests.cpp          |  2 +-
 11 files changed, 164 insertions(+), 117 deletions(-)

diff --git a/include/mesos/allocator/allocator.hpp 
b/include/mesos/allocator/allocator.hpp
index c700528..065597f 100644
--- a/include/mesos/allocator/allocator.hpp
+++ b/include/mesos/allocator/allocator.hpp
@@ -69,6 +69,19 @@ struct Options
 
 
 /**
+ * Per-framework allocator-specific options that are not part of
+ * `FrameworkInfo`.
+ */
+struct FrameworkOptions
+{
+  /**
+   * The set of roles for which the allocator should not generate offers.
+   */
+  std::set<std::string> suppressedRoles;
+};
+
+
+/**
  * Basic model of an allocator: resources are allocated to a framework
  * in the form of offers. A framework can refuse some resources in
  * offers and run tasks in others. Allocated resources can have offer
@@ -155,14 +168,14 @@ public:
    *
    * @param active Whether the framework is initially activated.
    *
-   * @param suppressedRoles List of suppressed roles for this framework.
+   * @param options Initial FrameworkOptions of this framework.
    */
   virtual void addFramework(
       const FrameworkID& frameworkId,
       const FrameworkInfo& frameworkInfo,
       const hashmap<SlaveID, Resources>& used,
       bool active,
-      const std::set<std::string>& suppressedRoles) = 0;
+      FrameworkOptions&& options) = 0;
 
   /**
    * Removes a framework from the Mesos cluster. It is up to an allocator to
@@ -187,19 +200,16 @@ public:
       const FrameworkID& frameworkId) = 0;
 
   /**
-   * Updates capabilities of a framework in the Mesos cluster.
+   * Updates FrameworkInfo and FrameworkOptions.
    *
-   * This will be invoked when a framework is re-added. As some of the
-   * framework's capabilities may be updated when re-added, this API should
-   * update the capabilities of the newly added framework to Mesos cluster to
-   * reflect the latest framework info. Please refer to the design document 
here
-   * 
https://cwiki.apache.org/confluence/display/MESOS/Design+doc:+Updating+Framework+Info
 // NOLINT
-   * for more details related to framework update.
+   * NOTE: Effective framework options can also be changed via other methods.
+   * For example, `suppress()` and `revive()` change the suppression state
+   * of framework's roles.
    */
   virtual void updateFramework(
       const FrameworkID& frameworkId,
       const FrameworkInfo& frameworkInfo,
-      const std::set<std::string>& suppressedRoles) = 0;
+      FrameworkOptions&& options) = 0;
 
   /**
    * Adds or re-adds an agent to the Mesos cluster. It is invoked when a
diff --git a/src/master/allocator/mesos/allocator.hpp 
b/src/master/allocator/mesos/allocator.hpp
index dd7952b..ac26ccb 100644
--- a/src/master/allocator/mesos/allocator.hpp
+++ b/src/master/allocator/mesos/allocator.hpp
@@ -66,7 +66,7 @@ public:
       const FrameworkInfo& frameworkInfo,
       const hashmap<SlaveID, Resources>& used,
       bool active,
-      const std::set<std::string>& suppressedRoles) override;
+      ::mesos::allocator::FrameworkOptions&& options) override;
 
   void removeFramework(
       const FrameworkID& frameworkId) override;
@@ -80,7 +80,7 @@ public:
   void updateFramework(
       const FrameworkID& frameworkId,
       const FrameworkInfo& frameworkInfo,
-      const std::set<std::string>& suppressedRoles) override;
+      ::mesos::allocator::FrameworkOptions&& options) override;
 
   void addSlave(
       const SlaveID& slaveId,
@@ -214,7 +214,7 @@ public:
       const FrameworkInfo& frameworkInfo,
       const hashmap<SlaveID, Resources>& used,
       bool active,
-      const std::set<std::string>& suppressedRoles) = 0;
+      ::mesos::allocator::FrameworkOptions&& options) = 0;
 
   virtual void removeFramework(
       const FrameworkID& frameworkId) = 0;
@@ -228,7 +228,7 @@ public:
   virtual void updateFramework(
       const FrameworkID& frameworkId,
       const FrameworkInfo& frameworkInfo,
-      const std::set<std::string>& suppressedRoles) = 0;
+      ::mesos::allocator::FrameworkOptions&& options) = 0;
 
   virtual void addSlave(
       const SlaveID& slaveId,
@@ -390,7 +390,7 @@ inline void MesosAllocator<AllocatorProcess>::addFramework(
     const FrameworkInfo& frameworkInfo,
     const hashmap<SlaveID, Resources>& used,
     bool active,
-    const std::set<std::string>& suppressedRoles)
+    ::mesos::allocator::FrameworkOptions&& options)
 {
   process::dispatch(
       process,
@@ -399,7 +399,7 @@ inline void MesosAllocator<AllocatorProcess>::addFramework(
       frameworkInfo,
       used,
       active,
-      suppressedRoles);
+      std::move(options));
 }
 
 
@@ -440,14 +440,14 @@ template <typename AllocatorProcess>
 inline void MesosAllocator<AllocatorProcess>::updateFramework(
     const FrameworkID& frameworkId,
     const FrameworkInfo& frameworkInfo,
-    const std::set<std::string>& suppressedRoles)
+    ::mesos::allocator::FrameworkOptions&& options)
 {
   process::dispatch(
       process,
       &MesosAllocatorProcess::updateFramework,
       frameworkId,
       frameworkInfo,
-      suppressedRoles);
+      std::move(options));
 }
 
 
diff --git a/src/master/allocator/mesos/hierarchical.cpp 
b/src/master/allocator/mesos/hierarchical.cpp
index 9e50799..b061a05 100644
--- a/src/master/allocator/mesos/hierarchical.cpp
+++ b/src/master/allocator/mesos/hierarchical.cpp
@@ -53,6 +53,7 @@ using std::string;
 using std::vector;
 using std::weak_ptr;
 
+using mesos::allocator::FrameworkOptions;
 using mesos::allocator::InverseOfferStatus;
 using mesos::allocator::Options;
 
@@ -595,12 +596,12 @@ std::string RoleTree::toJSON() const
 
 Framework::Framework(
     const FrameworkInfo& frameworkInfo,
-    const set<string>& _suppressedRoles,
+    FrameworkOptions&& options,
     bool _active,
     bool publishPerFrameworkMetrics)
   : frameworkId(frameworkInfo.id()),
     roles(protobuf::framework::getRoles(frameworkInfo)),
-    suppressedRoles(_suppressedRoles),
+    suppressedRoles(std::move(options.suppressedRoles)),
     capabilities(frameworkInfo.capabilities()),
     active(_active),
     metrics(new FrameworkMetrics(frameworkInfo, publishPerFrameworkMetrics)),
@@ -717,7 +718,7 @@ void HierarchicalAllocatorProcess::addFramework(
     const FrameworkInfo& frameworkInfo,
     const hashmap<SlaveID, Resources>& used,
     bool active,
-    const set<string>& suppressedRoles)
+    FrameworkOptions&& frameworkOptions)
 {
   CHECK(initialized);
   CHECK_NOT_CONTAINS(frameworks, frameworkId);
@@ -728,7 +729,7 @@ void HierarchicalAllocatorProcess::addFramework(
   frameworks.insert({frameworkId,
                      Framework(
                          frameworkInfo,
-                         suppressedRoles,
+                         std::move(frameworkOptions),
                          active,
                          options.publishPerFrameworkMetrics)});
 
@@ -739,7 +740,7 @@ void HierarchicalAllocatorProcess::addFramework(
 
     Sorter* frameworkSorter = CHECK_NOTNONE(getFrameworkSorter(role));
 
-    if (suppressedRoles.count(role)) {
+    if (framework.suppressedRoles.count(role)) {
       frameworkSorter->deactivate(frameworkId.value());
       framework.metrics->suppressRole(role);
     } else {
@@ -884,7 +885,7 @@ void HierarchicalAllocatorProcess::deactivateFramework(
 void HierarchicalAllocatorProcess::updateFramework(
     const FrameworkID& frameworkId,
     const FrameworkInfo& frameworkInfo,
-    const set<string>& suppressedRoles)
+    FrameworkOptions&& frameworkOptions)
 {
   CHECK(initialized);
 
@@ -928,13 +929,18 @@ void HierarchicalAllocatorProcess::updateFramework(
   framework.minAllocatableResources =
     unpackFrameworkOfferFilters(frameworkInfo.offer_filters());
 
-  suppressRoles(framework, suppressedRoles - oldSuppressedRoles);
-  reviveRoles(framework, (oldSuppressedRoles - suppressedRoles) & newRoles);
+  suppressRoles(
+      framework,
+      frameworkOptions.suppressedRoles - oldSuppressedRoles);
 
-  CHECK(framework.suppressedRoles == suppressedRoles)
+  reviveRoles(
+      framework,
+      (oldSuppressedRoles - frameworkOptions.suppressedRoles) & newRoles);
+
+  CHECK(framework.suppressedRoles == frameworkOptions.suppressedRoles)
     << "After updating framework " << frameworkId
     << " its set of suppressed roles " << stringify(framework.suppressedRoles)
-    << " differs from required " << stringify(suppressedRoles);
+    << " differs from required " << 
stringify(frameworkOptions.suppressedRoles);
 }
 
 
diff --git a/src/master/allocator/mesos/hierarchical.hpp 
b/src/master/allocator/mesos/hierarchical.hpp
index e444e47..9c1932d 100644
--- a/src/master/allocator/mesos/hierarchical.hpp
+++ b/src/master/allocator/mesos/hierarchical.hpp
@@ -81,7 +81,7 @@ struct Framework
 {
   Framework(
       const FrameworkInfo& frameworkInfo,
-      const std::set<std::string>& suppressedRoles,
+      ::mesos::allocator::FrameworkOptions&& options,
       bool active,
       bool publishPerFrameworkMetrics);
 
@@ -575,7 +575,7 @@ public:
       const FrameworkInfo& frameworkInfo,
       const hashmap<SlaveID, Resources>& used,
       bool active,
-      const std::set<std::string>& suppressedRoles) override;
+      ::mesos::allocator::FrameworkOptions&& frameworkOptions) override;
 
   void removeFramework(
       const FrameworkID& frameworkId) override;
@@ -589,7 +589,7 @@ public:
   void updateFramework(
       const FrameworkID& frameworkId,
       const FrameworkInfo& frameworkInfo,
-      const std::set<std::string>& suppressedRoles) override;
+      ::mesos::allocator::FrameworkOptions&& frameworkOptions) override;
 
   void addSlave(
       const SlaveID& slaveId,
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 6a013e3..2769349 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -140,6 +140,7 @@ namespace internal {
 namespace master {
 
 using mesos::allocator::Allocator;
+using mesos::allocator::FrameworkOptions;
 
 using mesos::authorization::createSubject;
 using mesos::authorization::VIEW_ROLE;
@@ -2677,25 +2678,29 @@ void Master::subscribe(
     return;
   }
 
+  set<string> suppressedRoles = set<string>(
+      make_move_iterator(subscribe.mutable_suppressed_roles()->begin()),
+      make_move_iterator(subscribe.mutable_suppressed_roles()->end()));
+
   // Need to disambiguate for the compiler.
   void (Master::*_subscribe)(
       StreamingHttpConnection<v1::scheduler::Event>,
       FrameworkInfo&&,
       bool,
-      google::protobuf::RepeatedPtrField<string>&&,
+      FrameworkOptions&&,
       const Future<Owned<ObjectApprovers>>&) = &Self::_subscribe;
 
   Future<Owned<ObjectApprovers>> objectApprovers =
     Framework::createObjectApprovers(authorizer, frameworkInfo);
 
-  objectApprovers.onAny(
-      defer(self(),
-            _subscribe,
-            http,
-            std::move(frameworkInfo),
-            subscribe.force(),
-            std::move(*subscribe.mutable_suppressed_roles()),
-            lambda::_1));
+  objectApprovers.onAny(defer(
+      self(),
+      _subscribe,
+      http,
+      std::move(frameworkInfo),
+      subscribe.force(),
+      FrameworkOptions{std::move(suppressedRoles)},
+      lambda::_1));
 }
 
 
@@ -2703,7 +2708,7 @@ void Master::_subscribe(
     StreamingHttpConnection<v1::scheduler::Event> http,
     FrameworkInfo&& frameworkInfo,
     bool force,
-    google::protobuf::RepeatedPtrField<string>&& suppressedRolesField,
+    ::mesos::allocator::FrameworkOptions&& options,
     const Future<Owned<ObjectApprovers>>& objectApprovers)
 {
   CHECK(!objectApprovers.isDiscarded());
@@ -2729,9 +2734,6 @@ void Master::_subscribe(
             << (frameworkInfo.checkpoint() ? "enabled" : "disabled")
             << " and capabilities " << frameworkInfo.capabilities();
 
-  set<string> suppressedRoles = set<string>(
-      make_move_iterator(suppressedRolesField.begin()),
-      make_move_iterator(suppressedRolesField.end()));
 
   if (!frameworkInfo.has_id() || frameworkInfo.id() == "") {
     // If we are here the framework is subscribing for the first time.
@@ -2742,7 +2744,7 @@ void Master::_subscribe(
     Framework* framework =
       new Framework(this, flags, frameworkInfo_, http, objectApprovers.get());
 
-    addFramework(framework, suppressedRoles);
+    addFramework(framework, std::move(options));
 
     framework->metrics.incrementCall(scheduler::Call::SUBSCRIBE);
 
@@ -2772,7 +2774,10 @@ void Master::_subscribe(
     // Furthermore, no agents have reregistered running one of this
     // framework's tasks. Reconstruct a `Framework` object from the
     // supplied `FrameworkInfo`.
-    recoverFramework(frameworkInfo, suppressedRoles);
+    //
+    // NOTE: allocatorOptions will be fed into the allocator later in this
+    // method.
+    recoverFramework(frameworkInfo);
 
     framework = getFramework(frameworkInfo.id());
   }
@@ -2803,7 +2808,8 @@ void Master::_subscribe(
     // The framework has previously been registered with this master;
     // it may or may not currently be connected.
 
-    updateFramework(framework, frameworkInfo, suppressedRoles);
+    updateFramework(framework, frameworkInfo, std::move(options));
+
     framework->reregisteredTime = Clock::now();
 
     // Always failover the old framework connection. See MESOS-4712 for 
details.
@@ -2816,7 +2822,7 @@ void Master::_subscribe(
         None(),
         http,
         objectApprovers.get(),
-        suppressedRoles);
+        std::move(options));
   }
 
   sendFrameworkUpdates(*framework);
@@ -2914,12 +2920,16 @@ void Master::subscribe(
     frameworkInfo.set_principal(authenticated[from]);
   }
 
+  set<string> suppressedRoles = set<string>(
+      make_move_iterator(subscribe.mutable_suppressed_roles()->begin()),
+      make_move_iterator(subscribe.mutable_suppressed_roles()->end()));
+
   // Need to disambiguate for the compiler.
   void (Master::*_subscribe)(
       const UPID&,
       FrameworkInfo&&,
       bool,
-      google::protobuf::RepeatedPtrField<string>&&,
+      ::mesos::allocator::FrameworkOptions&&,
       const Future<Owned<ObjectApprovers>>&) = &Self::_subscribe;
 
   Future<Owned<ObjectApprovers>> objectApprovers =
@@ -2931,7 +2941,7 @@ void Master::subscribe(
       from,
       std::move(frameworkInfo),
       subscribe.force(),
-      std::move(*subscribe.mutable_suppressed_roles()),
+      FrameworkOptions{std::move(suppressedRoles)},
       lambda::_1));
 }
 
@@ -2940,7 +2950,7 @@ void Master::_subscribe(
     const UPID& from,
     FrameworkInfo&& frameworkInfo,
     bool force,
-    google::protobuf::RepeatedPtrField<string>&& suppressedRolesField,
+    ::mesos::allocator::FrameworkOptions&& options,
     const Future<Owned<ObjectApprovers>>& objectApprovers)
 {
   CHECK(!objectApprovers.isDiscarded());
@@ -2976,9 +2986,6 @@ void Master::_subscribe(
     return;
   }
 
-  set<string> suppressedRoles = set<string>(
-      make_move_iterator(suppressedRolesField.begin()),
-      make_move_iterator(suppressedRolesField.end()));
 
   LOG(INFO) << "Subscribing framework " << frameworkInfo.name()
             << " with checkpointing "
@@ -3009,7 +3016,7 @@ void Master::_subscribe(
     Framework* framework =
       new Framework(this, flags, frameworkInfo, from, objectApprovers.get());
 
-    addFramework(framework, suppressedRoles);
+    addFramework(framework, std::move(options));
 
     FrameworkRegisteredMessage message;
     message.mutable_framework_id()->MergeFrom(framework->id());
@@ -3049,7 +3056,7 @@ void Master::_subscribe(
     // Furthermore, no agents have reregistered running one of this
     // framework's tasks. Reconstruct a `Framework` object from the
     // supplied `FrameworkInfo`.
-    recoverFramework(frameworkInfo, suppressedRoles);
+    recoverFramework(frameworkInfo);
 
     framework = getFramework(frameworkInfo.id());
   }
@@ -3098,7 +3105,7 @@ void Master::_subscribe(
     // It is now safe to update the framework fields since the request is now
     // guaranteed to be successful. We use the fields passed in during
     // re-registration.
-    updateFramework(framework, frameworkInfo, suppressedRoles);
+    updateFramework(framework, frameworkInfo, std::move(options));
 
     framework->reregisteredTime = Clock::now();
 
@@ -3162,7 +3169,7 @@ void Master::_subscribe(
         from,
         None(),
         objectApprovers.get(),
-        suppressedRoles);
+        std::move(options));
   }
 
   sendFrameworkUpdates(*framework);
@@ -3234,7 +3241,9 @@ Future<process::http::Response> Master::updateFramework(
     make_move_iterator(call.mutable_suppressed_roles()->begin()),
     make_move_iterator(call.mutable_suppressed_roles()->end()));
 
-  updateFramework(framework, call.framework_info(), suppressedRoles);
+  updateFramework(
+      framework, call.framework_info(), {std::move(suppressedRoles)});
+
   sendFrameworkUpdates(*framework);
 
   return process::http::OK();
@@ -7356,7 +7365,7 @@ void Master::updateSlaveFrameworks(
       LOG(INFO) << "Recovering framework " << frameworkInfo.id()
                 << " from reregistering agent " << *slave;
 
-      recoverFramework(frameworkInfo, {});
+      recoverFramework(frameworkInfo);
     }
   }
 }
@@ -7391,14 +7400,15 @@ void Master::unregisterSlave(const UPID& from, const 
SlaveID& slaveId)
 void Master::updateFramework(
     Framework* framework,
     const FrameworkInfo& frameworkInfo,
-    const set<string>& suppressedRoles)
+    ::mesos::allocator::FrameworkOptions&& allocatorOptions)
 {
   LOG(INFO) << "Updating framework " << *framework << " with roles "
-            << stringify(suppressedRoles) << " suppressed";
+            << stringify(allocatorOptions.suppressedRoles) << " suppressed";
 
   // NOTE: The allocator takes care of activating/deactivating
   // the frameworks from the added/removed roles, respectively.
-  allocator->updateFramework(framework->id(), frameworkInfo, suppressedRoles);
+  allocator->updateFramework(
+      framework->id(), frameworkInfo, std::move(allocatorOptions));
 
   // Rescind offers allocated to the roles that were removed.
   const set<string> newRoles = protobuf::framework::getRoles(frameworkInfo);
@@ -9887,7 +9897,7 @@ void Master::reconcileKnownSlave(
 
 void Master::addFramework(
     Framework* framework,
-    const set<string>& suppressedRoles)
+    ::mesos::allocator::FrameworkOptions&& allocatorOptions)
 {
   CHECK_NOTNULL(framework);
 
@@ -9895,7 +9905,7 @@ void Master::addFramework(
     << "Framework " << *framework << " already exists!";
 
   LOG(INFO) << "Adding framework " << *framework << " with roles "
-            << stringify(suppressedRoles) << " suppressed";
+            << stringify(allocatorOptions.suppressedRoles) << " suppressed";
 
   frameworks.registered[framework->id()] = framework;
 
@@ -9921,7 +9931,7 @@ void Master::addFramework(
       framework->info,
       framework->usedResources,
       framework->active(),
-      suppressedRoles);
+      std::move(allocatorOptions));
 
   // Export framework metrics if a principal is specified in `FrameworkInfo`.
 
@@ -9947,9 +9957,7 @@ void Master::addFramework(
 }
 
 
-void Master::recoverFramework(
-    const FrameworkInfo& info,
-    const set<string>& suppressedRoles)
+void Master::recoverFramework(const FrameworkInfo& info)
 {
   CHECK(!frameworks.registered.contains(info.id()));
 
@@ -10049,7 +10057,7 @@ void Master::recoverFramework(
   // `addResourceProvider()` above because if the order were reversed, the
   // resources of orphan operations would be incorrectly tracked twice in the
   // allocator.
-  addFramework(framework, suppressedRoles);
+  addFramework(framework, {});
 }
 
 
@@ -10059,7 +10067,7 @@ void Master::connectAndActivateRecoveredFramework(
     const Option<UPID>& pid,
     const Option<StreamingHttpConnection<v1::scheduler::Event>>& http,
     const Owned<ObjectApprovers>& objectApprovers,
-    const set<string>& suppressedRoles)
+    ::mesos::allocator::FrameworkOptions&& allocatorOptions)
 {
   // Exactly one of `pid` or `http` must be provided.
   CHECK(pid.isSome() != http.isSome());
@@ -10071,7 +10079,7 @@ void Master::connectAndActivateRecoveredFramework(
   CHECK(framework->pid().isNone());
   CHECK(framework->http().isNone());
 
-  updateFramework(framework, frameworkInfo, suppressedRoles);
+  updateFramework(framework, frameworkInfo, std::move(allocatorOptions));
 
   // Updating `registeredTime` here is debatable: ideally,
   // `registeredTime` would be the time at which the framework first
diff --git a/src/master/master.hpp b/src/master/master.hpp
index 214307f..e478f80 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -613,16 +613,15 @@ protected:
   // Add a framework.
   void addFramework(
       Framework* framework,
-      const std::set<std::string>& suppressedRoles);
+      ::mesos::allocator::FrameworkOptions&& allocatorOptions);
 
   // Recover a framework from its `FrameworkInfo`. This happens after
   // master failover, when an agent running one of the framework's
   // tasks reregisters or when the framework itself reregisters,
   // whichever happens first. The result of this function is a
-  // registered, inactive framework with state `RECOVERED`.
-  void recoverFramework(
-      const FrameworkInfo& info,
-      const std::set<std::string>& suppressedRoles);
+  // registered, inactive framework with state `RECOVERED` and empty
+  // FrameworkOptions in the allocator.
+  void recoverFramework(const FrameworkInfo& info);
 
   // Transition a framework from `RECOVERED` to `CONNECTED` state and
   // activate it. This happens at most once after master failover, the
@@ -634,7 +633,7 @@ protected:
       const Option<process::UPID>& pid,
       const Option<StreamingHttpConnection<v1::scheduler::Event>>& http,
       const process::Owned<ObjectApprovers>& objectApprovers,
-      const std::set<std::string>& suppressedRoles);
+      ::mesos::allocator::FrameworkOptions&& allocatorOptions);
 
   // Replace the scheduler for a framework with a new process ID, in
   // the event of a scheduler failover.
@@ -673,7 +672,7 @@ protected:
   void updateFramework(
       Framework* framework,
       const FrameworkInfo& frameworkInfo,
-      const std::set<std::string>& suppressedRoles);
+      ::mesos::allocator::FrameworkOptions&& allocatorOptions);
 
   void sendFrameworkUpdates(const Framework& framework);
 
@@ -907,7 +906,7 @@ private:
       StreamingHttpConnection<v1::scheduler::Event> http,
       FrameworkInfo&& frameworkInfo,
       bool force,
-      google::protobuf::RepeatedPtrField<std::string>&& suppressedRoles,
+      ::mesos::allocator::FrameworkOptions&& allocatorOptions,
       const process::Future<process::Owned<ObjectApprovers>>& objectApprovers);
 
   void subscribe(
@@ -918,7 +917,7 @@ private:
       const process::UPID& from,
       FrameworkInfo&& frameworkInfo,
       bool force,
-      google::protobuf::RepeatedPtrField<std::string>&& suppressedRoles,
+      ::mesos::allocator::FrameworkOptions&& allocatorOptions,
       const process::Future<process::Owned<ObjectApprovers>>& objectApprovers);
 
   // Update framework via SchedulerDriver (i.e. no response
diff --git a/src/tests/allocator.hpp b/src/tests/allocator.hpp
index 4765604..54f54c0 100644
--- a/src/tests/allocator.hpp
+++ b/src/tests/allocator.hpp
@@ -72,7 +72,7 @@ ACTION_P(InvokeRecover, allocator)
 
 ACTION_P(InvokeAddFramework, allocator)
 {
-  allocator->real->addFramework(arg0, arg1, arg2, arg3, arg4);
+  allocator->real->addFramework(arg0, arg1, arg2, arg3, std::move(arg4));
 }
 
 
@@ -96,7 +96,7 @@ ACTION_P(InvokeDeactivateFramework, allocator)
 
 ACTION_P(InvokeUpdateFramework, allocator)
 {
-  allocator->real->updateFramework(arg0, arg1, arg2);
+  allocator->real->updateFramework(arg0, arg1, std::move(arg2));
 }
 
 
@@ -272,9 +272,9 @@ public:
     EXPECT_CALL(*this, recover(_, _))
       .WillRepeatedly(DoDefault());
 
-    ON_CALL(*this, addFramework(_, _, _, _, _))
+    ON_CALL(*this, addFramework_(_, _, _, _, _))
       .WillByDefault(InvokeAddFramework(this));
-    EXPECT_CALL(*this, addFramework(_, _, _, _, _))
+    EXPECT_CALL(*this, addFramework_(_, _, _, _, _))
       .WillRepeatedly(DoDefault());
 
     ON_CALL(*this, removeFramework(_))
@@ -292,9 +292,9 @@ public:
     EXPECT_CALL(*this, deactivateFramework(_))
       .WillRepeatedly(DoDefault());
 
-    ON_CALL(*this, updateFramework(_, _, _))
+    ON_CALL(*this, updateFramework_(_, _, _))
       .WillByDefault(InvokeUpdateFramework(this));
-    EXPECT_CALL(*this, updateFramework(_, _, _))
+    EXPECT_CALL(*this, updateFramework_( _, _, _))
       .WillRepeatedly(DoDefault());
 
     ON_CALL(*this, addSlave(_, _, _, _, _, _))
@@ -418,12 +418,25 @@ public:
       const int expectedAgentCount,
       const hashmap<std::string, Quota>&));
 
-  MOCK_METHOD5(addFramework, void(
+  // NOTE: Due to gmock's limitations, instead of an rvlalue reference,
+  // a non-const lvalue reference to FrameworkOptions is passed into
+  // the mock method.
+  MOCK_METHOD5(addFramework_, void(
       const FrameworkID&,
       const FrameworkInfo&,
       const hashmap<SlaveID, Resources>&,
       bool active,
-      const std::set<std::string>&));
+      ::mesos::allocator::FrameworkOptions&));
+
+  void addFramework(
+      const FrameworkID& frameworkId,
+      const FrameworkInfo& frameworkInfo,
+      const hashmap<SlaveID, Resources>& used,
+      bool active,
+      ::mesos::allocator::FrameworkOptions&& options) override
+  {
+    addFramework_(frameworkId, frameworkInfo, used, active, options);
+  };
 
   MOCK_METHOD1(removeFramework, void(
       const FrameworkID&));
@@ -434,10 +447,21 @@ public:
   MOCK_METHOD1(deactivateFramework, void(
       const FrameworkID&));
 
-  MOCK_METHOD3(updateFramework, void(
+  // NOTE: Due to gmock's limitations, instead of an rvlalue reference,
+  // a non-const lvalue reference to FrameworkOptions is passed into
+  // the mock method.
+  MOCK_METHOD3(updateFramework_, void(
       const FrameworkID&,
       const FrameworkInfo&,
-      const std::set<std::string>&));
+      ::mesos::allocator::FrameworkOptions&));
+
+  void updateFramework(
+      const FrameworkID& frameworkId,
+      const FrameworkInfo& frameworkInfo,
+      ::mesos::allocator::FrameworkOptions&& options) override
+  {
+    updateFramework_(frameworkId, frameworkInfo, options);
+  };
 
   MOCK_METHOD6(addSlave, void(
       const SlaveID&,
diff --git a/src/tests/master_allocator_tests.cpp 
b/src/tests/master_allocator_tests.cpp
index d2580c3..416b7ba 100644
--- a/src/tests/master_allocator_tests.cpp
+++ b/src/tests/master_allocator_tests.cpp
@@ -184,7 +184,7 @@ TYPED_TEST(MasterAllocatorTest, SingleFramework)
   MesosSchedulerDriver driver(
       &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
 
-  EXPECT_CALL(allocator, addFramework(_, _, _, _, _));
+  EXPECT_CALL(allocator, addFramework_(_, _, _, _, _));
 
   EXPECT_CALL(sched, registered(_, _, _));
 
@@ -246,7 +246,7 @@ TYPED_TEST(MasterAllocatorTest, ResourcesUnused)
   MesosSchedulerDriver driver1(
       &sched1, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
 
-  EXPECT_CALL(allocator, addFramework(_, _, _, _, _));
+  EXPECT_CALL(allocator, addFramework_(_, _, _, _, _));
 
   EXPECT_CALL(sched1, registered(_, _, _));
 
@@ -285,7 +285,7 @@ TYPED_TEST(MasterAllocatorTest, ResourcesUnused)
   MesosSchedulerDriver driver2(
       &sched2, frameworkInfo2, master.get()->pid, DEFAULT_CREDENTIAL);
 
-  EXPECT_CALL(allocator, addFramework(_, _, _, _, _));
+  EXPECT_CALL(allocator, addFramework_(_, _, _, _, _));
 
   EXPECT_CALL(sched2, registered(_, _, _));
 
@@ -350,7 +350,7 @@ TYPED_TEST(MasterAllocatorTest, OutOfOrderDispatch)
   MesosSchedulerDriver driver1(
       &sched1, frameworkInfo1, master.get()->pid, DEFAULT_CREDENTIAL);
 
-  EXPECT_CALL(allocator, addFramework(_, Eq(frameworkInfo1), _, _, _))
+  EXPECT_CALL(allocator, addFramework_(_, Eq(frameworkInfo1), _, _, _))
     .WillOnce(InvokeAddFramework(&allocator));
 
   Future<FrameworkID> frameworkId1;
@@ -419,7 +419,7 @@ TYPED_TEST(MasterAllocatorTest, OutOfOrderDispatch)
   MesosSchedulerDriver driver2(
       &sched2, frameworkInfo2, master.get()->pid, DEFAULT_CREDENTIAL);
 
-  EXPECT_CALL(allocator, addFramework(_, Eq(frameworkInfo2), _, _, _))
+  EXPECT_CALL(allocator, addFramework_(_, Eq(frameworkInfo2), _, _, _))
     .WillOnce(InvokeAddFramework(&allocator));
 
   FrameworkID frameworkId2;
@@ -487,7 +487,7 @@ TYPED_TEST(MasterAllocatorTest, SchedulerFailover)
   MesosSchedulerDriver driver1(
       &sched1, frameworkInfo1, master.get()->pid, DEFAULT_CREDENTIAL);
 
-  EXPECT_CALL(allocator, addFramework(_, _, _, _, _));
+  EXPECT_CALL(allocator, addFramework_(_, _, _, _, _));
 
   FrameworkID frameworkId;
   EXPECT_CALL(sched1, registered(&driver1, _, _))
@@ -635,7 +635,7 @@ TYPED_TEST(MasterAllocatorTest, FrameworkExited)
   MesosSchedulerDriver driver1(
       &sched1, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
 
-  EXPECT_CALL(allocator, addFramework(_, _, _, _, _));
+  EXPECT_CALL(allocator, addFramework_(_, _, _, _, _));
 
   EXPECT_CALL(sched1, registered(_, _, _));
 
@@ -673,7 +673,7 @@ TYPED_TEST(MasterAllocatorTest, FrameworkExited)
   MesosSchedulerDriver driver2(
       &sched2, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
 
-  EXPECT_CALL(allocator, addFramework(_, _, _, _, _));
+  EXPECT_CALL(allocator, addFramework_(_, _, _, _, _));
 
   EXPECT_CALL(sched2, registered(_, _, _));
 
@@ -777,7 +777,7 @@ TYPED_TEST(MasterAllocatorTest, SlaveLost)
   MesosSchedulerDriver driver(
       &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
 
-  EXPECT_CALL(allocator, addFramework(_, _, _, _, _));
+  EXPECT_CALL(allocator, addFramework_(_, _, _, _, _));
 
   EXPECT_CALL(sched, registered(_, _, _));
 
@@ -899,7 +899,7 @@ TYPED_TEST(MasterAllocatorTest, SlaveAdded)
   MesosSchedulerDriver driver(
       &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
 
-  EXPECT_CALL(allocator, addFramework(_, _, _, _, _));
+  EXPECT_CALL(allocator, addFramework_(_, _, _, _, _));
 
   EXPECT_CALL(sched, registered(_, _, _));
 
@@ -998,7 +998,7 @@ TYPED_TEST(MasterAllocatorTest, TaskFinished)
   MesosSchedulerDriver driver(
       &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
 
-  EXPECT_CALL(allocator, addFramework(_, _, _, _, _));
+  EXPECT_CALL(allocator, addFramework_(_, _, _, _, _));
 
   EXPECT_CALL(sched, registered(_, _, _));
 
@@ -1105,7 +1105,7 @@ TYPED_TEST(MasterAllocatorTest, 
CpusOnlyOfferedAndTaskLaunched)
   MesosSchedulerDriver driver(
       &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
 
-  EXPECT_CALL(allocator, addFramework(_, _, _, _, _));
+  EXPECT_CALL(allocator, addFramework_(_, _, _, _, _));
 
   EXPECT_CALL(sched, registered(_, _, _));
 
@@ -1188,7 +1188,7 @@ TYPED_TEST(MasterAllocatorTest, 
MemoryOnlyOfferedAndTaskLaunched)
   MesosSchedulerDriver driver(
       &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
 
-  EXPECT_CALL(allocator, addFramework(_, _, _, _, _));
+  EXPECT_CALL(allocator, addFramework_(_, _, _, _, _));
 
   EXPECT_CALL(sched, registered(_, _, _));
 
@@ -1443,7 +1443,7 @@ TYPED_TEST(MasterAllocatorTest, RoleTest)
     .WillOnce(FutureSatisfy(&registered2));
 
   Future<Nothing> addFramework;
-  EXPECT_CALL(allocator, addFramework(_, _, _, _, _))
+  EXPECT_CALL(allocator, addFramework_(_, _, _, _, _))
     .WillOnce(FutureSatisfy(&addFramework));
 
   driver2.start();
@@ -1512,7 +1512,7 @@ TYPED_TEST(MasterAllocatorTest, FrameworkReregistersFirst)
     slave = this->StartSlave(&slaveDetector, &containerizer, flags);
     ASSERT_SOME(slave);
 
-    EXPECT_CALL(allocator, addFramework(_, _, _, _, _));
+    EXPECT_CALL(allocator, addFramework_(_, _, _, _, _));
 
     EXPECT_CALL(sched, registered(&driver, _, _));
 
@@ -1556,7 +1556,7 @@ TYPED_TEST(MasterAllocatorTest, FrameworkReregistersFirst)
     EXPECT_CALL(allocator2, initialize(_, _, _));
 
     Future<Nothing> addFramework;
-    EXPECT_CALL(allocator2, addFramework(_, _, _, _, _))
+    EXPECT_CALL(allocator2, addFramework_(_, _, _, _, _))
       .WillOnce(DoAll(InvokeAddFramework(&allocator2),
                       FutureSatisfy(&addFramework)));
 
@@ -1640,7 +1640,7 @@ TYPED_TEST(MasterAllocatorTest, SlaveReregistersFirst)
     slave = this->StartSlave(&slaveDetector, &containerizer, flags);
     ASSERT_SOME(slave);
 
-    EXPECT_CALL(allocator, addFramework(_, _, _, _, _));
+    EXPECT_CALL(allocator, addFramework_(_, _, _, _, _));
     EXPECT_CALL(allocator, recoverResources(_, _, _, _, _));
 
     EXPECT_CALL(sched, registered(&driver, _, _));
@@ -1690,7 +1690,7 @@ TYPED_TEST(MasterAllocatorTest, SlaveReregistersFirst)
     // Expect the framework to be added but to be inactive when the
     // agent reregisters, until the framework reregisters below.
     Future<Nothing> addFramework;
-    EXPECT_CALL(allocator2, addFramework(_, _, _, false, _))
+    EXPECT_CALL(allocator2, addFramework_(_, _, _, false, _))
       .WillOnce(DoAll(InvokeAddFramework(&allocator2),
                       FutureSatisfy(&addFramework)));
 
@@ -1709,7 +1709,7 @@ TYPED_TEST(MasterAllocatorTest, SlaveReregistersFirst)
 
     // Because the framework was re-added above, we expect to only
     // activate the framework when it reregisters.
-    EXPECT_CALL(allocator2, addFramework(_, _, _, _, _))
+    EXPECT_CALL(allocator2, addFramework_(_, _, _, _, _))
       .Times(0);
 
     EXPECT_CALL(allocator2, activateFramework(_));
@@ -1974,7 +1974,7 @@ TYPED_TEST(MasterAllocatorTest, NestedRoles)
   MesosSchedulerDriver driver1(
       &sched1, frameworkInfo1, master.get()->pid, DEFAULT_CREDENTIAL);
 
-  EXPECT_CALL(allocator, addFramework(_, _, _, _, _));
+  EXPECT_CALL(allocator, addFramework_(_, _, _, _, _));
 
   EXPECT_CALL(sched1, registered(_, _, _));
 
@@ -2004,7 +2004,7 @@ TYPED_TEST(MasterAllocatorTest, NestedRoles)
   MesosSchedulerDriver driver2(
       &sched2, frameworkInfo2, master.get()->pid, DEFAULT_CREDENTIAL);
 
-  EXPECT_CALL(allocator, addFramework(_, _, _, _, _));
+  EXPECT_CALL(allocator, addFramework_(_, _, _, _, _));
 
   Future<Nothing> framework2Registered;
   EXPECT_CALL(sched2, registered(_, _, _))
@@ -2023,7 +2023,7 @@ TYPED_TEST(MasterAllocatorTest, NestedRoles)
   MesosSchedulerDriver driver3(
       &sched3, frameworkInfo3, master.get()->pid, DEFAULT_CREDENTIAL);
 
-  EXPECT_CALL(allocator, addFramework(_, _, _, _, _));
+  EXPECT_CALL(allocator, addFramework_(_, _, _, _, _));
 
   Future<Nothing> framework3Registered;
   EXPECT_CALL(sched3, registered(_, _, _))
diff --git a/src/tests/reservation_tests.cpp b/src/tests/reservation_tests.cpp
index cd84cd2..dd06509 100644
--- a/src/tests/reservation_tests.cpp
+++ b/src/tests/reservation_tests.cpp
@@ -639,7 +639,7 @@ TEST_F(ReservationTest, DropReserveTooLarge)
   EXPECT_CALL(sched, resourceOffers(&driver, _))
     .WillOnce(FutureArg<1>(&offers));
 
-  EXPECT_CALL(allocator, addFramework(_, _, _, _, _));
+  EXPECT_CALL(allocator, addFramework_(_, _, _, _, _));
 
   driver.start();
 
@@ -2150,7 +2150,7 @@ TEST_F(ReservationTest, DropReserveWithDifferentRole)
   EXPECT_CALL(sched, resourceOffers(&driver, _))
     .WillOnce(FutureArg<1>(&offers));
 
-  EXPECT_CALL(allocator, addFramework(_, _, _, _, _));
+  EXPECT_CALL(allocator, addFramework_(_, _, _, _, _));
 
   driver.start();
 
diff --git a/src/tests/resource_offers_tests.cpp 
b/src/tests/resource_offers_tests.cpp
index 08bb109..17bf44f 100644
--- a/src/tests/resource_offers_tests.cpp
+++ b/src/tests/resource_offers_tests.cpp
@@ -293,7 +293,7 @@ TEST_F(ResourceOffersTest, Request)
   MesosSchedulerDriver driver(
       &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
 
-  EXPECT_CALL(allocator, addFramework(_, _, _, _, _));
+  EXPECT_CALL(allocator, addFramework_(_, _, _, _, _));
 
   Future<Nothing> registered;
   EXPECT_CALL(sched, registered(&driver, _, _))
diff --git a/src/tests/slave_recovery_tests.cpp 
b/src/tests/slave_recovery_tests.cpp
index da163a2..1c5177d 100644
--- a/src/tests/slave_recovery_tests.cpp
+++ b/src/tests/slave_recovery_tests.cpp
@@ -3940,7 +3940,7 @@ TYPED_TEST(SlaveRecoveryTest, 
ReconcileTasksMissingFromSlave)
   MesosSchedulerDriver driver(
       &sched, frameworkInfo, master.get()->pid, DEFAULT_CREDENTIAL);
 
-  EXPECT_CALL(allocator, addFramework(_, _, _, _, _));
+  EXPECT_CALL(allocator, addFramework_(_, _, _, _, _));
 
   Future<FrameworkID> frameworkId;
   EXPECT_CALL(sched, registered(_, _, _))

Reply via email to