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/26 20:16:44 UTC

[1/4] mesos git commit: Moved agent capabilities from SlaveInfo to (re-)registerSlaveMessage.

Repository: mesos
Updated Branches:
  refs/heads/master 5fc7bd5cc -> b54cdcd95


Moved agent capabilities from SlaveInfo to (re-)registerSlaveMessage.

We want agents to be able to upgrade to support new capabilities after
reregistration, however we don't support udpating SlaveInfo yet. This
patch moves agent capabilities protobuf message from SlaveInfo to the
(re-)registerSlaveMessage so that capabilities are communicated through
the agent registration and re-registration.

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


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

Branch: refs/heads/master
Commit: 2ff8f0129996e79ba07e19fbbc7b8472a2bde448
Parents: a66bd87
Author: Jay Guo <gu...@gmail.com>
Authored: Thu Jan 26 11:55:34 2017 -0800
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Thu Jan 26 12:01:01 2017 -0800

----------------------------------------------------------------------
 include/mesos/mesos.proto    |  5 -----
 include/mesos/v1/mesos.proto |  5 -----
 src/messages/messages.proto  | 10 ++++++++++
 3 files changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/2ff8f012/include/mesos/mesos.proto
----------------------------------------------------------------------
diff --git a/include/mesos/mesos.proto b/include/mesos/mesos.proto
index 044b7e6..37a97f6 100644
--- a/include/mesos/mesos.proto
+++ b/include/mesos/mesos.proto
@@ -792,11 +792,6 @@ message SlaveInfo {
     // 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/2ff8f012/include/mesos/v1/mesos.proto
----------------------------------------------------------------------
diff --git a/include/mesos/v1/mesos.proto b/include/mesos/v1/mesos.proto
index 7706de8..31563b7 100644
--- a/include/mesos/v1/mesos.proto
+++ b/include/mesos/v1/mesos.proto
@@ -786,11 +786,6 @@ message AgentInfo {
     // 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/2ff8f012/src/messages/messages.proto
----------------------------------------------------------------------
diff --git a/src/messages/messages.proto b/src/messages/messages.proto
index 7cbac56..7a2f37b 100644
--- a/src/messages/messages.proto
+++ b/src/messages/messages.proto
@@ -427,6 +427,11 @@ message RegisterSlaveMessage {
   // version. If unset the agent is < 0.21.0.
   // TODO(bmahler): Do proper versioning: MESOS-986.
   optional string version = 2;
+
+  // This field allows an agent to advertise its set of
+  // capabilities (e.g., ability to launch tasks of 'multi-role'
+  // frameworks).
+  repeated SlaveInfo.Capability agent_capabilities = 4;
 }
 
 
@@ -458,6 +463,11 @@ message ReregisterSlaveMessage {
   // version. If unset the agent is < 0.21.0.
   // TODO(bmahler): Do proper versioning: MESOS-986.
   optional string version = 6;
+
+  // This field allows an agent to advertise its set of
+  // capabilities (e.g., ability to launch tasks of 'multi-role'
+  // frameworks).
+  repeated SlaveInfo.Capability agent_capabilities = 9;
 }
 
 


[4/4] mesos git commit: Added agent capabilities as part of agent (re-)registration process.

Posted by bm...@apache.org.
Added agent capabilities as part of agent (re-)registration process.

Agent capabilities are communicated during registration and stored
in `Slave` struct in master. Upon agent reregistration, capabilities
are updated.

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


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

Branch: refs/heads/master
Commit: b54cdcd95a31ed8db767ae8ea7cfb96b72951aae
Parents: 595250d
Author: Jay Guo <gu...@gmail.com>
Authored: Thu Jan 26 12:03:00 2017 -0800
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Thu Jan 26 12:12:15 2017 -0800

----------------------------------------------------------------------
 src/master/master.cpp | 34 ++++++++++++++++++++++++----------
 src/master/master.hpp | 15 ++++++++++-----
 2 files changed, 34 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/b54cdcd9/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 2432ed4..0f2c7cd 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -793,7 +793,8 @@ void Master::initialize()
       &Master::registerSlave,
       &RegisterSlaveMessage::slave,
       &RegisterSlaveMessage::checkpointed_resources,
-      &RegisterSlaveMessage::version);
+      &RegisterSlaveMessage::version,
+      &RegisterSlaveMessage::agent_capabilities);
 
   install<ReregisterSlaveMessage>(
       &Master::reregisterSlave,
@@ -803,7 +804,8 @@ void Master::initialize()
       &ReregisterSlaveMessage::tasks,
       &ReregisterSlaveMessage::frameworks,
       &ReregisterSlaveMessage::completed_frameworks,
-      &ReregisterSlaveMessage::version);
+      &ReregisterSlaveMessage::version,
+      &ReregisterSlaveMessage::agent_capabilities);
 
   install<UnregisterSlaveMessage>(
       &Master::unregisterSlave,
@@ -5199,7 +5201,8 @@ void Master::registerSlave(
     const UPID& from,
     const SlaveInfo& slaveInfo,
     const vector<Resource>& checkpointedResources,
-    const string& version)
+    const string& version,
+    const vector<SlaveInfo::Capability>& agentCapabilities)
 {
   ++metrics->messages_register_slave;
 
@@ -5213,7 +5216,8 @@ void Master::registerSlave(
                      from,
                      slaveInfo,
                      checkpointedResources,
-                     version));
+                     version,
+                     agentCapabilities));
     return;
   }
 
