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/10/09 21:45:17 UTC

[1/3] mesos git commit: Added first class profile for disk resources.

Repository: mesos
Updated Branches:
  refs/heads/master ef01fa6c9 -> d79dd983e


Added first class profile for disk resources.

This is similar to storage classes. Instead of adding a bunch of
storage backend specific parameters (e.g., rotational, type, speed,
etc.) into the disk resources, and asking the frameworks to make
scheduling decisions based on those vendor specific parameters. We
propose to use a level of indirection here.

The operator will setup mappings between a profile name to a set of
vendor specific disk parameters. The framework will do disk selection
based on profile names.

The storage resource provider will provide a hook allowing operators
to customize the profile name assignment for disk resources.

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


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

Branch: refs/heads/master
Commit: d79dd983e484bfe5690d34b53716e2c97f1d288e
Parents: 5207985
Author: Jie Yu <yu...@gmail.com>
Authored: Fri Oct 6 14:04:23 2017 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Mon Oct 9 14:45:05 2017 -0700

----------------------------------------------------------------------
 include/mesos/mesos.proto     |  8 ++++++++
 include/mesos/v1/mesos.proto  |  8 ++++++++
 src/common/resources.cpp      |  8 ++++++++
 src/tests/mesos.hpp           | 34 ++++++++++++++++++++++++++++++----
 src/tests/resources_tests.cpp | 19 ++++++++++++++-----
 src/v1/resources.cpp          |  8 ++++++++
 6 files changed, 76 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/d79dd983/include/mesos/mesos.proto
----------------------------------------------------------------------
diff --git a/include/mesos/mesos.proto b/include/mesos/mesos.proto
index 1bfcc5b..830985a 100644
--- a/include/mesos/mesos.proto
+++ b/include/mesos/mesos.proto
@@ -1343,6 +1343,14 @@ message Resource {
 
       optional string id = 4; // EXPERIMENTAL.
       optional Labels metadata = 5; // EXPERIMENTAL.
+
+      // This field serves as an indirection to a set of storage
+      // vendor specific disk parameters which describe the properties
+      // of the disk. The operator will setup mappings between a
+      // profile name to a set of vendor specific disk parameters. And
+      // the framework will do disk selection based on profile names,
+      // instead of vendor specific disk parameters.
+      optional string profile = 6; // EXPERIMENTAL.
     }
 
     optional Source source = 3;

http://git-wip-us.apache.org/repos/asf/mesos/blob/d79dd983/include/mesos/v1/mesos.proto
----------------------------------------------------------------------
diff --git a/include/mesos/v1/mesos.proto b/include/mesos/v1/mesos.proto
index d742adb..a6d662f 100644
--- a/include/mesos/v1/mesos.proto
+++ b/include/mesos/v1/mesos.proto
@@ -1326,6 +1326,14 @@ message Resource {
 
       optional string id = 4; // EXPERIMENTAL.
       optional Labels metadata = 5; // EXPERIMENTAL.
+
+      // This field serves as an indirection to a set of storage
+      // vendor specific disk parameters which describe the properties
+      // of the disk. The operator will setup mappings between a
+      // profile name to a set of vendor specific disk parameters. And
+      // the framework will do disk selection based on profile names,
+      // instead of vendor specific disk parameters.
+      optional string profile = 6; // EXPERIMENTAL.
     }
 
     optional Source source = 3;

http://git-wip-us.apache.org/repos/asf/mesos/blob/d79dd983/src/common/resources.cpp
----------------------------------------------------------------------
diff --git a/src/common/resources.cpp b/src/common/resources.cpp
index 07fa56a..7ee4dae 100644
--- a/src/common/resources.cpp
+++ b/src/common/resources.cpp
@@ -206,6 +206,14 @@ bool operator==(
     return false;
   }
 
