Added ResourceVersion to RunTask and RunTaskGroup messages.

This commit adds the known agent resource versions to RunTaskMessage
and RunTaskGroupMessage. We also update sites where the message is
unpacked.

In a later commit we will inject versions in the master and evaluate
them in the agent.

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


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

Branch: refs/heads/master
Commit: ac97d764e55eb26484f3aad8ff8ac9730e6555b2
Parents: c78496f
Author: Benjamin Bannier <[email protected]>
Authored: Thu Nov 30 12:19:45 2017 +0100
Committer: Benjamin Bannier <[email protected]>
Committed: Fri Dec 8 11:07:44 2017 +0100

----------------------------------------------------------------------
 src/messages/messages.proto | 26 ++++++++++++++++++++++++++
 src/slave/slave.cpp         | 23 +++++++++++++++++------
 src/slave/slave.hpp         |  7 +++++--
 src/tests/mock_slave.cpp    | 26 ++++++++++++++++++++------
 src/tests/mock_slave.hpp    | 17 +++++++++++------
 src/tests/slave_tests.cpp   |  6 +++---
 6 files changed, 82 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/ac97d764/src/messages/messages.proto
----------------------------------------------------------------------
diff --git a/src/messages/messages.proto b/src/messages/messages.proto
index 44b45d5..f711784 100644
--- a/src/messages/messages.proto
+++ b/src/messages/messages.proto
@@ -306,6 +306,19 @@ message RunTaskMessage {
   required FrameworkInfo framework = 2;
   required TaskInfo task = 4;
 
+  // Used to establish the relationship between the operation and the
+  // resources that the operation is operating on. Each resource
+  // provider will keep a resource version UUID, and change it when
+  // it believes that the resources from this resource provider are
+  // out of sync from the master's view.  The master will keep track
+  // of the last known resource version UUID for each resource
+  // provider, and attach the resource version UUID in each operation
+  // it sends out. The resource provider should reject operations that
+  // have a different resource version UUID than that it maintains,
+  // because this means the operation is operating on resources that
+  // might have already been invalidated.
+  repeated ResourceVersionUUID resource_version_uuids = 5;
+
   // The pid of the framework. This was moved to 'optional' in
   // 0.24.0 to support schedulers using the HTTP API. For now, we
   // continue to always set pid since it was required in 0.23.x.
@@ -328,6 +341,19 @@ message RunTaskGroupMessage {
   required FrameworkInfo framework = 1;
   required ExecutorInfo executor = 2;
   required TaskGroupInfo task_group = 3;
+
+  // Used to establish the relationship between the operation and the
+  // resources that the operation is operating on. Each resource
+  // provider will keep a resource version UUID, and change it when
+  // it believes that the resources from this resource provider are
+  // out of sync from the master's view.  The master will keep track
+  // of the last known resource version UUID for each resource
+  // provider, and attach the resource version UUID in each operation
+  // it sends out. The resource provider should reject operations that
+  // have a different resource version UUID than that it maintains,
+  // because this means the operation is operating on resources that
+  // might have already been invalidated.
+  repeated ResourceVersionUUID resource_version_uuids = 4;
 }
 
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/ac97d764/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index 98370f9..8bdb945 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -654,13 +654,15 @@ void Slave::initialize()
       &RunTaskMessage::framework,
       &RunTaskMessage::framework_id,
       &RunTaskMessage::pid,
-      &RunTaskMessage::task);
+      &RunTaskMessage::task,
+      &RunTaskMessage::resource_version_uuids);
 
   install<RunTaskGroupMessage>(
       &Slave::runTaskGroup,
       &RunTaskGroupMessage::framework,
       &RunTaskGroupMessage::executor,
-      &RunTaskGroupMessage::task_group);
+      &RunTaskGroupMessage::task_group,
+      &RunTaskGroupMessage::resource_version_uuids);
 
   install<KillTaskMessage>(
       &Slave::killTask);