@@ -5306,6 +5310,7 @@ void Master::registerSlave(
                  from,
                  checkpointedResources,
                  version,
+                 agentCapabilities,
                  lambda::_1));
 }
 
@@ -5315,6 +5320,7 @@ void Master::_registerSlave(
     const UPID& pid,
     const vector<Resource>& checkpointedResources,
     const string& version,
+    const vector<SlaveInfo::Capability>& agentCapabilities,
     const Future<bool>& admit)
 {
   CHECK(slaves.registering.contains(pid));
@@ -5350,6 +5356,7 @@ void Master::_registerSlave(
       pid,
       machineId,
       version,
+      agentCapabilities,
       Clock::now(),
       checkpointedResources);
 
@@ -5380,7 +5387,8 @@ void Master::reregisterSlave(
     const vector<Task>& tasks,
     const vector<FrameworkInfo>& frameworks,
     const vector<Archive::Framework>& completedFrameworks,
-    const string& version)
+    const string& version,
+    const vector<SlaveInfo::Capability>& agentCapabilities)
 {
   ++metrics->messages_reregister_slave;
 
@@ -5398,7 +5406,8 @@ void Master::reregisterSlave(
                      tasks,
                      frameworks,
                      completedFrameworks,
-                     version));
+                     version,
+                     agentCapabilities));
     return;
   }
 
@@ -5475,10 +5484,11 @@ void Master::reregisterSlave(
     slave->pid = from;
     link(slave->pid);
 
-    // Update slave's version and re-registration timestamp after
-    // re-registering successfully.
+    // Update slave's version, re-registration timestamp and
+    // agent capabilities after re-registering successfully.
     slave->version = version;
     slave->reregisteredTime = Clock::now();
+    slave->capabilities = agentCapabilities;
 
     // Reconcile tasks between master and slave, and send the
     // `SlaveReregisteredMessage`.
@@ -5541,6 +5551,7 @@ void Master::reregisterSlave(
                  frameworks,
                  completedFrameworks,
                  version,
+                 agentCapabilities,
                  lambda::_1));
 }
 
