You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2017/01/17 21:16:10 UTC

[1/2] mesos git commit: Added Capabilities to SlaveInfo protobuf message.

Repository: mesos
Updated Branches:
  refs/heads/master 92595f4f1 -> 4099daa87


Added Capabilities to SlaveInfo protobuf message.

Frameworks can advertise their capabilities via the protobuf field
in FrameworkInfo and master can behave differently according them.
Similarly, agents should be able to advertise their capabilities in
a mixed cluster, so that master could make better decisions based
on them. For example, multi-role frameworks could only launch tasks
on agents with multi-role capabilities.

This allows us to handle upgrades in a more explicit manner, without
having to rely on version strings.

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


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

Branch: refs/heads/master
Commit: ec1a326397641af74b7349182159c07d360a4d73
Parents: 92595f4
Author: Jay Guo <gu...@gmail.com>
Authored: Tue Jan 17 13:14:36 2017 -0800
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Tue Jan 17 13:14:36 2017 -0800

----------------------------------------------------------------------
 include/mesos/mesos.proto    | 25 +++++++++++++++++++++++++
 include/mesos/v1/mesos.proto | 25 +++++++++++++++++++++++++
 2 files changed, 50 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/ec1a3263/include/mesos/mesos.proto
----------------------------------------------------------------------
diff --git a/include/mesos/mesos.proto b/include/mesos/mesos.proto
index ab68ff8..8f14444 100644
--- a/include/mesos/mesos.proto
+++ b/include/mesos/mesos.proto
@@ -697,6 +697,31 @@ message SlaveInfo {
   // TODO(joerg84): Remove checkpoint field after deprecation cycle starting
   // with 0.27 (MESOS-2317).
   optional bool checkpoint = 7 [default = false];
+
+  message Capability {
+    enum Type {
+      // This must be the first enum value in this list, to
+      // ensure that if 'type' is not set, the default value
+      // is UNKNOWN. This enables enum values to be added
+      // in a backwards-compatible way. See: MESOS-4997.
+      UNKNOWN = 0;
+
+      // This expresses the ability for the agent to be able
+      // to launch tasks of a 'multi-role' framework.
+      //
+      // NOTE: The implementation for supporting multiple
+      // roles is not complete, DO NOT USE THIS.
+      MULTI_ROLE = 1; // EXPERIMENTAL.
+    }
+
+    // Enum fields should be optional, see: MESOS-4997.
+    optional Type type = 1;
+  }
+
+  // This field allows an agent to advertise its set of
+  // capabilities (e.g., ability to launch tasks of 'multi-role'
+  // frameworks).
+  repeated Capability capabilities = 9;
 }
 
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/ec1a3263/include/mesos/v1/mesos.proto
----------------------------------------------------------------------
diff --git a/include/mesos/v1/mesos.proto b/include/mesos/v1/mesos.proto
index caefa23..74e7851 100644
--- a/include/mesos/v1/mesos.proto
+++ b/include/mesos/v1/mesos.proto
@@ -691,6 +691,31 @@ message AgentInfo {
   repeated Resource resources = 3;
   repeated Attribute attributes = 5;
   optional AgentID id = 6;
+
+  message Capability {
+    enum Type {
+      // This must be the first enum value in this list, to
+      // ensure that if 'type' is not set, the default value
+      // is UNKNOWN. This enables enum values to be added
+      // in a backwards-compatible way. See: MESOS-4997.
+      UNKNOWN = 0;
+
+      // This expresses the ability for the agent to be able
+      // to launch tasks of a 'multi-role' framework.
+      //
+      // NOTE: The implementation for supporting multiple
+      // roles is not complete, DO NOT USE THIS.
+      MULTI_ROLE = 1; // EXPERIMENTAL.
+    }
+
+    // Enum fields should be optional, see: MESOS-4997.
+    optional Type type = 1;
+  }
+
+  // This field allows an agent to advertise its set of
+  // capabilities (e.g., ability to launch tasks of 'multi-role'
+  // frameworks).
+  repeated Capability capabilities = 9;
 }
 
 


