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/12/07 21:30:07 UTC
mesos git commit: Updated the allocator to untrack allocations via a
single code path.
Repository: mesos
Updated Branches:
refs/heads/master 9cb85e955 -> 31d718e39
Updated the allocator to untrack allocations via a single code path.
Review: https://reviews.apache.org/r/64357/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/31d718e3
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/31d718e3
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/31d718e3
Branch: refs/heads/master
Commit: 31d718e39697cc63ade47f23b5858ee605091bc0
Parents: 9cb85e9
Author: Meng Zhu <mz...@mesosphere.io>
Authored: Thu Dec 7 13:14:10 2017 -0800
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Thu Dec 7 13:29:48 2017 -0800
----------------------------------------------------------------------
src/master/allocator/mesos/hierarchical.cpp | 58 ++++++++++++++++--------
src/master/allocator/mesos/hierarchical.hpp | 8 +++-
2 files changed, 47 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/31d718e3/src/master/allocator/mesos/hierarchical.cpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/mesos/hierarchical.cpp b/src/master/allocator/mesos/hierarchical.cpp
index d348516..9d8b671 100644
--- a/src/master/allocator/mesos/hierarchical.cpp
+++ b/src/master/allocator/mesos/hierarchical.cpp
@@ -315,6 +315,8 @@ void HierarchicalAllocatorProcess::removeFramework(
foreach (const string& role, framework.roles) {
// Might not be in 'frameworkSorters[role]' because it
// was previously deactivated and never re-added.
+ //
+ // TODO(mzhu): This check may no longer be necessary.
if (!frameworkSorters.contains(role) ||
!frameworkSorters.at(role)->contains(frameworkId.value())) {
continue;
@@ -327,14 +329,7 @@ void HierarchicalAllocatorProcess::removeFramework(
foreachpair (const SlaveID& slaveId,
const Resources& allocated,
allocation) {
- roleSorter->unallocated(role, slaveId, allocated);
- frameworkSorters.at(role)->remove(slaveId, allocated);
-
- if (quotas.contains(role)) {
- // See comment at `quotaRoleSorter` declaration
- // regarding non-revocable.
- quotaRoleSorter->unallocated(role, slaveId, allocated.nonRevocable());
- }
+ untrackAllocatedResources(slaveId, frameworkId, allocated);
}
untrackFrameworkUnderRole(frameworkId, role);
@@ -1168,16 +1163,7 @@ void HierarchicalAllocatorProcess::recoverResources(
const Owned<Sorter>& frameworkSorter = frameworkSorters.at(role);
if (frameworkSorter->contains(frameworkId.value())) {
- frameworkSorter->unallocated(frameworkId.value(), slaveId, resources);
- frameworkSorter->remove(slaveId, resources);
- roleSorter->unallocated(role, slaveId, resources);
-
- if (quotas.contains(role)) {
- // See comment at `quotaRoleSorter` declaration
- // regarding non-revocable
- quotaRoleSorter->unallocated(
- role, slaveId, resources.nonRevocable());
- }
+ untrackAllocatedResources(slaveId, frameworkId, resources);
// Stop tracking the framework under this role if it's no longer
// subscribed and no longer has resources allocated to the role.
@@ -2511,6 +2497,42 @@ void HierarchicalAllocatorProcess::trackAllocatedResources(
}
}
+
+void HierarchicalAllocatorProcess::untrackAllocatedResources(
+ const SlaveID& slaveId,
+ const FrameworkID& frameworkId,
+ const Resources& allocated)
+{
+ // TODO(mzhu): Add a `CHECK(slaves.contains(slaveId));`
+ // here once MESOS-621 is resolved. Ideally, `removeSlave()`
+ // should unallocate resources in the framework sorters.
+ // But currently, a slave is removed first via `removeSlave()`
+ // and later a call to `recoverResources()` occurs to recover
+ // the framework's resources.
+ CHECK(frameworks.contains(frameworkId));
+
+ // TODO(bmahler): Calling allocations() is expensive since it has
+ // to construct a map. Avoid this.
+ foreachpair (const string& role,
+ const Resources& allocation,
+ allocated.allocations()) {
+ CHECK(roleSorter->contains(role));
+ CHECK(frameworkSorters.contains(role));
+ CHECK(frameworkSorters.at(role)->contains(frameworkId.value()));
+
+ frameworkSorters.at(role)->unallocated(
+ frameworkId.value(), slaveId, allocation);
+ frameworkSorters.at(role)->remove(slaveId, allocation);
+
+ roleSorter->unallocated(role, slaveId, allocation);
+
+ if (quotas.contains(role)) {
+ // See comment at `quotaRoleSorter` declaration regarding non-revocable.
+ quotaRoleSorter->unallocated(role, slaveId, allocation.nonRevocable());
+ }
+ }
+}
+
} // namespace internal {
} // namespace allocator {
} // namespace master {
http://git-wip-us.apache.org/repos/asf/mesos/blob/31d718e3/src/master/allocator/mesos/hierarchical.hpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/mesos/hierarchical.hpp b/src/master/allocator/mesos/hierarchical.hpp
index 0622026..41801eb 100644
--- a/src/master/allocator/mesos/hierarchical.hpp
+++ b/src/master/allocator/mesos/hierarchical.hpp
@@ -550,12 +550,18 @@ private:
// the agent and the master are both configured with a fault domain.
bool isRemoteSlave(const Slave& slave) const;
- // Helper to track used resources on an agent.
+ // Helper to track allocated resources on an agent.
void trackAllocatedResources(
const SlaveID& slaveId,
const FrameworkID& frameworkId,
const Resources& allocated);
+ // Helper to untrack resources that are no longer allocated on an agent.
+ void untrackAllocatedResources(
+ const SlaveID& slaveId,
+ const FrameworkID& frameworkId,
+ const Resources& allocated);
+
// Helper that removes all existing offer filters for the given slave
// id.
void removeFilters(const SlaveID& slaveId);