You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bb...@apache.org on 2017/12/08 16:02:22 UTC
[4/5] mesos git commit: Removed 'total' from 'UpdateSlaveMessage'.
Removed 'total' from 'UpdateSlaveMessage'.
This field was added during the development leading up to version 1.5
in order to allow updates to agent-total resources in the context of
resource providers. It was never used in a released Mesos version.
Review: https://reviews.apache.org/r/64424
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/bd55be10
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/bd55be10
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/bd55be10
Branch: refs/heads/master
Commit: bd55be1066b8f2553e10e9d5bd35a3582f659b00
Parents: 7cfa0e9
Author: Benjamin Bannier <bb...@apache.org>
Authored: Wed Dec 6 14:27:34 2017 +0100
Committer: Benjamin Bannier <bb...@apache.org>
Committed: Fri Dec 8 13:59:41 2017 +0100
----------------------------------------------------------------------
src/master/master.cpp | 51 ++++++++++++++++++----------------------
src/messages/messages.proto | 16 +++++--------
2 files changed, 29 insertions(+), 38 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/bd55be10/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 8cf699b..3b2fcb8 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -7211,12 +7211,6 @@ void Master::updateSlave(const UpdateSlaveMessage& message)
message.resource_categories().oversubscribed()) ||
!message.has_resource_categories();
- const bool hasTotal =
- message.has_resource_categories() &&
- message.resource_categories().has_total() &&
- message.resource_categories().total();
-
- Option<Resources> newTotal;
Option<Resources> newOversubscribed;
// Make a copy of the message so we can transform its resources.
@@ -7226,21 +7220,6 @@ void Master::updateSlave(const UpdateSlaveMessage& message)
message_.mutable_oversubscribed_resources(),
POST_RESERVATION_REFINEMENT);
- convertResourceFormat(
- message_.mutable_total_resources(),
- POST_RESERVATION_REFINEMENT);
-
- // Agents will send a total if a resource provider subscribed or went away.
- // Process resources and operations grouped by resource provider.
- if (hasTotal) {
- const Resources& totalResources = message_.total_resources();
-
- LOG(INFO) << "Received update of agent " << *slave << " with total"
- << " resources " << totalResources;
-
- newTotal = totalResources;
- }
-
if (hasOversubscribed) {
const Resources& oversubscribedResources =
message_.oversubscribed_resources();
@@ -7251,15 +7230,30 @@ void Master::updateSlave(const UpdateSlaveMessage& message)
newOversubscribed = oversubscribedResources;
}
+ Resources newResourceProviderResources;
+ if (message.has_resource_providers()) {
+ foreach (
+ const UpdateSlaveMessage::ResourceProvider& resourceProvider,
+ message.resource_providers().providers()) {
+ newResourceProviderResources += resourceProvider.total_resources();
+ }
+ }
+
auto agentResources = [](const Resource& resource) {
return !resource.has_provider_id();
};
const Resources newSlaveResources =
- newTotal.getOrElse(slave->totalResources.nonRevocable()) +
- newOversubscribed.getOrElse(slave->totalResources.revocable());
+ slave->totalResources.nonRevocable().filter(agentResources) +
+ newOversubscribed.getOrElse(
+ slave->totalResources.revocable().filter(agentResources)) +
+ newResourceProviderResources;
- bool updated = slave->totalResources != newSlaveResources;
+ // TODO(bbannier): We only need to update if any changes from
+ // resource providers are reported.
+ bool updated =
+ slave->totalResources != newSlaveResources ||
+ message.has_resource_providers();
// Agents which can support resource providers always update the
// master on their resource versions uuids via `UpdateSlaveMessage`.
@@ -7657,11 +7651,12 @@ void Master::updateSlave(const UpdateSlaveMessage& message)
rescind = true;
}
- // For updates to the agent's total resources all offers are rescinded.
+ // Updates on resource providers can change the agent total
+ // resources, so we rescind all offers.
//
- // TODO(bbannier): Only rescind offers possibly containing removed
- // resources.
- if (hasTotal) {
+ // TODO(bbannier): Only rescind offers possibly containing
+ // affected resources.
+ if (message.has_resource_providers()) {
LOG(INFO) << "Removing offer " << offer->id() << " with resources "
<< offered << " on agent " << *slave;
http://git-wip-us.apache.org/repos/asf/mesos/blob/bd55be10/src/messages/messages.proto
----------------------------------------------------------------------
diff --git a/src/messages/messages.proto b/src/messages/messages.proto
index 53db010..0b44ba2 100644
--- a/src/messages/messages.proto
+++ b/src/messages/messages.proto
@@ -723,23 +723,19 @@ message UpdateSlaveMessage {
// TODO(bbannier): Consider passing agent information inside a
// `ResourceProvider` value as well where applicable.
- // This message can contain `oversubscribed_resources` or
- // `total_resources`. Callers are expected to set the respective
- // categories in `resource_categories` to denote which fields should
- // be examined. For backwards compatibility we interpret an unset
- // `category` field as if only oversubscribed was set.
- //
- // Oversubscribed resources must be revocable, while total resources
- // must be non-revocable.
+ // This message can contain `oversubscribed_resources` or resource
+ // providers. Callers are expected to set the `oversubscribed`
+ // category in `resource_categories` to denote whether the
+ // `oversubscribed_resources` field should be examined. For
+ // backwards compatibility we interpret an unset `category` field as
+ // if only oversubscribed was set.
message ResourceCategories {
- optional bool total = 1;
optional bool oversubscribed = 2;
}
optional ResourceCategories resource_categories = 5;
repeated Resource oversubscribed_resources = 2;
- repeated Resource total_resources = 4;
message OfferOperations {
repeated OfferOperation operations = 1;