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/05/04 01:18:25 UTC

[02/13] mesos git commit: Added offer operation to grow and shrink persistent volumes.

Added offer operation to grow and shrink persistent volumes.

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


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

Branch: refs/heads/master
Commit: 7d88e06cb9752c55aa0c80f0989c58e05ee495f9
Parents: 57e705a
Author: Zhitao Li <zh...@gmail.com>
Authored: Thu May 3 17:04:11 2018 -0700
Committer: Chun-Hung Hsiao <ch...@mesosphere.io>
Committed: Thu May 3 17:04:11 2018 -0700

----------------------------------------------------------------------
 include/mesos/mesos.proto                  | 22 ++++++++++++++++++++++
 include/mesos/v1/mesos.proto               | 22 ++++++++++++++++++++++
 src/common/protobuf_utils.cpp              | 19 +++++++++++++++++++
 src/common/resources_utils.cpp             | 13 +++++++++++++
 src/master/master.cpp                      | 23 +++++++++++++++++++++++
 src/resource_provider/storage/provider.cpp |  6 ++++++
 src/tests/mesos.hpp                        |  6 ++++++
 src/tests/persistent_volume_tests.cpp      |  2 ++
 src/tests/reservation_tests.cpp            |  2 ++
 9 files changed, 115 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/7d88e06c/include/mesos/mesos.proto
----------------------------------------------------------------------
diff --git a/include/mesos/mesos.proto b/include/mesos/mesos.proto
index a61de9d..9930bea 100644
--- a/include/mesos/mesos.proto
+++ b/include/mesos/mesos.proto
@@ -1923,6 +1923,8 @@ message Offer {
       DESTROY_VOLUME = 8; // EXPERIMENTAL.
       CREATE_BLOCK = 9;   // EXPERIMENTAL.
       DESTROY_BLOCK = 10; // EXPERIMENTAL.
+      GROW_VOLUME = 11;   // EXPERIMENTAL.
+      SHRINK_VOLUME = 12; // EXPERIMENTAL.
     }
 
     // TODO(vinod): Deprecate this in favor of `LaunchGroup` below.
@@ -1959,6 +1961,24 @@ message Offer {
       repeated Resource volumes = 1;
     }
 