@@ -1763,7 +1765,8 @@ void Slave::runTask(
     const FrameworkInfo& frameworkInfo,
     const FrameworkID& frameworkId,
     const UPID& pid,
-    const TaskInfo& task)
+    const TaskInfo& task,
+    const vector<ResourceVersionUUID>& resourceVersionUuids)
 {
   CHECK_NE(task.has_executor(), task.has_command())
     << "Task " << task.task_id()
@@ -1784,7 +1787,7 @@ void Slave::runTask(
 
   const ExecutorInfo executorInfo = getExecutorInfo(frameworkInfo, task);
 
-  run(frameworkInfo, executorInfo, task, None(), pid);
+  run(frameworkInfo, executorInfo, task, None(), resourceVersionUuids, pid);
 }
 
 
@@ -1793,6 +1796,7 @@ void Slave::run(
     ExecutorInfo executorInfo,
     Option<TaskInfo> task,
     Option<TaskGroupInfo> taskGroup,
+    const vector<ResourceVersionUUID>& resourceVersionUuids,
     const UPID& pid)
 {
   CHECK_NE(task.isSome(), taskGroup.isSome())
@@ -3037,7 +3041,8 @@ void Slave::runTaskGroup(
     const UPID& from,
     const FrameworkInfo& frameworkInfo,
     const ExecutorInfo& executorInfo,
-    const TaskGroupInfo& taskGroupInfo)
+    const TaskGroupInfo& taskGroupInfo,
+    const vector<ResourceVersionUUID>& resourceVersionUuids)
 {
   if (master != from) {
     LOG(WARNING) << "Ignoring run task group message from " << from
@@ -3059,7 +3064,13 @@ void Slave::runTaskGroup(
     return;
   }
 
-  run(frameworkInfo, executorInfo, None(), taskGroupInfo, UPID());
+  run(
+      frameworkInfo,
+      executorInfo,
+      None(),
+      taskGroupInfo,
+      resourceVersionUuids,
+      UPID());
 }
 
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/ac97d764/src/slave/slave.hpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp
index d9b0469..a47f93e 100644
--- a/src/slave/slave.hpp
+++ b/src/slave/slave.hpp
@@ -148,13 +148,15 @@ public:
       const FrameworkInfo& frameworkInfo,
       const FrameworkID& frameworkId,
       const process::UPID& pid,
-      const TaskInfo& task);
+      const TaskInfo& task,
+      const std::vector<ResourceVersionUUID>& resourceVersionUuids);
 
   void run(
       const FrameworkInfo& frameworkInfo,
       ExecutorInfo executorInfo,
       Option<TaskInfo> task,
       Option<TaskGroupInfo> taskGroup,
+      const std::vector<ResourceVersionUUID>& resourceVersionUuids,
       const process::UPID& pid);
 
   // Made 'virtual' for Slave mocking.
@@ -170,7 +172,8 @@ public:
       const process::UPID& from,
       const FrameworkInfo& frameworkInfo,
       const ExecutorInfo& executorInfo,
-      const TaskGroupInfo& taskGroupInfo);
+      const TaskGroupInfo& taskGroupInfo,
+      const std::vector<ResourceVersionUUID>& resourceVersionUuids);
 
   // Made 'virtual' for Slave mocking.
   virtual void killTask(

http://git-wip-us.apache.org/repos/asf/mesos/blob/ac97d764/src/tests/mock_slave.cpp
----------------------------------------------------------------------
diff --git a/src/tests/mock_slave.cpp b/src/tests/mock_slave.cpp
index 6d050ca..a43a12f 100644
--- a/src/tests/mock_slave.cpp
+++ b/src/tests/mock_slave.cpp
@@ -45,6 +45,7 @@ using mesos::slave::QoSController;
 
 using std::list;
 using std::string;
+using std::vector;
 
 using process::Future;
 using process::UPID;
@@ -117,11 +118,11 @@ MockSlave::MockSlave(
         authorizer)
 {
   // Set up default behaviors, calling the original methods.
-  EXPECT_CALL(*this, runTask(_, _, _, _, _))
+  EXPECT_CALL(*this, runTask(_, _, _, _, _, _))
     .WillRepeatedly(Invoke(this, &MockSlave::unmocked_runTask));
   EXPECT_CALL(*this, _run(_, _, _, _, _))
     .WillRepeatedly(Invoke(this, &MockSlave::unmocked__run));
-  EXPECT_CALL(*this, runTaskGroup(_, _, _, _))
+  EXPECT_CALL(*this, runTaskGroup(_, _, _, _, _))
     .WillRepeatedly(Invoke(this, &MockSlave::unmocked_runTaskGroup));
   EXPECT_CALL(*this, killTask(_, _))
     .WillRepeatedly(Invoke(this, &MockSlave::unmocked_killTask));
@@ -145,9 +146,16 @@ void MockSlave::unmocked_runTask(
     const FrameworkInfo& frameworkInfo,
     const FrameworkID& frameworkId,
     const UPID& pid,
-    const TaskInfo& task)
+    const TaskInfo& task,
+    const vector<ResourceVersionUUID>& resourceVersionUuids)
 {
-  slave::Slave::runTask(from, frameworkInfo, frameworkInfo.id(), pid, task);
+  slave::Slave::runTask(
+      from,
+      frameworkInfo,
+      frameworkInfo.id(),
+      pid,
+      task,
+      resourceVersionUuids);
 }
 
 
@@ -167,9 +175,15 @@ void MockSlave::unmocked_runTaskGroup(
     const UPID& from,
     const FrameworkInfo& frameworkInfo,
     const ExecutorInfo& executorInfo,
-    const TaskGroupInfo& taskGroup)
+    const TaskGroupInfo& taskGroup,
+    const vector<ResourceVersionUUID>& resourceVersionUuids)
 {
-  slave::Slave::runTaskGroup(from, frameworkInfo, executorInfo, taskGroup);
+  slave::Slave::runTaskGroup(
+      from,
+      frameworkInfo,
+      executorInfo,
+      taskGroup,
+      resourceVersionUuids);
 }
 
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/ac97d764/src/tests/mock_slave.hpp
----------------------------------------------------------------------
diff --git a/src/tests/mock_slave.hpp b/src/tests/mock_slave.hpp
index d986125..cf5a581 100644
--- a/src/tests/mock_slave.hpp
+++ b/src/tests/mock_slave.hpp
@@ -19,6 +19,7 @@
 
 #include <list>
 #include <string>
