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

mesos git commit: Added `HIERARCHICAL_ROLE` agent capability.

Repository: mesos
Updated Branches:
  refs/heads/master 13cae29e7 -> a8f7ded4c


Added `HIERARCHICAL_ROLE` agent capability.

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


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

Branch: refs/heads/master
Commit: a8f7ded4c8d53fcc6e252c9d1e9455633798b3e3
Parents: 13cae29
Author: Michael Park <mp...@apache.org>
Authored: Wed May 3 18:45:13 2017 -0700
Committer: Michael Park <mp...@apache.org>
Committed: Tue Jun 13 17:08:11 2017 -0700

----------------------------------------------------------------------
 include/mesos/mesos.proto     |  9 +++++++++
 include/mesos/v1/mesos.proto  |  9 +++++++++
 src/common/protobuf_utils.cpp |  3 ++-
 src/common/protobuf_utils.hpp |  7 +++++++
 src/slave/constants.cpp       | 17 +++++++++++++----
 src/tests/master_tests.cpp    |  7 +++++--
 src/tests/slave_tests.cpp     |  7 +++++--
 src/tests/upgrade_tests.cpp   | 16 ++++++++--------
 8 files changed, 58 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/a8f7ded4/include/mesos/mesos.proto
----------------------------------------------------------------------
diff --git a/include/mesos/mesos.proto b/include/mesos/mesos.proto
index 31972b0..e9a8b15 100644
--- a/include/mesos/mesos.proto
+++ b/include/mesos/mesos.proto
@@ -805,6 +805,15 @@ message SlaveInfo {
       // This expresses the ability for the agent to be able
       // to launch tasks of a 'multi-role' framework.
       MULTI_ROLE = 1;
+
+      // This expresses the ability for the agent to be able to launch
+      // tasks, reserve resources, and create volumes using resources
+      // allocated to a 'hierarchical-role'.
+      // NOTE: This capability is required specifically for creating
+      // volumes because a hierchical role includes '/' (slashes) in them.
+      // Agents with this capability know to transform the '/' (slashes)
+      // into ' ' (spaces).
+      HIERARCHICAL_ROLE = 2;
     }
 
     // Enum fields should be optional, see: MESOS-4997.

http://git-wip-us.apache.org/repos/asf/mesos/blob/a8f7ded4/include/mesos/v1/mesos.proto
----------------------------------------------------------------------
diff --git a/include/mesos/v1/mesos.proto b/include/mesos/v1/mesos.proto
index cabe0d5..5e8c15c 100644
--- a/include/mesos/v1/mesos.proto
+++ b/include/mesos/v1/mesos.proto
@@ -799,6 +799,15 @@ message AgentInfo {
       // This expresses the ability for the agent to be able
       // to launch tasks of a 'multi-role' framework.
       MULTI_ROLE = 1;
+
+      // This expresses the ability for the agent to be able to launch
+      // tasks, reserve resources, and create volumes using resources
+      // allocated to a 'hierarchical-role'.
+      // NOTE: This capability is required specifically for creating
+      // volumes because a hierchical role includes '/' (slashes) in them.
+      // Agents with this capability know to transform the '/' (slashes)
+      // into ' ' (spaces).
+      HIERARCHICAL_ROLE = 2;
     }
 
     // Enum fields should be optional, see: MESOS-4997.

http://git-wip-us.apache.org/repos/asf/mesos/blob/a8f7ded4/src/common/protobuf_utils.cpp
----------------------------------------------------------------------
diff --git a/src/common/protobuf_utils.cpp b/src/common/protobuf_utils.cpp
index 3fcaf78..46331b3 100644
--- a/src/common/protobuf_utils.cpp
+++ b/src/common/protobuf_utils.cpp
@@ -656,7 +656,8 @@ bool operator==(const Capabilities& left, const Capabilities& right)
   // TODO(bmahler): Use reflection-based equality to avoid breaking
   // as new capabilities are added. Note that it needs to be set-based
   // equality.
-  return left.multiRole == right.multiRole;
+  return left.multiRole == right.multiRole &&
+         left.hierarchicalRole == right.hierarchicalRole;
 }
 
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/a8f7ded4/src/common/protobuf_utils.hpp
----------------------------------------------------------------------
diff --git a/src/common/protobuf_utils.hpp b/src/common/protobuf_utils.hpp
index be2325f..7b1a128 100644
--- a/src/common/protobuf_utils.hpp
+++ b/src/common/protobuf_utils.hpp
@@ -197,6 +197,9 @@ struct Capabilities
         case SlaveInfo::Capability::MULTI_ROLE:
           multiRole = true;
           break;
+        case SlaveInfo::Capability::HIERARCHICAL_ROLE:
+          hierarchicalRole = true;
+          break;
         // If adding another case here be sure to update the
         // equality operator.
       }
@@ -205,6 +208,7 @@ struct Capabilities
 
   // See mesos.proto for the meaning of agent capabilities.
   bool multiRole = false;
+  bool hierarchicalRole = false;
 
   google::protobuf::RepeatedPtrField<SlaveInfo::Capability>
   toRepeatedPtrField() const
@@ -213,6 +217,9 @@ struct Capabilities
     if (multiRole) {
       result.Add()->set_type(SlaveInfo::Capability::MULTI_ROLE);
     }
+    if (hierarchicalRole) {
+      result.Add()->set_type(SlaveInfo::Capability::HIERARCHICAL_ROLE);
+    }
 
     return result;
   }

