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/07/13 21:41:19 UTC

[14/17] mesos git commit: Made disk type checks in SLRP hard assertions.

Made disk type checks in SLRP hard assertions.

Since the disk types of the `CREATE_DISK` and `DESTROY_DISK` should have
been validated by the master, we now use `CHECK`s instead of returning
failures.

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


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

Branch: refs/heads/master
Commit: 039f0c22300c9c982c23e4085d8229982af9a12a
Parents: 9b1850e
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
Authored: Wed Jul 11 20:05:47 2018 -0700
Committer: Chun-Hung Hsiao <ch...@mesosphere.io>
Committed: Fri Jul 13 14:30:07 2018 -0700

----------------------------------------------------------------------
 src/resource_provider/storage/provider.cpp | 23 +++--------------------
 1 file changed, 3 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/039f0c22/src/resource_provider/storage/provider.cpp
----------------------------------------------------------------------
diff --git a/src/resource_provider/storage/provider.cpp b/src/resource_provider/storage/provider.cpp
index 59b1d47..22c184f 100644
--- a/src/resource_provider/storage/provider.cpp
+++ b/src/resource_provider/storage/provider.cpp
@@ -3044,11 +3044,7 @@ StorageLocalResourceProviderProcess::applyCreateDisk(
     const id::UUID& operationUuid,
     const Resource::DiskInfo::Source::Type& type)
 {
-  if (resource.disk().source().type() != Resource::DiskInfo::Source::RAW) {
-    return Failure(
-        "Cannot create volume or block from source of " +
-        stringify(resource.disk().source().type()) + " type");
-  }
+  CHECK_EQ(Resource::DiskInfo::Source::RAW, resource.disk().source().type());
 
   // NOTE: Currently we only support two type of RAW disk resources:
   //   1. RAW disk from `GetCapacity` with a profile but no volume ID.
@@ -3219,21 +3215,8 @@ Future<vector<ResourceConversion>>
 StorageLocalResourceProviderProcess::applyDestroyDisk(
     const Resource& resource)
 {
-  switch (resource.disk().source().type()) {
-    case Resource::DiskInfo::Source::MOUNT:
-    case Resource::DiskInfo::Source::BLOCK: {
-      break;
-    }
-    case Resource::DiskInfo::Source::UNKNOWN:
-    case Resource::DiskInfo::Source::PATH:
-    case Resource::DiskInfo::Source::RAW: {
-      return Failure(
-          "Cannot destroy volume or block of " +
-          stringify(resource.disk().source().type()) + " type");
-      break;
-    }
-  }
-
+  CHECK(resource.disk().source().type() == Resource::DiskInfo::Source::MOUNT ||
+        resource.disk().source().type() == Resource::DiskInfo::Source::BLOCK);
   CHECK(resource.disk().source().has_id());
   CHECK(volumes.contains(resource.disk().source().id()));