+#include <vector>
 
 #include <gmock/gmock.h>
 
@@ -100,19 +101,21 @@ public:
       SecretGenerator* secretGenerator,
       const Option<Authorizer*>& authorizer);
 
-  MOCK_METHOD5(runTask, void(
+  MOCK_METHOD6(runTask, void(
       const process::UPID& from,
       const FrameworkInfo& frameworkInfo,
       const FrameworkID& frameworkId,
       const process::UPID& pid,
-      const TaskInfo& task));
+      const TaskInfo& task,
+      const std::vector<ResourceVersionUUID>& resourceVersionUuids));
 
   void unmocked_runTask(
       const process::UPID& from,
       const FrameworkInfo& frameworkInfo,
       const FrameworkID& frameworkId,
       const process::UPID& pid,
-      const TaskInfo& task);
+      const TaskInfo& task,
+      const std::vector<ResourceVersionUUID>& resourceVersionUuids);
 
   MOCK_METHOD5(_run, void(
       const process::Future<std::list<bool>>& unschedules,
@@ -128,17 +131,19 @@ public:
       const Option<TaskInfo>& task,
       const Option<TaskGroupInfo>& taskGroup);
 
-  MOCK_METHOD4(runTaskGroup, void(
+  MOCK_METHOD5(runTaskGroup, void(
       const process::UPID& from,
       const FrameworkInfo& frameworkInfo,
       const ExecutorInfo& executorInfo,
-      const TaskGroupInfo& taskGroup));
+      const TaskGroupInfo& taskGroup,
+      const std::vector<ResourceVersionUUID>& resourceVersionUuids));
 
   void unmocked_runTaskGroup(
       const process::UPID& from,
       const FrameworkInfo& frameworkInfo,
       const ExecutorInfo& executorInfo,
-      const TaskGroupInfo& taskGroup);
+      const TaskGroupInfo& taskGroup,
+      const std::vector<ResourceVersionUUID>& resourceVersionUuids);
 
   MOCK_METHOD2(killTask, void(
       const process::UPID& from,

http://git-wip-us.apache.org/repos/asf/mesos/blob/ac97d764/src/tests/slave_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/slave_tests.cpp b/src/tests/slave_tests.cpp
index ee490a0..29ab216 100644
--- a/src/tests/slave_tests.cpp
+++ b/src/tests/slave_tests.cpp
@@ -4109,7 +4109,7 @@ TEST_F(SlaveTest, KillTaskBetweenRunTaskParts)
   EXPECT_CALL(sched, statusUpdate(&driver, _))
     .WillRepeatedly(FutureArg<1>(&status));
 
-  EXPECT_CALL(*slave.get()->mock(), runTask(_, _, _, _, _))
+  EXPECT_CALL(*slave.get()->mock(), runTask(_, _, _, _, _, _))
     .WillOnce(Invoke(slave.get()->mock(), &MockSlave::unmocked_runTask));
 
   // Saved arguments from Slave::_run().
@@ -4227,7 +4227,7 @@ TEST_F(SlaveTest, KillMultiplePendingTasks)
     .WillOnce(FutureArg<1>(&status1))
     .WillOnce(FutureArg<1>(&status2));
 
-  EXPECT_CALL(*slave.get()->mock(), runTask(_, _, _, _, _))
+  EXPECT_CALL(*slave.get()->mock(), runTask(_, _, _, _, _, _))
     .WillOnce(Invoke(slave.get()->mock(), &MockSlave::unmocked_runTask))
     .WillOnce(Invoke(slave.get()->mock(), &MockSlave::unmocked_runTask));
 
@@ -7166,7 +7166,7 @@ TEST_F(SlaveTest, KillTaskGroupBetweenRunTaskParts)
     .WillOnce(FutureArg<1>(&update2))
     .WillRepeatedly(Return());
 
-  EXPECT_CALL(*slave.get()->mock(), runTaskGroup(_, _, _, _))
+  EXPECT_CALL(*slave.get()->mock(), runTaskGroup(_, _, _, _, _))
     .WillOnce(Invoke(slave.get()->mock(),
                      &MockSlave::unmocked_runTaskGroup));
 

Reply via email to