http://git-wip-us.apache.org/repos/asf/mesos/blob/a8f7ded4/src/slave/constants.cpp
----------------------------------------------------------------------
diff --git a/src/slave/constants.cpp b/src/slave/constants.cpp
index 0fbcab8..d3668e4 100644
--- a/src/slave/constants.cpp
+++ b/src/slave/constants.cpp
@@ -35,10 +35,19 @@ Duration DEFAULT_MASTER_PING_TIMEOUT()
 
 vector<SlaveInfo::Capability> AGENT_CAPABILITIES()
 {
-  SlaveInfo::Capability multiRoleCapability;
-  multiRoleCapability.set_type(SlaveInfo::Capability::MULTI_ROLE);
-
-  return {multiRoleCapability};
+  SlaveInfo::Capability::Type types[] = {
+    SlaveInfo::Capability::MULTI_ROLE,
+    SlaveInfo::Capability::HIERARCHICAL_ROLE
+  };
+
+  vector<SlaveInfo::Capability> result;
+  foreach (SlaveInfo::Capability::Type type, types) {
+    SlaveInfo::Capability capability;
+    capability.set_type(type);
+    result.push_back(capability);
+  }
+
+  return result;
 }
 
 } // namespace slave {

http://git-wip-us.apache.org/repos/asf/mesos/blob/a8f7ded4/src/tests/master_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/master_tests.cpp b/src/tests/master_tests.cpp
index 490d7ed..543c4a3 100644
--- a/src/tests/master_tests.cpp
+++ b/src/tests/master_tests.cpp
@@ -4284,8 +4284,11 @@ TEST_F(MasterTest, StateEndpointAgentCapabilities)
   ASSERT_EQ(1u, slaveInfo.values.count("capabilities"));
   JSON::Value slaveCapabilities = slaveInfo.values.at("capabilities");
 
-  // Agents should always have MULTI_ROLE capability in current implementation.
-  Try<JSON::Value> expectedCapabilities = JSON::parse("[\"MULTI_ROLE\"]");
+  // Agents should always have MULTI_ROLE and HIERARCHICAL_ROLE capabilities
+  // in current implementation.
+  Try<JSON::Value> expectedCapabilities =
+    JSON::parse("[\"MULTI_ROLE\",\"HIERARCHICAL_ROLE\"]");
+
   ASSERT_SOME(expectedCapabilities);
   EXPECT_TRUE(slaveCapabilities.contains(expectedCapabilities.get()));
 }

http://git-wip-us.apache.org/repos/asf/mesos/blob/a8f7ded4/src/tests/slave_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/slave_tests.cpp b/src/tests/slave_tests.cpp
index 6aa5d9b..26901f4 100644
--- a/src/tests/slave_tests.cpp
+++ b/src/tests/slave_tests.cpp
@@ -1540,8 +1540,11 @@ TEST_F(SlaveTest, StateEndpoint)
   EXPECT_FALSE(state.values["capabilities"].as<JSON::Array>().values.empty());
   JSON::Value slaveCapabilities = state.values.at("capabilities");
 
-  // Agents should always have MULTI_ROLE capability in current implementation.
-  Try<JSON::Value> expectedCapabilities = JSON::parse("[\"MULTI_ROLE\"]");
+  // Agents should always have MULTI_ROLE and HIERARCHICAL_ROLE capabilities
+  // in current implementation.
+  Try<JSON::Value> expectedCapabilities =
+    JSON::parse("[\"MULTI_ROLE\",\"HIERARCHICAL_ROLE\"]");
+
   ASSERT_SOME(expectedCapabilities);
   EXPECT_TRUE(slaveCapabilities.contains(expectedCapabilities.get()));
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/a8f7ded4/src/tests/upgrade_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/upgrade_tests.cpp b/src/tests/upgrade_tests.cpp
index b07426f..1474754 100644
--- a/src/tests/upgrade_tests.cpp
+++ b/src/tests/upgrade_tests.cpp
@@ -189,10 +189,10 @@ TEST_F(UpgradeTest, ReregisterOldAgentWithMultiRoleMaster)
 
   AWAIT_READY(reregisterSlaveMessage);
 
-  EXPECT_EQ(1u, reregisterSlaveMessage->agent_capabilities_size());
-  EXPECT_EQ(
-      SlaveInfo::Capability::MULTI_ROLE,
-      reregisterSlaveMessage->agent_capabilities(0).type());
+  protobuf::slave::Capabilities capabilities(
+      reregisterSlaveMessage->agent_capabilities());
+
+  EXPECT_TRUE(capabilities.multiRole);
 
   // Strip allocation_info and MULTI_ROLE capability.
   ReregisterSlaveMessage strippedReregisterSlaveMessage =
@@ -309,10 +309,10 @@ TEST_F(UpgradeTest, UpgradeSlaveIntoMultiRole)
 
   AWAIT_READY(registerSlaveMessage);
 
-  EXPECT_EQ(1u, registerSlaveMessage->agent_capabilities_size());
-  EXPECT_EQ(
-      SlaveInfo::Capability::MULTI_ROLE,
-      registerSlaveMessage->agent_capabilities(0).type());
+  protobuf::slave::Capabilities capabilities(
+      registerSlaveMessage->agent_capabilities());
+
+  EXPECT_TRUE(capabilities.multiRole);
 
   // Strip MULTI_ROLE capability.
   RegisterSlaveMessage strippedRegisterSlaveMessage =