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/12/04 18:46:56 UTC
mesos git commit: Quota: Filtered revocable resources out of
quotaRoleSorter in allocator.
Repository: mesos
Updated Branches:
refs/heads/master fe4be25fa -> ffa8392d7
Quota: Filtered revocable resources out of quotaRoleSorter in allocator.
Review: https://reviews.apache.org/r/40821
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/ffa8392d
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/ffa8392d
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/ffa8392d
Branch: refs/heads/master
Commit: ffa8392d71b13f5c65e64acbf433db3bb9257f31
Parents: fe4be25
Author: Alexander Rukletsov <ru...@gmail.com>
Authored: Fri Dec 4 12:33:30 2015 -0500
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Fri Dec 4 12:43:48 2015 -0500
----------------------------------------------------------------------
src/master/allocator/mesos/hierarchical.cpp | 47 ++++++++++++------------
src/master/allocator/mesos/hierarchical.hpp | 2 +
2 files changed, 26 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/ffa8392d/src/master/allocator/mesos/hierarchical.cpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/mesos/hierarchical.cpp b/src/master/allocator/mesos/hierarchical.cpp
index d05be4c..5da825a 100644
--- a/src/master/allocator/mesos/hierarchical.cpp
+++ b/src/master/allocator/mesos/hierarchical.cpp
@@ -244,7 +244,8 @@ void HierarchicalAllocatorProcess::addFramework(
frameworkSorters[role]->allocated(frameworkId.value(), slaveId, allocated);
if (roles[role].quota.isSome()) {
- quotaRoleSorter->allocated(role, slaveId, allocated.unreserved());
+ quotaRoleSorter->allocated(
+ role, slaveId, allocated.unreserved().nonRevocable());
}
}
@@ -290,7 +291,8 @@ void HierarchicalAllocatorProcess::removeFramework(
frameworkSorters[role]->remove(slaveId, allocated);
if (roles[role].quota.isSome()) {
- quotaRoleSorter->unallocated(role, slaveId, allocated.unreserved());
+ quotaRoleSorter->unallocated(
+ role, slaveId, allocated.unreserved().nonRevocable());
}
}
@@ -387,7 +389,7 @@ void HierarchicalAllocatorProcess::addSlave(
CHECK(!paused || expectedAgentCount.isSome());
roleSorter->add(slaveId, total.unreserved());
- quotaRoleSorter->add(slaveId, total.unreserved());
+ quotaRoleSorter->add(slaveId, total.unreserved().nonRevocable());
// Update the allocation for each framework.
foreachpair (const FrameworkID& frameworkId,
@@ -405,7 +407,8 @@ void HierarchicalAllocatorProcess::addSlave(
frameworkId.value(), slaveId, allocated);
if (roles[role].quota.isSome()) {
- quotaRoleSorter->allocated(role, slaveId, allocated.unreserved());
+ quotaRoleSorter->allocated(
+ role, slaveId, allocated.unreserved().nonRevocable());
}
}
}
@@ -463,7 +466,8 @@ void HierarchicalAllocatorProcess::removeSlave(
// than what we currently track in the allocator.
roleSorter->remove(slaveId, slaves[slaveId].total.unreserved());
- quotaRoleSorter->remove(slaveId, slaves[slaveId].total.unreserved());
+ quotaRoleSorter->remove(
+ slaveId, slaves[slaveId].total.unreserved().nonRevocable());
slaves.erase(slaveId);
@@ -494,7 +498,8 @@ void HierarchicalAllocatorProcess::updateSlave(
// Now, update the total resources in the role sorters.
roleSorter->update(slaveId, slaves[slaveId].total.unreserved());
- quotaRoleSorter->update(slaveId, slaves[slaveId].total.unreserved());
+ quotaRoleSorter->update(
+ slaveId, slaves[slaveId].total.unreserved().nonRevocable());
LOG(INFO) << "Slave " << slaveId << " (" << slaves[slaveId].hostname << ")"
<< " updated with oversubscribed resources " << oversubscribed
@@ -600,8 +605,8 @@ void HierarchicalAllocatorProcess::updateAllocation(
quotaRoleSorter->update(
role,
slaveId,
- frameworkAllocation.unreserved(),
- updatedFrameworkAllocation.get().unreserved());
+ frameworkAllocation.unreserved().nonRevocable(),
+ updatedFrameworkAllocation.get().unreserved().nonRevocable());
}
Try<Resources> updatedSlaveAllocation =
@@ -658,7 +663,8 @@ Future<Nothing> HierarchicalAllocatorProcess::updateAvailable(
// Now, update the total resources in the role sorters.
roleSorter->update(slaveId, slaves[slaveId].total.unreserved());
- quotaRoleSorter->update(slaveId, slaves[slaveId].total.unreserved());
+ quotaRoleSorter->update(
+ slaveId, slaves[slaveId].total.unreserved().nonRevocable());
return Nothing();
}
@@ -838,7 +844,8 @@ void HierarchicalAllocatorProcess::recoverResources(
roleSorter->unallocated(role, slaveId, resources.unreserved());
if (roles[role].quota.isSome()) {
- quotaRoleSorter->unallocated(role, slaveId, resources.unreserved());
+ quotaRoleSorter->unallocated(
+ role, slaveId, resources.unreserved().nonRevocable());
}
}
}
@@ -976,7 +983,7 @@ void HierarchicalAllocatorProcess::setQuota(
foreachpair (
const SlaveID& slaveId, const Resources& resources, roleAllocation) {
quotaRoleSorter->allocated(
- role, slaveId, resources.unreserved());
+ role, slaveId, resources.unreserved().nonRevocable());
}
// TODO(alexr): Print all quota info for the role.
@@ -1124,14 +1131,12 @@ void HierarchicalAllocatorProcess::allocate(
// Summing up resources is fine because quota is only for scalar
// resources.
- // NOTE: Allocation for a quota'ed role may contain revocable resources
- // from the WDRF stage, which we should not count towards quota.
+ // NOTE: Reserved and revocable resources are excluded in
+ // `quotaRoleSorter`.
// TODO(alexr): Consider including dynamically reserved resources.
Resources roleConsumedResources =
Resources::sum(quotaRoleSorter->allocation(role));
- roleConsumedResources -= roleConsumedResources.revocable();
-
// If quota for the role is satisfied, we do not need to do any further
// allocations, at least at this stage.
// TODO(alexr): Skipping satisfied roles is pessimistic. Better
@@ -1158,8 +1163,7 @@ void HierarchicalAllocatorProcess::allocate(
// resources on the agent.
// TODO(alexr): Consider adding dynamically reserved resources.
Resources available = slaves[slaveId].total - slaves[slaveId].allocated;
- Resources resources = available.unreserved();
- resources -= resources.revocable();
+ Resources resources = available.unreserved().nonRevocable();
// NOTE: The resources may not be allocatable here, but they can be
// accepted by some framework during the DRF allocation stage.
@@ -1212,13 +1216,9 @@ void HierarchicalAllocatorProcess::allocate(
}
// Compute the amount of quota that the role does not have allocated.
- // NOTE: Allocation for a quota'ed role may contain revocable resources
- // from the WDRF stage, which we should not count towards quota.
+ // NOTE: Reserved and revocable resources are excluded in `quotaRoleSorter`.
Resources allocated = Resources::sum(quotaRoleSorter->allocation(name));
- allocated -= allocated.revocable();
-
const Resources required = role.quota.get().guarantee();
-
unallocatedQuotaResources += (required - allocated);
}
@@ -1306,7 +1306,8 @@ void HierarchicalAllocatorProcess::allocate(
roleSorter->allocated(role, slaveId, resources.unreserved());
if (roles[role].quota.isSome()) {
- quotaRoleSorter->allocated(role, slaveId, resources.unreserved());
+ quotaRoleSorter->allocated(
+ role, slaveId, resources.unreserved().nonRevocable());
}
}
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/ffa8392d/src/master/allocator/mesos/hierarchical.hpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/mesos/hierarchical.hpp b/src/master/allocator/mesos/hierarchical.hpp
index 388ed17..99c7429 100644
--- a/src/master/allocator/mesos/hierarchical.hpp
+++ b/src/master/allocator/mesos/hierarchical.hpp
@@ -399,6 +399,8 @@ protected:
// A dedicated sorter for roles for which quota is set. Quota'ed roles
// belong to an extra allocation group and have resources allocated up
// to their alloted quota prior to non-quota'ed roles.
+ // NOTE: This sorter counts only unreserved non-revocable resources.
+ // TODO(alexr): Consider including dynamically reserved resources.
Sorter* quotaRoleSorter;
Sorter* roleSorter;