You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by gr...@apache.org on 2017/12/07 19:54:54 UTC

[4/6] mesos git commit: Added offer operation update acknowledgement to the agent.

Added offer operation update acknowledgement to the agent.

The agent's 'offerOperationUpdateAcknowlegement' handler is
updated to pass acknowledgements to the resource provider
manager.

The agent's resource provider message handler is also
updated to avoid removing offer operations, since this
should actually be done upon acknowledgement of the update.

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


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

Branch: refs/heads/master
Commit: cfb634b6742d3b6d74bef079473663d915014cfc
Parents: ecef069
Author: Greg Mann <gr...@mesosphere.io>
Authored: Thu Dec 7 11:36:17 2017 -0800
Committer: Greg Mann <gr...@gmail.com>
Committed: Thu Dec 7 11:38:31 2017 -0800

----------------------------------------------------------------------
 src/slave/slave.cpp | 31 +++++++++++++++++++++++++------
 1 file changed, 25 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/cfb634b6/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index dd830d9..133c0d5 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -3896,10 +3896,33 @@ void Slave::statusUpdateAcknowledgement(
 }
 
 
-// TODO(greggomann): Implement offer operation update acknowledgement.
 void Slave::offerOperationUpdateAcknowledgement(
     const UPID& from,
-    const OfferOperationUpdateAcknowledgementMessage& acknowledgement) {}
+    const OfferOperationUpdateAcknowledgementMessage& acknowledgement)
+{
+  Try<UUID> operationUuid = UUID::fromBytes(acknowledgement.operation_uuid());
+  CHECK_SOME(operationUuid);
+
+  OfferOperation* operation = getOfferOperation(operationUuid.get());
+  if (operation != nullptr) {
+    resourceProviderManager.acknowledgeOfferOperationUpdate(acknowledgement);
+
+    CHECK(operation->statuses_size() > 0);
+    if (protobuf::isTerminalState(
+            operation->statuses(operation->statuses_size() - 1).state())) {
+      // Note that if this acknowledgement is dropped due to resource provider
+      // disconnection, the resource provider will inform the agent about the
+      // operation via an UPDATE_STATE call after it reregisters, which will
+      // cause the agent to add the operation back.
+      removeOfferOperation(operation);
+    }
+  } else {
+    LOG(WARNING) << "Dropping offer operation update acknowledgement with"
+                 << " status_uuid " << acknowledgement.status_uuid() << " and"
+                 << " operation_uuid " << acknowledgement.operation_uuid()
+                 << " because the operation was not found";
+  }
+}
 
 
 void Slave::_statusUpdateAcknowledgement(
@@ -7131,10 +7154,6 @@ void Slave::handleResourceProviderMessage(
           break;
         }
       }
-
-      if (protobuf::isTerminalState(operation->latest_status().state())) {
-        removeOfferOperation(operation);
-      }
     }
   }