Made the agent respond to reconciliation requests for default resources.

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


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

Branch: refs/heads/master
Commit: d0d5f5c46de7dabb08d54b7c7f8c7f31e184de52
Parents: 01832c0
Author: Greg Mann <g...@mesosphere.io>
Authored: Tue Dec 12 16:19:19 2017 -0800
Committer: Greg Mann <gregorywm...@gmail.com>
Committed: Tue Dec 12 16:55:47 2017 -0800

----------------------------------------------------------------------
 src/slave/slave.cpp | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/d0d5f5c4/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index 9584326..d997b42 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -3898,14 +3898,37 @@ void Slave::reconcileOfferOperations(
 {
   bool containsResourceProviderOperations = false;
 
-  // TODO(greggomann): Implement reconciliation for offer
-  // operations on the agent's default resources.
   foreach (
       const ReconcileOfferOperationsMessage::Operation& operation,
       message.operations()) {
     if (operation.has_resource_provider_id()) {
       containsResourceProviderOperations = true;
-      break;
+      continue;
+    }
+
+    Try<UUID> operationUuid = UUID::fromBytes(operation.operation_uuid());
+    CHECK_SOME(operationUuid);
+
+    // The master reconciles when it notices that an operation is missing from
+    // an `UpdateSlaveMessage`. If we cannot find an operation in the agent
+    // state, we send an update to inform the master. If we do find the
+    // operation, then the master and agent state are consistent and we do not
+    // need to do anything.
+    OfferOperation* storedOperation = getOfferOperation(operationUuid.get());
+    if (storedOperation == nullptr) {
+      // For agent default resources, we send best-effort offer operation 
status
+      // updates to the master. This is satisfactory because a dropped message
+      // would imply a subsequent agent reregistration, after which an
+      // `UpdateSlaveMessage` would be sent with pending operations.
+      OfferOperationStatusUpdate update =
+        protobuf::createOfferOperationStatusUpdate(
+            operationUuid.get(),
+            protobuf::createOfferOperationStatus(OFFER_OPERATION_DROPPED),
+            None(),
+            None(),
+            info.id());
+
+      send(master.get(), update);
     }
   }
 

Reply via email to