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:52 UTC

[mesos] 04/06: Added agent and resource provider IDs to operation status messages.

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 58c7ff57b70e43da479ef2b4ea7f635c2c4a8b73
Author: Benjamin Bannier <be...@mesosphere.io>
AuthorDate: Wed Dec 5 13:03:06 2018 -0800

    Added agent and resource provider IDs to operation status messages.
    
    This patch adds agent and resource provider IDs to
    `UpdateOperationStatus` and `UpdateOperationStatusMessage`. With that
    frameworks are able to reconcile enough information after failover to
    construct operation acknowledgements.
    
    We will add code to populate these fields in a follow-up patch.
    
    Review: https://reviews.apache.org/r/69162/
---
 include/mesos/mesos.proto    | 12 ++++++++++++
 include/mesos/v1/mesos.proto | 12 ++++++++++++
 src/common/type_utils.cpp    | 17 +++++++++++++++++
 src/internal/devolve.cpp     |  8 +++++++-
 src/internal/evolve.cpp      |  8 +++++++-
 5 files changed, 55 insertions(+), 2 deletions(-)

diff --git a/include/mesos/mesos.proto b/include/mesos/mesos.proto
index 2df4dad..043a737 100644
--- a/include/mesos/mesos.proto
+++ b/include/mesos/mesos.proto
@@ -2426,6 +2426,18 @@ message OperationStatus {
   // include a `uuid`. The status is considered delivered once
   // it is acknowledged by the scheduler.
   optional UUID uuid = 5;
+
+  // If the operation affects resources from a local resource provider,
+  // both `slave_id` and `resource_provider_id` will be set.
+  //
+  // If the operation affects resources that belong to an external
+  // resource provider, only `resource_provider_id` will be set.
+  //
+  // In certain cases, e.g., invalid operations, neither `uuid`,
+  // `slave_id` nor `resource_provider_id` will be set, and the
+  // scheduler does not need to acknowledge this status update.
+  optional SlaveID slave_id = 6;
+  optional ResourceProviderID resource_provider_id = 7;
 }
 
 
diff --git a/include/mesos/v1/mesos.proto b/include/mesos/v1/mesos.proto
index 6a04193..9830c0b 100644
--- a/include/mesos/v1/mesos.proto
+++ b/include/mesos/v1/mesos.proto
@@ -2419,6 +2419,18 @@ message OperationStatus {
   // include a `uuid`. The status is considered delivered once
   // it is acknowledged by the scheduler.
   optional UUID uuid = 5;
+
+  // If the operation affects resources from a local resource provider,
+  // both `agent_id` and `resource_provider_id` will be set.
+  //
+  // If the operation affects resources that belong to an external
+  // resource provider, only `resource_provider_id` will be set.
+  //
+  // In certain cases, e.g., invalid operations, neither `uuid`,
+  // `slave_id` nor `resource_provider_id` will be set, and the
+  // scheduler does not need to acknowledge this status update.
+  optional AgentID agent_id = 6;
+  optional ResourceProviderID resource_provider_id = 7;
 }
 
 
diff --git a/src/common/type_utils.cpp b/src/common/type_utils.cpp
index 33d6380..1f0f4a4 100644
--- a/src/common/type_utils.cpp
+++ b/src/common/type_utils.cpp
@@ -488,6 +488,23 @@ bool operator==(const OperationStatus& left, const OperationStatus& right)
     return false;
   }
 
+  if (left.has_slave_id() != right.has_slave_id()) {
+    return false;
+  }
+
+  if (left.has_slave_id() && left.slave_id() != right.slave_id()) {
+    return false;
+  }
+
+  if (left.has_resource_provider_id() != right.has_resource_provider_id()) {
+    return false;
+  }
+
+  if (left.has_resource_provider_id() &&
+      left.resource_provider_id() != right.resource_provider_id()) {
+    return false;
+  }
+
   return true;
 }
 
diff --git a/src/internal/devolve.cpp b/src/internal/devolve.cpp
index a5d9ab9..3df04dc 100644
--- a/src/internal/devolve.cpp
+++ b/src/internal/devolve.cpp
@@ -106,7 +106,13 @@ Offer devolve(const v1::Offer& offer)
 
 OperationStatus devolve(const v1::OperationStatus& status)
 {
-  return devolve<OperationStatus>(status);
+  OperationStatus _status = devolve<OperationStatus>(status);
+
+  if (status.has_agent_id()) {
+    *_status.mutable_slave_id() = devolve<SlaveID>(status.agent_id());
+  }
+
+  return _status;
 }
 
 
diff --git a/src/internal/evolve.cpp b/src/internal/evolve.cpp
index 5ef5838..defda32 100644
--- a/src/internal/evolve.cpp
+++ b/src/internal/evolve.cpp
@@ -160,7 +160,13 @@ v1::OfferID evolve(const OfferID& offerId)
 
 v1::OperationStatus evolve(const OperationStatus& status)
 {
-  return evolve<v1::OperationStatus>(status);
+  v1::OperationStatus _status = evolve<v1::OperationStatus>(status);
+
+  if (status.has_slave_id()) {
+    *_status.mutable_agent_id() = evolve<v1::AgentID>(status.slave_id());
+  }
+
+  return _status;
 }