@@ -5554,6 +5565,7 @@ void Master::_reregisterSlave(
     const vector<FrameworkInfo>& frameworks,
     const vector<Archive::Framework>& completedFrameworks,
     const string& version,
+    const vector<SlaveInfo::Capability>& agentCapabilities,
     const Future<bool>& readmit)
 {
   CHECK(slaves.reregistering.contains(slaveInfo.id()));
@@ -5667,6 +5679,7 @@ void Master::_reregisterSlave(
       pid,
       machineId,
       version,
+      agentCapabilities,
       Clock::now(),
       checkpointedResources,
       executorInfos,
@@ -8806,6 +8819,7 @@ Slave::Slave(
     const UPID& _pid,
     const MachineID& _machineId,
     const string& _version,
+    const vector<SlaveInfo::Capability>& _capabilites,
     const Time& _registeredTime,
     const Resources& _checkpointedResources,
     const vector<ExecutorInfo> executorInfos,
@@ -8816,12 +8830,12 @@ Slave::Slave(
     machineId(_machineId),
     pid(_pid),
     version(_version),
+    capabilities(_capabilites),
     registeredTime(_registeredTime),
     connected(true),
     active(true),
     checkpointedResources(_checkpointedResources),
-    observer(nullptr),
-    capabilities(_info.capabilities())
+    observer(nullptr)
 {
   CHECK(_info.has_id());
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/b54cdcd9/src/master/master.hpp
----------------------------------------------------------------------
diff --git a/src/master/master.hpp b/src/master/master.hpp
index cb1b82d..7e38af4 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -119,6 +119,7 @@ struct Slave
         const process::UPID& _pid,
         const MachineID& _machineId,
         const std::string& _version,
+        const std::vector<SlaveInfo::Capability>& _capabilites,
         const process::Time& _registeredTime,
         const Resources& _checkpointedResources,
         const std::vector<ExecutorInfo> executorInfos =
@@ -177,6 +178,9 @@ struct Slave
   // TODO(bmahler): Use stout's Version when it can parse labels, etc.
   std::string version;
 
+  // Agent capabilities.
+  protobuf::slave::Capabilities capabilities;
+
   process::Time registeredTime;
   Option<process::Time> reregisteredTime;
 
@@ -242,9 +246,6 @@ struct Slave
 
   SlaveObserver* observer;
 
-  // Agent capabilities.
-  protobuf::slave::Capabilities capabilities;
-
 private:
   Slave(const Slave&);              // No copying.
   Slave& operator=(const Slave&); // No assigning.
@@ -379,7 +380,8 @@ public:
       const process::UPID& from,
       const SlaveInfo& slaveInfo,
       const std::vector<Resource>& checkpointedResources,
-      const std::string& version);
+      const std::string& version,
+      const std::vector<SlaveInfo::Capability>& agentCapabilities);
 
   void reregisterSlave(
       const process::UPID& from,
@@ -389,7 +391,8 @@ public:
       const std::vector<Task>& tasks,
       const std::vector<FrameworkInfo>& frameworks,
       const std::vector<Archive::Framework>& completedFrameworks,
-      const std::string& version);
+      const std::string& version,
+      const std::vector<SlaveInfo::Capability>& agentCapabilities);
 
   void unregisterSlave(
       const process::UPID& from,
@@ -504,6 +507,7 @@ protected:
       const process::UPID& pid,
       const std::vector<Resource>& checkpointedResources,
       const std::string& version,
+      const std::vector<SlaveInfo::Capability>& agentCapabilities,
       const process::Future<bool>& admit);
 
   void _reregisterSlave(
@@ -515,6 +519,7 @@ protected:
       const std::vector<FrameworkInfo>& frameworks,
       const std::vector<Archive::Framework>& completedFrameworks,
       const std::string& version,
+      const std::vector<SlaveInfo::Capability>& agentCapabilities,
       const process::Future<bool>& readmit);
 
   void __reregisterSlave(


[3/4] mesos git commit: Updated the protobuf tests to reflect agent capabilities moving.

Posted by bm...@apache.org.
Updated the protobuf tests to reflect agent capabilities moving.

Since the agent capabilities have been moved into the
(re-)registration messages, the test needs to be updated.

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


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

Branch: refs/heads/master
Commit: 595250d29a85c216fc490069d13eb6eabba16f70
Parents: 2ff8f01
Author: Jay Guo <gu...@gmail.com>
Authored: Thu Jan 26 12:06:59 2017 -0800
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Thu Jan 26 12:06:59 2017 -0800

----------------------------------------------------------------------
 src/tests/protobuf_utils_tests.cpp | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/595250d2/src/tests/protobuf_utils_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/protobuf_utils_tests.cpp b/src/tests/protobuf_utils_tests.cpp
index 39604e9..4cf748b 100644
--- a/src/tests/protobuf_utils_tests.cpp
+++ b/src/tests/protobuf_utils_tests.cpp
@@ -138,16 +138,17 @@ TEST(ProtobufUtilTest, FrameworkCapabilities)
 
 
 // This tests that Capabilities are correctly constructed
-// from given SlaveInfo Capabilities.
+// from given Agent 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);
+  RegisterSlaveMessage registerSlaveMessage;
+  registerSlaveMessage.add_agent_capabilities()->set_type(
+      SlaveInfo::Capability::MULTI_ROLE);
 
-  protobuf::slave::Capabilities capabilities =
-    protobuf::slave::Capabilities(slaveInfo.capabilities());
+  protobuf::slave::Capabilities capabilities(
+      registerSlaveMessage.agent_capabilities());
 
   ASSERT_TRUE(capabilities.multiRole);
 }


[2/4] mesos git commit: Added a `install` template method to support 8 arguments.

Posted by bm...@apache.org.
Added a `install` template method to support 8 arguments.

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


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

Branch: refs/heads/master
Commit: a66bd8704b8592289105b751861355fa9b372119
Parents: 5fc7bd5
Author: Jay Guo <gu...@gmail.com>
Authored: Thu Jan 26 12:00:38 2017 -0800
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Thu Jan 26 12:01:01 2017 -0800

----------------------------------------------------------------------
 .../libprocess/include/process/protobuf.hpp     | 74 ++++++++++++++++++++
 1 file changed, 74 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/a66bd870/3rdparty/libprocess/include/process/protobuf.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/protobuf.hpp b/3rdparty/libprocess/include/process/protobuf.hpp
index ad2f232..ba6e6d6 100644
--- a/3rdparty/libprocess/include/process/protobuf.hpp
+++ b/3rdparty/libprocess/include/process/protobuf.hpp
@@ -304,6 +304,38 @@ protected:
     delete m;
   }
 
+  template <typename M,
+            typename P1, typename P1C,
+            typename P2, typename P2C,
+            typename P3, typename P3C,
+            typename P4, typename P4C,
+            typename P5, typename P5C,
+            typename P6, typename P6C,
+            typename P7, typename P7C,
+            typename P8, typename P8C>
+  void install(
+      void (T::*method)(const process::UPID&, P1C, P2C, P3C,
+                                              P4C, P5C, P6C, P7C, P8C),
+      P1 (M::*p1)() const,
+      P2 (M::*p2)() const,
+      P3 (M::*p3)() const,
+      P4 (M::*p4)() const,
+      P5 (M::*p5)() const,
+      P6 (M::*p6)() const,
+      P7 (M::*p7)() const,
+      P8 (M::*p8)() const)
+  {
+    google::protobuf::Message* m = new M();
+    T* t = static_cast<T*>(this);
+    protobufHandlers[m->GetTypeName()] =
+      lambda::bind(&handler8<M, P1, P1C, P2, P2C, P3, P3C,
+                                P4, P4C, P5, P5C, P6, P6C,
+                                P7, P7C, P8, P8C>,
+                   t, method, p1, p2, p3, p4, p5, p6, p7, p8,
+                   lambda::_1, lambda::_2);
+    delete m;
+  }
+
   // Installs that do not take the sender.
   template <typename M>
   void install(void (T::*method)(const M&))
@@ -711,6 +743,48 @@ private:
     }
   }
 
