You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by mp...@apache.org on 2017/02/08 00:38:23 UTC

[7/7] mesos git commit: Tightened assertions in sorter and allocator + fixed a mistaken comment.

Tightened assertions in sorter and allocator + fixed a mistaken comment.

Review: https://reviews.apache.org/r/56251/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/f1df9b80
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/f1df9b80
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/f1df9b80

Branch: refs/heads/master
Commit: f1df9b80229986d06ed6003b77ea95e95cb95ebe
Parents: 61d3f39
Author: Neil Conway <ne...@gmail.com>
Authored: Mon Feb 6 13:05:25 2017 -0800
Committer: Michael Park <mp...@apache.org>
Committed: Tue Feb 7 16:23:43 2017 -0800

----------------------------------------------------------------------
 src/master/allocator/mesos/hierarchical.cpp |  1 +
 src/master/allocator/sorter/drf/sorter.cpp  | 15 +++++++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/f1df9b80/src/master/allocator/mesos/hierarchical.cpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/mesos/hierarchical.cpp b/src/master/allocator/mesos/hierarchical.cpp
index 2eab005..017253c 100644
--- a/src/master/allocator/mesos/hierarchical.cpp
+++ b/src/master/allocator/mesos/hierarchical.cpp
@@ -466,6 +466,7 @@ void HierarchicalAllocatorProcess::addSlave(
       // framework's role.
       CHECK(roleSorter->contains(role));
       CHECK(frameworkSorters.contains(role));
+      CHECK(frameworkSorters.at(role)->contains(frameworkId.value()));
 
       roleSorter->allocated(role, slaveId, allocated);
       frameworkSorters.at(role)->add(slaveId, allocated);

http://git-wip-us.apache.org/repos/asf/mesos/blob/f1df9b80/src/master/allocator/sorter/drf/sorter.cpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/sorter/drf/sorter.cpp b/src/master/allocator/sorter/drf/sorter.cpp
index 8e5548d..ae49fcd 100644
--- a/src/master/allocator/sorter/drf/sorter.cpp
+++ b/src/master/allocator/sorter/drf/sorter.cpp
@@ -99,6 +99,8 @@ void DRFSorter::update(const string& name, double weight)
 
 void DRFSorter::remove(const string& name)
 {
+  CHECK(contains(name));
+
   set<Client, DRFComparator>::iterator it = find(name);
 
   if (it != clients.end()) {
@@ -128,6 +130,8 @@ void DRFSorter::activate(const string& name)
 
 void DRFSorter::deactivate(const string& name)
 {
+  CHECK(contains(name));
+
   set<Client, DRFComparator>::iterator it = find(name);
 
   if (it != clients.end()) {
@@ -145,9 +149,15 @@ void DRFSorter::allocated(
     const SlaveID& slaveId,
     const Resources& resources)
 {
+  CHECK(contains(name));
+
   set<Client, DRFComparator>::iterator it = find(name);
 
-  if (it != clients.end()) { // TODO(benh): This should really be a CHECK.
+  // The allocator might notify us about an allocation that has been
+  // made to an inactive sorter client. For example, this happens when
+  // an agent re-registers that is running tasks for a framework that
+  // has not yet re-registered.
+  if (it != clients.end()) {
     // TODO(benh): Refactor 'update' to be able to reuse it here.
     Client client(*it);
 
@@ -283,9 +293,10 @@ void DRFSorter::unallocated(
     const SlaveID& slaveId,
     const Resources& resources)
 {
+  CHECK(contains(name));
   CHECK(allocations[name].resources.contains(slaveId));
-
   CHECK(allocations[name].resources[slaveId].contains(resources));
+
   allocations[name].resources[slaveId] -= resources;
 
   // Remove shared resources from the allocated quantities when there