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/08 22:01:27 UTC
mesos git commit: Added validation for roles in ACCEPT call.
Repository: mesos
Updated Branches:
refs/heads/master 22a07afdd -> dfe53db6b
Added validation for roles in ACCEPT call.
For a multi-role framework, it may receive offers for different roles
in that framework. However, we disallow multiple offers with different
roles being accepted in single ACCEPT call.
Review: https://reviews.apache.org/r/54650/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/dfe53db6
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/dfe53db6
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/dfe53db6
Branch: refs/heads/master
Commit: dfe53db6ba6b7c53bcf0d769a412df4e99739795
Parents: 22a07af
Author: Jay Guo <gu...@gmail.com>
Authored: Wed Feb 8 14:00:57 2017 -0800
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Wed Feb 8 14:01:18 2017 -0800
----------------------------------------------------------------------
src/master/master.cpp | 3 ---
src/master/validation.cpp | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/dfe53db6/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 98c39b2..e1e3150 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -3621,9 +3621,6 @@ void Master::accept(
// TODO(jieyu): Add metrics for non launch operations.
}
- // TODO(bmahler): MULTI_ROLE: Validate that the accepted offers
- // do not mix allocation roles, see MESOS-6637.
-
// TODO(bmahler): We currently only support using multiple offers
// for a single slave.
Resources offeredResources;
http://git-wip-us.apache.org/repos/asf/mesos/blob/dfe53db6/src/master/validation.cpp
----------------------------------------------------------------------
diff --git a/src/master/validation.cpp b/src/master/validation.cpp
index c34187d..a54db29 100644
--- a/src/master/validation.cpp
+++ b/src/master/validation.cpp
@@ -1469,6 +1469,39 @@ Option<Error> validateFramework(
}
+// Validate that all offers in one operation must be
+// allocated to the same role.
+Option<Error> validateAllocationRole(
+ const RepeatedPtrField<OfferID>& offerIds,
+ Master* master)
+{
+ Option<string> role;
+ foreach (const OfferID& offerId, offerIds) {
+ Offer* offer = getOffer(master, offerId);
+ if (offer == nullptr) {
+ return Error("Offer " + stringify(offerId) + " is no longer valid");
+ }
+
+ CHECK(offer->has_allocation_info());
+
+ string _role = offer->allocation_info().role();
+ if (role.isNone()) {
+ role = _role;
+ continue;
+ }
+
+ if (_role != role.get()) {
+ return Error(
+ "Aggregated offers must be allocated to the same role. Offer " +
+ stringify(offerId) + " uses role '" + _role + " but another"
+ " is using role '" + role.get());
+ }
+ }
+
+ return None();
+}
+
+
// Validates that all offers belong to the same valid slave.
Option<Error> validateSlave(
const RepeatedPtrField<OfferID>& offerIds,
@@ -1524,6 +1557,7 @@ Option<Error> validate(
lambda::bind(validateUniqueOfferID, offerIds),
lambda::bind(validateOfferIds, offerIds, master),
lambda::bind(validateFramework, offerIds, master, framework),
+ lambda::bind(validateAllocationRole, offerIds, master),
lambda::bind(validateSlave, offerIds, master)
};