+  template <typename M,
+            typename P1, typename P1C,
+            typename P2, typename P2C,
+            typename P3, typename P3C,
+            typename P4, typename P4C,
+            typename P5, typename P5C,
+            typename P6, typename P6C,
+            typename P7, typename P7C,
+            typename P8, typename P8C>
+  static void handler8(
+      T* t,
+      void (T::*method)(
+          const process::UPID&, P1C, P2C, P3C, P4C, P5C, P6C, P7C, P8C),
+      P1 (M::*p1)() const,
+      P2 (M::*p2)() const,
+      P3 (M::*p3)() const,
+      P4 (M::*p4)() const,
+      P5 (M::*p5)() const,
+      P6 (M::*p6)() const,
+      P7 (M::*p7)() const,
+      P8 (M::*p8)() const,
+      const process::UPID& sender,
+      const std::string& data)
+  {
+    M m;
+    m.ParseFromString(data);
+    if (m.IsInitialized()) {
+      (t->*method)(sender,
+                   google::protobuf::convert((&m->*p1)()),
+                   google::protobuf::convert((&m->*p2)()),
+                   google::protobuf::convert((&m->*p3)()),
+                   google::protobuf::convert((&m->*p4)()),
+                   google::protobuf::convert((&m->*p5)()),
+                   google::protobuf::convert((&m->*p6)()),
+                   google::protobuf::convert((&m->*p7)()),
+                   google::protobuf::convert((&m->*p8)()));
+    } else {
+      LOG(WARNING) << "Initialization errors: "
+                   << m.InitializationErrorString();
+    }
+  }
+
   // Handlers that ignore the sender.
   template <typename M>
   static void _handlerM(