+  if (left.has_profile() != right.has_profile()) {
+    return false;
+  }
+
+  if (left.has_profile() && left.profile() != right.profile()) {
+    return false;
+  }
+
   return true;
 }
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/d79dd983/src/tests/mesos.hpp
----------------------------------------------------------------------
diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp
index b0749db..24d220e 100644
--- a/src/tests/mesos.hpp
+++ b/src/tests/mesos.hpp
@@ -941,12 +941,25 @@ inline typename TResource::DiskInfo createDiskInfo(
 // Helper for creating a disk source with type `PATH`.
 template <typename TResource>
 inline typename TResource::DiskInfo::Source createDiskSourcePath(
-    const std::string& root)
+    const Option<std::string>& root,
+    const Option<std::string>& id = None(),
+    const Option<std::string>& profile = None())
 {
   typename TResource::DiskInfo::Source source;
 
   source.set_type(TResource::DiskInfo::Source::PATH);
-  source.mutable_path()->set_root(root);
+
+  if (root.isSome()) {
+    source.mutable_path()->set_root(root.get());
+  }
+
+  if (id.isSome()) {
+    source.set_id(id.get());
+  }
+
+  if (profile.isSome()) {
+    source.set_profile(profile.get());
+  }
 
   return source;
 }
@@ -955,12 +968,25 @@ inline typename TResource::DiskInfo::Source createDiskSourcePath(
 // Helper for creating a disk source with type `MOUNT`.
 template <typename TResource>
 inline typename TResource::DiskInfo::Source createDiskSourceMount(
-    const std::string& root)
+    const Option<std::string>& root,
+    const Option<std::string>& id = None(),
+    const Option<std::string>& profile = None())
 {
   typename TResource::DiskInfo::Source source;
 
   source.set_type(TResource::DiskInfo::Source::MOUNT);
-  source.mutable_mount()->set_root(root);
+
+  if (root.isSome()) {
+    source.mutable_mount()->set_root(root.get());
+  }
+
+  if (id.isSome()) {
+    source.set_id(id.get());
+  }
+
+  if (profile.isSome()) {
+    source.set_profile(profile.get());
+  }
 
   return source;
 }

http://git-wip-us.apache.org/repos/asf/mesos/blob/d79dd983/src/tests/resources_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/resources_tests.cpp b/src/tests/resources_tests.cpp
index 7f0150f..64bde85 100644
--- a/src/tests/resources_tests.cpp
+++ b/src/tests/resources_tests.cpp
@@ -2250,12 +2250,14 @@ TEST(DiskResourcesTest, DiskSourceEquals)
 
 class DiskResourcesSourceTest
   : public ::testing::Test,
-    public ::testing::WithParamInterface<
-        std::tr1::tuple<Resource::DiskInfo::Source::Type, bool>> {};
+    public ::testing::WithParamInterface<std::tr1::tuple<
+        Resource::DiskInfo::Source::Type,
+        bool,
+        bool>> {};
 
 
 INSTANTIATE_TEST_CASE_P(
-    TypeAndIdentity,
+    TypeIdentityProfile,
     DiskResourcesSourceTest,
     ::testing::Combine(
         // We test all source types.
@@ -2266,16 +2268,19 @@ INSTANTIATE_TEST_CASE_P(
             Resource::DiskInfo::Source::MOUNT),
         // We test the case where the source has identity (i.e., has
         // an `id` set) and where not.
+        ::testing::Bool(),
+        // We test the case where the source has profile (i.e., has
+        // an `profile` set) and where not.
         ::testing::Bool()));
 
 
 TEST_P(DiskResourcesSourceTest, SourceIdentity)
 {
-  const std::tr1::tuple<Resource::DiskInfo::Source::Type, bool>& parameters =
-    GetParam();
+  auto parameters = GetParam();
 
   Resource::DiskInfo::Source::Type type = std::tr1::get<0>(parameters);
   bool hasIdentity = std::tr1::get<1>(parameters);
+  bool hasProfile = std::tr1::get<2>(parameters);
 
   // Create a disk, possibly with an id to signify identiy.
   Resource::DiskInfo::Source source;
@@ -2285,6 +2290,10 @@ TEST_P(DiskResourcesSourceTest, SourceIdentity)
     source.set_id("id");
   }
 
+  if (hasProfile) {
+    source.set_profile("profile");
+  }
+
   // Create two disk resources with the created source.
   Resource disk1 = Resources::parse("disk", "1", "*").get();
   disk1.mutable_disk()->mutable_source()->CopyFrom(source);

