You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by me...@apache.org on 2016/03/30 22:52:26 UTC
[1/2] mesos git commit: Rescind all outstanding offers to satisfy
weights update.
Repository: mesos
Updated Branches:
refs/heads/master c6d618222 -> c01542485
Rescind all outstanding offers to satisfy weights update.
Review: https://reviews.apache.org/r/44450/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/c0154248
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/c0154248
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/c0154248
Branch: refs/heads/master
Commit: c015424859da4de349459075960b68ee784dec8d
Parents: 5a4680d
Author: Yongqiao Wang <yq...@cn.ibm.com>
Authored: Wed Mar 30 04:34:11 2016 -0700
Committer: Adam B <ad...@mesosphere.io>
Committed: Wed Mar 30 13:49:40 2016 -0700
----------------------------------------------------------------------
src/master/master.hpp | 4 +++
src/master/weights_handler.cpp | 51 +++++++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/c0154248/src/master/master.hpp
----------------------------------------------------------------------
diff --git a/src/master/master.hpp b/src/master/master.hpp
index 124d439..1751ee1 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -1044,6 +1044,10 @@ private:
process::Future<process::http::Response> _update(
const std::vector<WeightInfo>& updateWeightInfos) const;
+ // Rescind all outstanding offers if any of the 'weightInfos' roles has
+ // an active framework.
+ void rescindOffers(const std::vector<WeightInfo>& weightInfos) const;
+
Master* master;
};
http://git-wip-us.apache.org/repos/asf/mesos/blob/c0154248/src/master/weights_handler.cpp
----------------------------------------------------------------------
diff --git a/src/master/weights_handler.cpp b/src/master/weights_handler.cpp
index c9a1b0d..e88bf2a 100644
--- a/src/master/weights_handler.cpp
+++ b/src/master/weights_handler.cpp
@@ -26,6 +26,7 @@
#include <stout/stringify.hpp>
#include <stout/strings.hpp>
+#include <stout/utils.hpp>
#include "master/weights.hpp"
@@ -131,11 +132,61 @@ Future<http::Response> Master::WeightsHandler::_update(
// Notify allocator for updating weights.
master->allocator->updateWeights(weightInfos);
+
+ // If any active role is updated, we rescind all outstanding offers,
+ // to facilitate satisfying the updated weights.
+ // NOTE: We update weights before we rescind to avoid a race. If we were
+ // to rescind first, then recovered resources may get allocated again
+ // before our call to `updateWeights` was handled.
+ // The consequence of updating weights first is that (in the hierarchical
+ // allocator) it will trigger an allocation if at least one of the
+ // updated roles has registered frameworks. This means the rescinded
+ // offer resources will only be available to the updated weights once
+ // another allocation is invoked.
+ // This can be resolved in the future with an explicit allocation call,
+ // and this solution is preferred to having the race described earlier.
+ rescindOffers(weightInfos);
+
return OK();
}));
}
+void Master::WeightsHandler::rescindOffers(
+ const std::vector<WeightInfo>& weightInfos) const
+{
+ bool rescind = false;
+
+ foreach (const WeightInfo& weightInfo, weightInfos) {
+ const string& role = weightInfo.role();
+
+ // This should have been validated earlier.
+ CHECK(master->isWhitelistedRole(role));
+
+ // Rescind all outstanding offers if at least one of the
+ // updated roles has a registered frameworks.
+ if (master->activeRoles.contains(role)) {
+ rescind = true;
+ break;
+ }
+ }
+
+ if (rescind) {
+ foreachvalue (const Slave* slave, master->slaves.registered) {
+ foreach (Offer* offer, utils::copy(slave->offers)) {
+ master->allocator->recoverResources(
+ offer->framework_id(),
+ offer->slave_id(),
+ offer->resources(),
+ None());
+
+ master->removeOffer(offer, true);
+ }
+ }
+ }
+}
+
+
Future<bool> Master::WeightsHandler::authorize(
const Option<string>& principal,
const vector<string>& roles) const
[2/2] mesos git commit: Made the Action enum optional to support
upgrades (MESOS-5031).
Posted by me...@apache.org.
Made the Action enum optional to support upgrades (MESOS-5031).
This fix makes the Action enum in Authorization optional to support
upgrades. See MESOS-4997 for details.
Review: https://reviews.apache.org/r/45342/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/5a4680d1
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/5a4680d1
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/5a4680d1
Branch: refs/heads/master
Commit: 5a4680d1b9abda1bbcfea497ffe95af16dd71387
Parents: c6d6182
Author: Yong Tang <yo...@outlook.com>
Authored: Wed Mar 30 04:22:29 2016 -0700
Committer: Adam B <ad...@mesosphere.io>
Committed: Wed Mar 30 13:49:40 2016 -0700
----------------------------------------------------------------------
include/mesos/authorizer/authorizer.proto | 13 +++++++++++--
src/authorizer/local/authorizer.cpp | 5 +++++
2 files changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/5a4680d1/include/mesos/authorizer/authorizer.proto
----------------------------------------------------------------------
diff --git a/include/mesos/authorizer/authorizer.proto b/include/mesos/authorizer/authorizer.proto
index 944a493..40d93ea 100644
--- a/include/mesos/authorizer/authorizer.proto
+++ b/include/mesos/authorizer/authorizer.proto
@@ -42,6 +42,12 @@ message Object {
// List of authorizable actions supported in Mesos.
enum Action {
+ // This must be the first enum value in this list, to
+ // ensure that if 'type' is not set, the default value
+ // is UNKNOWN. This enables enum values to be added
+ // in a backwards-compatible way. See: MESOS-4997.
+ UNKNOWN = 0;
+
REGISTER_FRAMEWORK_WITH_ROLE = 1;
RUN_TASK_WITH_USER = 2;
TEARDOWN_FRAMEWORK_WITH_PRINCIPAL = 3;
@@ -59,6 +65,9 @@ enum Action {
// as "Can `subject` perform `action` with `object`?".
message Request {
required Subject subject = 1;
- required Action action = 2;
+
+ // Enum fields should be optional, see: MESOS-4997.
+ optional Action action = 2;
+
required Object object = 3;
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/mesos/blob/5a4680d1/src/authorizer/local/authorizer.cpp
----------------------------------------------------------------------
diff --git a/src/authorizer/local/authorizer.cpp b/src/authorizer/local/authorizer.cpp
index 0f0d927..c744a16 100644
--- a/src/authorizer/local/authorizer.cpp
+++ b/src/authorizer/local/authorizer.cpp
@@ -201,6 +201,11 @@ public:
return authorized(request, acls_);
break;
+ default:
+ LOG(WARNING) << "Authorization request for action '" << request.action()
+ << "' is not defined and therefore not authorized";
+ return false;
+ break;
}
UNREACHABLE();
}