You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2017/11/30 00:04:17 UTC

[06/13] mesos git commit: Added default reservations in `ResourceProviderInfo`.

Added default reservations in `ResourceProviderInfo`.

The `default_reservations` field is used to set up the default
reservation stack for new resources from the resource provider.

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


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

Branch: refs/heads/master
Commit: c0a4988c676014999ff027401d8d8bcf396ace90
Parents: 6216cde
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
Authored: Wed Nov 29 15:30:54 2017 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed Nov 29 15:30:54 2017 -0800

----------------------------------------------------------------------
 include/mesos/mesos.proto      | 13 ++++++++++++-
 include/mesos/resources.hpp    | 11 +++++++++++
 include/mesos/v1/mesos.proto   | 13 ++++++++++++-
 include/mesos/v1/resources.hpp | 11 +++++++++++
 src/common/type_utils.cpp      | 11 +++++++++++
 src/v1/mesos.cpp               | 11 +++++++++++
 6 files changed, 68 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/c0a4988c/include/mesos/mesos.proto
----------------------------------------------------------------------
diff --git a/include/mesos/mesos.proto b/include/mesos/mesos.proto
index 25a9082..11089b7 100644
--- a/include/mesos/mesos.proto
+++ b/include/mesos/mesos.proto
@@ -1071,7 +1071,18 @@ message ResourceProviderInfo {
   // to avoid conflicts on concatenation of type and name.
   required string name = 4;
 
-  optional CSIPluginInfo storage = 5; // EXPERIMENTAL.
+  // The stack of default reservations. If this field is not empty, it
+  // indicates that resources from this resource provider are reserved
+  // by default, except for the resources that have been reserved or
+  // unreserved through offer operations. The first `ReservationInfo`
+  // may have type `STATIC` or `DYNAMIC`, but the rest must have
+  // `DYNAMIC`. One can create a new reservation on top of an existing
+  // one by pushing a new `ReservationInfo` to the back. The last
+  // `ReservationInfo` in this stack is the "current" reservation. The
+  // new reservation's role must be a child of the current one.
+  repeated Resource.ReservationInfo default_reservations = 5; // EXPERIMENTAL.
+
+  optional CSIPluginInfo storage = 6; // EXPERIMENTAL.
 }
 
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/c0a4988c/include/mesos/resources.hpp
----------------------------------------------------------------------
diff --git a/include/mesos/resources.hpp b/include/mesos/resources.hpp
index 08c544d..eefe9ea 100644
--- a/include/mesos/resources.hpp
+++ b/include/mesos/resources.hpp
@@ -58,6 +58,17 @@ namespace mesos {
 class ResourceConversion;
 
 
+// Helper functions.
+bool operator==(
+    const Resource::ReservationInfo& left,
+    const Resource::ReservationInfo& right);
+
+
+bool operator!=(
+    const Resource::ReservationInfo& left,
+    const Resource::ReservationInfo& right);
+
+
 // NOTE: Resource objects stored in the class are always valid, are in
 // the "post-reservation-refinement" format, and kept combined if possible.
 // It is the caller's responsibility to validate any Resource object or

http://git-wip-us.apache.org/repos/asf/mesos/blob/c0a4988c/include/mesos/v1/mesos.proto
----------------------------------------------------------------------
diff --git a/include/mesos/v1/mesos.proto b/include/mesos/v1/mesos.proto
index ddb5add..c496da9 100644
--- a/include/mesos/v1/mesos.proto
+++ b/include/mesos/v1/mesos.proto
@@ -1063,7 +1063,18 @@ message ResourceProviderInfo {
   // to avoid conflicts on concatenation of type and name.
   required string name = 4;
 
-  optional CSIPluginInfo storage = 5; // EXPERIMENTAL.
+  // The stack of default reservations. If this field is not empty, it
+  // indicates that resources from this resource provider are reserved
+  // by default, except for the resources that have been reserved or
+  // unreserved through offer operations. The first `ReservationInfo`
+  // may have type `STATIC` or `DYNAMIC`, but the rest must have
+  // `DYNAMIC`. One can create a new reservation on top of an existing
+  // one by pushing a new `ReservationInfo` to the back. The last
+  // `ReservationInfo` in this stack is the "current" reservation. The
+  // new reservation's role must be a child of the current one.
+  repeated Resource.ReservationInfo default_reservations = 5; // EXPERIMENTAL.
+
+  optional CSIPluginInfo storage = 6; // EXPERIMENTAL.
 }
 
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/c0a4988c/include/mesos/v1/resources.hpp
----------------------------------------------------------------------
diff --git a/include/mesos/v1/resources.hpp b/include/mesos/v1/resources.hpp
index d59fa35..7a5b0e3 100644
--- a/include/mesos/v1/resources.hpp
+++ b/include/mesos/v1/resources.hpp
@@ -58,6 +58,17 @@ namespace v1 {
 class ResourceConversion;
 
 
+// Helper functions.
+bool operator==(
+    const Resource::ReservationInfo& left,
+    const Resource::ReservationInfo& right);
+
+
+bool operator!=(
+    const Resource::ReservationInfo& left,
+    const Resource::ReservationInfo& right);
+
+
 // NOTE: Resource objects stored in the class are always valid, are in
 // the "post-reservation-refinement" format, and kept combined if possible.
 // It is the caller's responsibility to validate any Resource object or

http://git-wip-us.apache.org/repos/asf/mesos/blob/c0a4988c/src/common/type_utils.cpp
----------------------------------------------------------------------
diff --git a/src/common/type_utils.cpp b/src/common/type_utils.cpp
index 3bff49e..3657d55 100644
--- a/src/common/type_utils.cpp
+++ b/src/common/type_utils.cpp
@@ -404,6 +404,17 @@ bool operator==(
     const ResourceProviderInfo& left,
     const ResourceProviderInfo& right)
 {
+  // Order of reservations is important.
+  if (left.default_reservations_size() != right.default_reservations_size()) {
+    return false;
+  }
+
+  for (int i = 0; i < left.default_reservations_size(); i++) {
+    if (left.default_reservations(i) != right.default_reservations(i)) {
+      return false;
+    }
+  }
+
   return left.has_id() == right.has_id() &&
     (!left.has_id() || left.id() == right.id()) &&
     Attributes(left.attributes()) == Attributes(right.attributes()) &&

http://git-wip-us.apache.org/repos/asf/mesos/blob/c0a4988c/src/v1/mesos.cpp
----------------------------------------------------------------------
diff --git a/src/v1/mesos.cpp b/src/v1/mesos.cpp
index 243b1cd..15eb848 100644
--- a/src/v1/mesos.cpp
+++ b/src/v1/mesos.cpp
@@ -398,6 +398,17 @@ bool operator==(
     const ResourceProviderInfo& left,
     const ResourceProviderInfo& right)
 {
+  // Order of reservations is important.
+  if (left.default_reservations_size() != right.default_reservations_size()) {
+    return false;
+  }
+
+  for (int i = 0; i < left.default_reservations_size(); i++) {
+    if (left.default_reservations(i) != right.default_reservations(i)) {
+      return false;
+    }
+  }
+
   return left.has_id() == right.has_id() &&
     (!left.has_id() || left.id() == right.id()) &&
     Attributes(left.attributes()) == Attributes(right.attributes()) &&