You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ch...@apache.org on 2018/12/05 22:06:51 UTC

[mesos] 03/06: Made agent state consistent with forwarded updates.

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

chhsiao pushed a commit to branch 1.7.x
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 3c7c4568b1b1d75d43cdf71871599557c54c7656
Author: Benjamin Bannier <be...@mesosphere.io>
AuthorDate: Wed Dec 5 13:02:59 2018 -0800

    Made agent state consistent with forwarded updates.
    
    When the agent handles an `UpdateOperationStatusMessage` from a resource
    provider, it injects its own ID which is (at least conceptually) unknown
    to the resource provider before forwarding the message to the master,
    and also updates its own tracking for the operation.
    
    This patch makes sure that we first mutate the message before handing it
    on for updating the internal operation tracking, while previously we
    used the unmodified message. Always using the same message reduces error
    potential if in future changes we e.g., introduce agent operation status
    update managers.
    
    Review: https://reviews.apache.org/r/69458/
---
 src/slave/slave.cpp | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index 218ca83..50a4729 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -7787,9 +7787,14 @@ void Slave::handleResourceProviderMessage(
     case ResourceProviderMessage::Type::UPDATE_OPERATION_STATUS: {
       CHECK_SOME(message->updateOperationStatus);
 
-      const UpdateOperationStatusMessage& update =
+      // The status update from the resource provider didn't provide
+      // the agent ID (because the resource provider doesn't know it),
+      // hence we inject it here.
+      UpdateOperationStatusMessage update =
         message->updateOperationStatus->update;
 
+      update.mutable_slave_id()->CopyFrom(info.id());
+
       const UUID& operationUUID = update.operation_uuid();
 
       Operation* operation = getOperation(operationUUID);
@@ -7850,14 +7855,7 @@ void Slave::handleResourceProviderMessage(
                  ? " for framework " + stringify(update.framework_id())
                  : " for an operator API call");
 
-          // The status update from the resource provider didn't
-          // provide the agent ID (because the resource provider
-          // doesn't know it), hence we inject it here.
-          UpdateOperationStatusMessage _update;
-          _update.CopyFrom(update);
-          _update.mutable_slave_id()->CopyFrom(info.id());
-
-          send(master.get(), _update);
+          send(master.get(), update);
           break;
         }
       }