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 19:59:00 UTC
[16/16] mesos git commit: Maintenance Primitives: Added Accept /
Decline for InverseOffers.
Maintenance Primitives: Added Accept / Decline for InverseOffers.
Review: https://reviews.apache.org/r/37284
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/a127671a
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/a127671a
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/a127671a
Branch: refs/heads/master
Commit: a127671a726542e21cc7bc8838aa882b6bec4b49
Parents: bf82689
Author: Joris Van Remoortere <jo...@gmail.com>
Authored: Sun Aug 30 14:28:53 2015 -0400
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Mon Sep 14 13:58:37 2015 -0400
----------------------------------------------------------------------
src/master/master.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 53 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/a127671a/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 52d5763..61236b3 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -2789,6 +2789,11 @@ void Master::accept(
// validation failed, return resources to the allocator.
foreach (const OfferID& offerId, accept.offer_ids()) {
Offer* offer = getOffer(offerId);
+
+ // Since we re-use `OfferID`s, it is possible to arrive here with either
+ // a resource offer, or an inverse offer. We first try as a resource offer
+ // and if that fails, then we assume it is an inverse offer. This is
+ // correct as those are currently the only 2 ways to get an `OfferID`.
if (offer != NULL) {
slaveId = offer->slave_id();
offeredResources += offer->resources();
@@ -2801,7 +2806,29 @@ void Master::accept(
None());
}
removeOffer(offer);
+ continue;
+ }
+
+ // Try it as an inverse offer. If this fails then the offer is no longer
+ // valid.
+ InverseOffer* inverseOffer = getInverseOffer(offerId);
+ if (inverseOffer != NULL) {
+ mesos::master::InverseOfferStatus status;
+ status.set_status(mesos::master::InverseOfferStatus::ACCEPT);
+
+ allocator->updateInverseOffer(
+ offer->slave_id(),
+ offer->framework_id(),
+ status);
+
+ removeInverseOffer(inverseOffer);
+ continue;
}
+
+ // If the offer was neither in our offer or inverse offer sets, then this
+ // offer is no longer valid.
+ LOG(WARNING) << "Ignoring accept of offer " << offerId
+ << " since it is no longer valid";
}
}
@@ -3237,6 +3264,10 @@ void Master::decline(
// Return resources to the allocator.
foreach (const OfferID& offerId, decline.offer_ids()) {
+ // Since we re-use `OfferID`s, it is possible to arrive here with either a
+ // resource offer, or an inverse offer. We first try as a resource offer and
+ // if that fails, then we assume it is an inverse offer. This is correct as
+ // those are currently the only 2 ways to get an `OfferID`.
Offer* offer = getOffer(offerId);
if (offer != NULL) {
allocator->recoverResources(
@@ -3246,10 +3277,29 @@ void Master::decline(
decline.filters());
removeOffer(offer);
- } else {
- LOG(WARNING) << "Ignoring decline of offer " << offerId
- << " since it is no longer valid";
+ continue;
+ }
+
+ // Try it as an inverse offer. If this fails then the offer is no longer
+ // valid.
+ InverseOffer* inverseOffer = getInverseOffer(offerId);
+ if (inverseOffer != NULL) { // If this is an inverse offer.
+ mesos::master::InverseOfferStatus status;
+ status.set_status(mesos::master::InverseOfferStatus::DECLINE);
+
+ allocator->updateInverseOffer(
+ offer->slave_id(),
+ offer->framework_id(),
+ status);
+
+ removeInverseOffer(inverseOffer);
+ continue;
}
+
+ // If the offer was neither in our offer or inverse offer sets, then this
+ // offer is no longer valid.
+ LOG(WARNING) << "Ignoring decline of offer " << offerId
+ << " since it is no longer valid";
}
}