This is an automated email from the ASF dual-hosted git repository.

grag pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git


The following commit(s) were added to refs/heads/master by this push:
     new 6bf9582  Updated the master to allocate recovered orphan operation 
resources.
6bf9582 is described below

commit 6bf9582c35cce5fe38ae559d2d44b03a8383b9ec
Author: Greg Mann <[email protected]>
AuthorDate: Thu Apr 4 11:59:37 2019 -0700

    Updated the master to allocate recovered orphan operation resources.
    
    This patch updates the master's framework recovery code to use
    the allocator's `addResourceProvider()` method rather than
    `updateSlave()` when recovering orphan operations, which has the
    benefit of tracking the allocation of the operations' consumed
    resources, avoiding situations in which those resources would be
    incorrectly offered to frameworks while the operation is still
    in a pending state.
    
    Review: https://reviews.apache.org/r/70325/
---
 src/master/master.cpp | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/master/master.cpp b/src/master/master.cpp
index cf5caa0..ad54ae2 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -10543,15 +10543,30 @@ void Master::recoverFramework(
           slave->totalResources += consumedUnallocated;
           slave->usedResources[framework->id()] += consumed.get();
 
-          allocator->updateSlave(slave->id, slave->info, 
slave->totalResources);
+          hashmap<FrameworkID, Resources> usedResources;
+          usedResources.put(framework->id(), consumed.get());
 
-          // NOTE: The allocation of these orphan operation resources will be
-          // updated in `addFramework` below.
+          // This call to `addResourceProvider()` adds orphan operation
+          // resources back to the agent's total and used resources. This
+          // prevents these resources from being offered while the operation is
+          // still pending.
+          //
+          // NOTE: We intentionally call `addResourceProvider()` before we call
+          // `addFramework()` below because if the order were reversed, these
+          // resources would be incorrectly tracked twice in the allocator.
+          allocator->addResourceProvider(
+              slave->id,
+              consumedUnallocated,
+              usedResources);
         }
       }
     }
   }
 
+  // NOTE: We intentionally call `addFramework()` after we called
+  // `addResourceProvider()` above because if the order were reversed, the
+  // resources of orphan operations would be incorrectly tracked twice in the
+  // allocator.
   addFramework(framework, suppressedRoles);
 }
 

Reply via email to