+    // Grow a volume by an additional disk resource.
+    // NOTE: This is currently experimental and only for persistent volumes
+    // created on ROOT/PATH disk.
+    message GrowVolume {
+      required Resource volume = 1;
+      required Resource addition = 2;
+    }
+
+    // Shrink a volume by the size specified in the `subtract` field.
+    // NOTE: This is currently experimental and only for persistent volumes
+    // created on ROOT/PATH disk.
+    message ShrinkVolume {
+      required Resource volume = 1;
+
+      // See comments in `Value.Scalar` for maximum precision supported.
+      required Value.Scalar subtract = 2;
+    }
+
     // NOTE: For the time being, this API is subject to change and the related
     // feature is experimental.
     message CreateVolume {
@@ -1997,6 +2017,8 @@ message Offer {
     optional Unreserve unreserve = 4;
     optional Create create = 5;
     optional Destroy destroy = 6;
+    optional GrowVolume grow_volume = 13; // EXPERIMENTAL.
+    optional ShrinkVolume shrink_volume = 14; // EXPERIMENTAL.
     optional CreateVolume create_volume = 8;
     optional DestroyVolume destroy_volume = 9;
     optional CreateBlock create_block = 10;

http://git-wip-us.apache.org/repos/asf/mesos/blob/7d88e06c/include/mesos/v1/mesos.proto
----------------------------------------------------------------------
diff --git a/include/mesos/v1/mesos.proto b/include/mesos/v1/mesos.proto
index 317d9ef..4101243 100644
--- a/include/mesos/v1/mesos.proto
+++ b/include/mesos/v1/mesos.proto
@@ -1915,6 +1915,8 @@ message Offer {
       DESTROY_VOLUME = 8; // EXPERIMENTAL.
       CREATE_BLOCK = 9;   // EXPERIMENTAL.
       DESTROY_BLOCK = 10; // EXPERIMENTAL.
+      GROW_VOLUME = 11;   // EXPERIMENTAL.
+      SHRINK_VOLUME = 12; // EXPERIMENTAL.
     }
 
     // TODO(vinod): Deprecate this in favor of `LaunchGroup` below.
@@ -1951,6 +1953,24 @@ message Offer {
       repeated Resource volumes = 1;
     }
 
+    // Grow a volume by an additional disk resource.
+    // NOTE: This is currently experimental and only for persistent volumes
+    // created on ROOT/PATH disk.
+    message GrowVolume {
+      required Resource volume = 1;
+      required Resource addition = 2;
+    }
+
+    // Shrink a volume by the size specified in the `subtract` field.
+    // NOTE: This is currently experimental and only for persistent volumes
+    // created on ROOT/PATH disk.
+    message ShrinkVolume {
+      required Resource volume = 1;
+
+      // See comments in `Value.Scalar` for maximum precision supported.
+      required Value.Scalar subtract = 2;
+    }
+
     // NOTE: For the time being, this API is subject to change and the related
     // feature is experimental.
     message CreateVolume {
@@ -1989,6 +2009,8 @@ message Offer {
     optional Unreserve unreserve = 4;
     optional Create create = 5;
     optional Destroy destroy = 6;
+    optional GrowVolume grow_volume = 13; // EXPERIMENTAL.
+    optional ShrinkVolume shrink_volume = 14; // EXPERIMENTAL.
     optional CreateVolume create_volume = 8;
     optional DestroyVolume destroy_volume = 9;
     optional CreateBlock create_block = 10;

http://git-wip-us.apache.org/repos/asf/mesos/blob/7d88e06c/src/common/protobuf_utils.cpp
----------------------------------------------------------------------
diff --git a/src/common/protobuf_utils.cpp b/src/common/protobuf_utils.cpp
index 78bffd8..2e675c4 100644
--- a/src/common/protobuf_utils.cpp
+++ b/src/common/protobuf_utils.cpp
@@ -37,6 +37,7 @@
 #include <stout/foreach.hpp>
 #include <stout/net.hpp>
 #include <stout/stringify.hpp>
+#include <stout/unimplemented.hpp>
 #include <stout/unreachable.hpp>
 #include <stout/uuid.hpp>
 
@@ -707,6 +708,11 @@ void injectAllocationInfo(
       break;
     }
 
+    case Offer::Operation::GROW_VOLUME:
+    case Offer::Operation::SHRINK_VOLUME: {
+      UNIMPLEMENTED;
+    }
+
     case Offer::Operation::CREATE_VOLUME: {
       inject(
           *operation->mutable_create_volume()->mutable_source(),
@@ -822,6 +828,11 @@ void stripAllocationInfo(Offer::Operation* operation)
       break;
     }
 
+    case Offer::Operation::GROW_VOLUME:
+    case Offer::Operation::SHRINK_VOLUME: {
+      UNIMPLEMENTED;
+    }
+
     case Offer::Operation::CREATE_VOLUME: {
       strip(*operation->mutable_create_volume()->mutable_source());
 
@@ -867,6 +878,10 @@ bool isSpeculativeOperation(const Offer::Operation& operation)
     case Offer::Operation::CREATE:
     case Offer::Operation::DESTROY:
       return true;
+    case Offer::Operation::GROW_VOLUME:
+    case Offer::Operation::SHRINK_VOLUME: {
+      UNIMPLEMENTED;
+    }
     case Offer::Operation::UNKNOWN:
       UNREACHABLE();
   }
@@ -1020,6 +1035,10 @@ Try<Resources> getConsumedResources(const Offer::Operation& operation)
 
       return consumed;
     }
+    case Offer::Operation::GROW_VOLUME:
+    case Offer::Operation::SHRINK_VOLUME: {
+      UNIMPLEMENTED;
+    }
     case Offer::Operation::LAUNCH:
     case Offer::Operation::LAUNCH_GROUP:
       // TODO(bbannier): Consider adding support for 'LAUNCH' and

http://git-wip-us.apache.org/repos/asf/mesos/blob/7d88e06c/src/common/resources_utils.cpp
----------------------------------------------------------------------
diff --git a/src/common/resources_utils.cpp b/src/common/resources_utils.cpp
index 9be01c1..6f56026 100644
--- a/src/common/resources_utils.cpp
+++ b/src/common/resources_utils.cpp
@@ -16,6 +16,7 @@
 
 #include <stout/foreach.hpp>
 #include <stout/stringify.hpp>
+#include <stout/unimplemented.hpp>
 
 #include "common/resources_utils.hpp"
 
@@ -195,6 +196,10 @@ Try<vector<TResourceConversion>> getResourceConversions(
       }
       break;
     }
+    case TOperation::GROW_VOLUME:
+    case TOperation::SHRINK_VOLUME: {
+      UNIMPLEMENTED;
+    }
   }
 
   return conversions;
@@ -259,6 +264,10 @@ Result<ResourceProviderID> getResourceProviderId(
       }
       resource = operation.destroy().volumes(0);
       break;
+    case Offer::Operation::GROW_VOLUME:
+    case Offer::Operation::SHRINK_VOLUME: {
+      UNIMPLEMENTED;
+    }
     case Offer::Operation::CREATE_VOLUME:
       resource = operation.create_volume().source();
       break;
@@ -631,6 +640,10 @@ Option<Error> validateAndUpgradeResources(Offer::Operation* operation)
 
       break;
     }
+    case Offer::Operation::GROW_VOLUME:
+    case Offer::Operation::SHRINK_VOLUME: {
+      UNIMPLEMENTED;
+    }
     case Offer::Operation::LAUNCH: {
       // TODO(mpark): Once we perform a sanity check validation for
       // offer operations as specified in MESOS-7760, this should no

http://git-wip-us.apache.org/repos/asf/mesos/blob/7d88e06c/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index c723a29..56cf61f 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -69,6 +69,7 @@
 #include <stout/option.hpp>
 #include <stout/path.hpp>
 #include <stout/stringify.hpp>
+#include <stout/unimplemented.hpp>
 #include <stout/unreachable.hpp>
 #include <stout/utils.hpp>
 #include <stout/uuid.hpp>
@@ -4132,6 +4133,10 @@ void Master::accept(
 
             break;
           }
+          case Offer::Operation::GROW_VOLUME:
+          case Offer::Operation::SHRINK_VOLUME: {
+            UNIMPLEMENTED;
+          }
           case Offer::Operation::UNKNOWN: {
             LOG(WARNING) << "Ignoring unknown operation";
             break;
@@ -4203,6 +4208,10 @@ void Master::accept(
             accept.add_operations()->CopyFrom(operation);
             break;
           }
+          case Offer::Operation::GROW_VOLUME:
+          case Offer::Operation::SHRINK_VOLUME: {
+            UNIMPLEMENTED;
+          }
           case Offer::Operation::UNKNOWN: {
             LOG(WARNING) << "Ignoring unknown operation";
             break;
@@ -4239,6 +4248,10 @@ void Master::accept(
         // No-op.
         break;
       }
+      case Offer::Operation::GROW_VOLUME:
+      case Offer::Operation::SHRINK_VOLUME: {
+        UNIMPLEMENTED;
+      }
       case Offer::Operation::LAUNCH: {
         foreach (
             TaskInfo& task, *operation.mutable_launch()->mutable_task_infos()) {
@@ -4403,6 +4416,11 @@ void Master::accept(
         break;
       }
 
+      case Offer::Operation::GROW_VOLUME:
+      case Offer::Operation::SHRINK_VOLUME: {
+        UNIMPLEMENTED;
+      }
+
       case Offer::Operation::CREATE_VOLUME: {
         // TODO(nfnt): Implement authorization for 'CREATE_VOLUME'.
         break;
@@ -4884,6 +4902,11 @@ void Master::_accept(
         break;
       }
 
+      case Offer::Operation::GROW_VOLUME:
+      case Offer::Operation::SHRINK_VOLUME: {
+        UNIMPLEMENTED;
+      }
+
       case Offer::Operation::LAUNCH: {
         foreach (const TaskInfo& task, operation.launch().task_infos()) {
           Future<bool> authorization = authorizations.front();

http://git-wip-us.apache.org/repos/asf/mesos/blob/7d88e06c/src/resource_provider/storage/provider.cpp
----------------------------------------------------------------------
diff --git a/src/resource_provider/storage/provider.cpp b/src/resource_provider/storage/provider.cpp
index d1267cf..eb35780 100644
--- a/src/resource_provider/storage/provider.cpp
+++ b/src/resource_provider/storage/provider.cpp
@@ -2845,6 +2845,12 @@ Future<Nothing> StorageLocalResourceProviderProcess::_applyOperation(
 
       break;
     }
+    case Offer::Operation::GROW_VOLUME:
+    case Offer::Operation::SHRINK_VOLUME: {
+      // TODO(chhsiao): These operations are currently not supported for
+      // resource providers, and should have been validated by the master.
+      UNREACHABLE();
+    }
     case Offer::Operation::UNKNOWN:
     case Offer::Operation::LAUNCH:
     case Offer::Operation::LAUNCH_GROUP: {

http://git-wip-us.apache.org/repos/asf/mesos/blob/7d88e06c/src/tests/mesos.hpp
----------------------------------------------------------------------
diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp
index 756a521..907bca5 100644
--- a/src/tests/mesos.hpp
+++ b/src/tests/mesos.hpp
@@ -3126,6 +3126,12 @@ public:
         break;
       case Operation::DESTROY:
         break;
+      // TODO(zhitao): Implement default operation for `GROW_VOLUME` and
+      // `SHRINK_VOLUME` on mocked resource provider.
+      case Operation::GROW_VOLUME:
+        break;
+      case Operation::SHRINK_VOLUME:
+        break;
       case Operation::CREATE_VOLUME:
         update->mutable_status()->add_converted_resources()->CopyFrom(
             operation.info().create_volume().source());

http://git-wip-us.apache.org/repos/asf/mesos/blob/7d88e06c/src/tests/persistent_volume_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/persistent_volume_tests.cpp b/src/tests/persistent_volume_tests.cpp
index 4edf781..c3de96e 100644
--- a/src/tests/persistent_volume_tests.cpp
+++ b/src/tests/persistent_volume_tests.cpp
@@ -176,6 +176,8 @@ protected:
           case Offer::Operation::DESTROY_VOLUME:
           case Offer::Operation::CREATE_BLOCK:
           case Offer::Operation::DESTROY_BLOCK:
+          case Offer::Operation::GROW_VOLUME:
+          case Offer::Operation::SHRINK_VOLUME:
             UNREACHABLE();
           case Offer::Operation::CREATE: {
             Resources resources = message.operation_info().create().volumes();

http://git-wip-us.apache.org/repos/asf/mesos/blob/7d88e06c/src/tests/reservation_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/reservation_tests.cpp b/src/tests/reservation_tests.cpp
index 5570df2..7d121bf 100644
--- a/src/tests/reservation_tests.cpp
+++ b/src/tests/reservation_tests.cpp
@@ -95,6 +95,8 @@ public:
           case Offer::Operation::DESTROY_VOLUME:
           case Offer::Operation::CREATE_BLOCK:
           case Offer::Operation::DESTROY_BLOCK:
+          case Offer::Operation::GROW_VOLUME:
+          case Offer::Operation::SHRINK_VOLUME:
             UNREACHABLE();
           case Offer::Operation::RESERVE: {
             Resources resources =