http://git-wip-us.apache.org/repos/asf/mesos/blob/d79dd983/src/v1/resources.cpp
----------------------------------------------------------------------
diff --git a/src/v1/resources.cpp b/src/v1/resources.cpp
index 04df4d4..5c0a196 100644
--- a/src/v1/resources.cpp
+++ b/src/v1/resources.cpp
@@ -206,6 +206,14 @@ bool operator==(
     return false;
   }
 
+  if (left.has_profile() != right.has_profile()) {
+    return false;
+  }
+
+  if (left.has_profile() && left.profile() != right.profile()) {
+    return false;
+  }
+
   return true;
 }
 


[2/3] mesos git commit: Fixed 'operator==' for 'v1::Resource::DiskInfo::Source'.

Posted by ji...@apache.org.
Fixed 'operator==' for 'v1::Resource::DiskInfo::Source'.

When implementing 'operator==' for protobufs as a pattern we typically
first check that two 'optional' fields are set for both the left- and
right-hand side, and only then compare their values, e.g., given a
definition

    message Foo {
      optional string bar = 1;
    }

we would implement 'operator==' similar to the following,

   bool operator==(const Foo& lhs, const Foo& rhs)
   {
       if (lhs.has_bar() != rhs.has_bar()) {
         return false;
       }

       if (lhs.has_bar() && lhs.bar() != rhs.bar()) {
         return false;
       }

       return true;
   }

One reason for this is that it allows us to distinguish an unset field
from a set field containing a default constructed value (if e.g.,
above 'lhs.has_bar()' was 'false', 'lhs.bar()' would return an empty
string).

This patch makes sure we use the same pattern when checking
'v1::Resource::DiskInfo::Source' for equality. An earlier patch
('591f74d') already fixed this for 'Resources::DiskInfo::Source'.

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


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

Branch: refs/heads/master
Commit: 5207985400a9135f85f9340bd679cc7d12ebec4d
Parents: 07f8da2
Author: Benjamin Bannier <bb...@apache.org>
Authored: Mon Oct 9 14:30:39 2017 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Mon Oct 9 14:45:05 2017 -0700

----------------------------------------------------------------------
 src/v1/resources.cpp | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/52079854/src/v1/resources.cpp
----------------------------------------------------------------------
diff --git a/src/v1/resources.cpp b/src/v1/resources.cpp
index a64180b..04df4d4 100644
--- a/src/v1/resources.cpp
+++ b/src/v1/resources.cpp
@@ -174,18 +174,34 @@ bool operator==(
     return false;
   }
 
+  if (left.has_path() != right.has_path()) {
+    return false;
+  }
+
   if (left.has_path() && left.path() != right.path()) {
     return false;
   }
 
+  if (left.has_mount() != right.has_mount()) {
+    return false;
+  }
+
   if (left.has_mount() && left.mount() != right.mount()) {
     return false;
   }
 
+  if (left.has_id() != right.has_id()) {
+    return false;
+  }
+
   if (left.has_id() && left.id() != right.id()) {
     return false;
   }
 
+  if (left.has_metadata() != right.has_metadata()) {
+    return false;
+  }
+
   if (left.has_metadata() && left.metadata() != right.metadata()) {
     return false;
   }


[3/3] mesos git commit: Removed a redundant equality check for Mount disk source.

Posted by ji...@apache.org.
Removed a redundant equality check for Mount disk source.

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


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

Branch: refs/heads/master
Commit: 07f8da23c3f85193e00ab6f3d618ea5e3cdd54be
Parents: ef01fa6
Author: Jie Yu <yu...@gmail.com>
Authored: Fri Oct 6 13:57:49 2017 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Mon Oct 9 14:45:05 2017 -0700

----------------------------------------------------------------------
 src/common/resources.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/07f8da23/src/common/resources.cpp
----------------------------------------------------------------------
diff --git a/src/common/resources.cpp b/src/common/resources.cpp
index ea0f3a2..07fa56a 100644
--- a/src/common/resources.cpp
+++ b/src/common/resources.cpp
@@ -146,7 +146,7 @@ bool operator==(
     return false;
   }
 
-  return left.root() == right.root();
+  return true;
 }