[2/2] mesos git commit: Added capabilities to the master's Slave struct.

Posted by bm...@apache.org.
Added capabilities to the master's Slave struct.

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


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

Branch: refs/heads/master
Commit: 4099daa87b9751d2917656e56dad2e416acc8a02
Parents: ec1a326
Author: Jay Guo <gu...@gmail.com>
Authored: Tue Jan 17 13:15:47 2017 -0800
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Tue Jan 17 13:15:47 2017 -0800

----------------------------------------------------------------------
 src/common/protobuf_utils.hpp      | 23 +++++++++++++++++++++++
 src/master/master.hpp              |  6 +++++-
 src/tests/protobuf_utils_tests.cpp | 16 ++++++++++++++++
 3 files changed, 44 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/4099daa8/src/common/protobuf_utils.hpp
----------------------------------------------------------------------
diff --git a/src/common/protobuf_utils.hpp b/src/common/protobuf_utils.hpp
index 9dee91a..bca9ace 100644
--- a/src/common/protobuf_utils.hpp
+++ b/src/common/protobuf_utils.hpp
@@ -121,6 +121,29 @@ FileInfo createFileInfo(const std::string& path, const struct stat& s);
 
 namespace slave {
 
+struct Capabilities
+{
+  Capabilities() = default;
+
+  template <typename Iterable>
+  Capabilities(const Iterable& capabilities)
+  {
+    foreach (const SlaveInfo::Capability& capability, capabilities) {
+      switch (capability.type()) {
+        case SlaveInfo::Capability::UNKNOWN:
+          break;
+        case SlaveInfo::Capability::MULTI_ROLE:
+          multiRole = true;
+          break;
+      }
+    }
+  }
+
+  // See mesos.proto for the meaning of agent capabilities.
+  bool multiRole = false;
+};
+
+
 mesos::slave::ContainerLimitation createContainerLimitation(
     const Resources& resources,
     const std::string& message,

http://git-wip-us.apache.org/repos/asf/mesos/blob/4099daa8/src/master/master.hpp
----------------------------------------------------------------------
diff --git a/src/master/master.hpp b/src/master/master.hpp
index 44f4fec..8e8a903 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -132,7 +132,8 @@ struct Slave
       connected(true),
       active(true),
       checkpointedResources(_checkpointedResources),
-      observer(nullptr)
+      observer(nullptr),
+      capabilities(_info.capabilities())
   {
     CHECK(_info.has_id());
 
@@ -366,6 +367,9 @@ struct Slave
 
   SlaveObserver* observer;
 
+  // Agent capabilities.
+  protobuf::slave::Capabilities capabilities;
+
 private:
   Slave(const Slave&);              // No copying.
   Slave& operator=(const Slave&); // No assigning.

http://git-wip-us.apache.org/repos/asf/mesos/blob/4099daa8/src/tests/protobuf_utils_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/protobuf_utils_tests.cpp b/src/tests/protobuf_utils_tests.cpp
index 6940b66..bc2a3d0 100644
--- a/src/tests/protobuf_utils_tests.cpp
+++ b/src/tests/protobuf_utils_tests.cpp
@@ -137,6 +137,22 @@ TEST(ProtobufUtilTest, FrameworkCapabilities)
   EXPECT_EQ(expected, backAndForth(expected));
 }
 
+
+// This tests that Capabilities are correctly constructed
+// from given SlaveInfo Capabilities.
+TEST(ProtobufUtilTest, AgentCapabilities)
+{
+  // TODO(jay_guo): consider applying the same test style in
+  // FrameworkCapabilities when we have more capabilities in agent.
+  SlaveInfo slaveInfo;
+  slaveInfo.add_capabilities()->set_type(SlaveInfo::Capability::MULTI_ROLE);
+
+  protobuf::slave::Capabilities capabilities =
+    protobuf::slave::Capabilities(slaveInfo.capabilities());
+
+  ASSERT_TRUE(capabilities.multiRole);
+}
+
 } // namespace tests {
 } // namespace internal {
 } // namespace mesos {