You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2014/07/01 20:02:17 UTC
git commit: Fixed a regression in ExecutorInfoChecker to allow an
executor with the same id but different executor info as long as it is on a
different slave.
Repository: mesos
Updated Branches:
refs/heads/master 093280867 -> dde865e39
Fixed a regression in ExecutorInfoChecker to allow an executor with the same id but different executor info as long as it is on a different slave.
Review: https://reviews.apache.org/r/23187
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/dde865e3
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/dde865e3
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/dde865e3
Branch: refs/heads/master
Commit: dde865e39be9e8c377ab07eda3290277659715ce
Parents: 0932808
Author: Vinod Kone <vi...@gmail.com>
Authored: Mon Jun 30 17:08:38 2014 -0700
Committer: Vinod Kone <vi...@gmail.com>
Committed: Tue Jul 1 11:01:55 2014 -0700
----------------------------------------------------------------------
src/master/master.cpp | 6 +-
src/tests/master_authorization_tests.cpp | 130 ++++++++++++++++++++++++++
src/tests/resource_offers_tests.cpp | 118 ++++++++++++++++++++++-
3 files changed, 250 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/dde865e3/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 474014b..251b699 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -1809,14 +1809,16 @@ struct ExecutorInfoChecker : TaskInfoVisitor
if (slave.hasExecutor(framework.id, executorId)) {
executorInfo = slave.executors.get(framework.id).get().get(executorId);
} else {
- // See if any of the pending tasks have the same executor.
+ // See if any of the pending tasks have the same executor
+ // on the same slave.
// Note that picking the first matching executor is ok because
// all the matching executors have been added to
// 'framework.pendingTasks' after validation and hence have
// the same executor info.
foreachvalue (const TaskInfo& task_, framework.pendingTasks) {
if (task_.has_executor() &&
- task_.executor().executor_id() == executorId) {
+ task_.executor().executor_id() == executorId &&
+ task_.slave_id() == task.slave_id()) {
executorInfo = task_.executor();
break;
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/dde865e3/src/tests/master_authorization_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/master_authorization_tests.cpp b/src/tests/master_authorization_tests.cpp
index 478041c..0fdf464 100644
--- a/src/tests/master_authorization_tests.cpp
+++ b/src/tests/master_authorization_tests.cpp
@@ -601,6 +601,136 @@ TEST_F(MasterAuthorizationTest, ReconcileTask)
}
+// This test verifies that two tasks each launched on a different
+// slave with same executor id but different executor info are
+// allowed even when the first task is pending due to authorization.
+TEST_F(MasterAuthorizationTest, PendingExecutorInfoDiffersOnDifferentSlaves)
+{
+ MockAuthorizer authorizer;
+ Try<PID<Master> > master = StartMaster(&authorizer);
+ ASSERT_SOME(master);
+
+ MockScheduler sched;
+ MesosSchedulerDriver driver(
+ &sched, DEFAULT_FRAMEWORK_INFO, master.get(), DEFAULT_CREDENTIAL);
+
+ Future<Nothing> registered;
+ EXPECT_CALL(sched, registered(&driver, _, _))
+ .WillOnce(FutureSatisfy(®istered));
+
+ driver.start();
+
+ AWAIT_READY(registered);
+
+ Future<vector<Offer> > offers1;
+ EXPECT_CALL(sched, resourceOffers(&driver, _))
+ .WillOnce(FutureArg<1>(&offers1));
+
+ // Start the first slave.
+ MockExecutor exec1(DEFAULT_EXECUTOR_ID);
+
+ Try<PID<Slave> > slave1 = StartSlave(&exec1);
+ ASSERT_SOME(slave1);
+
+ AWAIT_READY(offers1);
+ EXPECT_NE(0u, offers1.get().size());
+
+ // Launch the first task with the default executor id.
+ ExecutorInfo executor1;
+ executor1 = DEFAULT_EXECUTOR_INFO;
+ executor1.mutable_command()->set_value("exit 1");
+
+ TaskInfo task1 = createTask(
+ offers1.get()[0], executor1.command().value(), executor1.executor_id());
+
+ vector<TaskInfo> tasks1;
+ tasks1.push_back(task1);
+
+ // Return a pending future from authorizer.
+ Future<Nothing> future;
+ Promise<bool> promise;
+ EXPECT_CALL(authorizer, authorize(An<const mesos::ACL::RunTasks&>()))
+ .WillOnce(DoAll(FutureSatisfy(&future),
+ Return(promise.future())));
+
+ driver.launchTasks(offers1.get()[0].id(), tasks1);
+
+ // Wait until authorization is in progress.
+ AWAIT_READY(future);
+
+ Future<vector<Offer> > offers2;
+ EXPECT_CALL(sched, resourceOffers(&driver, _))
+ .WillOnce(FutureArg<1>(&offers2))
+ .WillRepeatedly(Return()); // Ignore subsequent offers.
+
+ // Now start the second slave.
+ MockExecutor exec2(DEFAULT_EXECUTOR_ID);
+
+ Try<PID<Slave> > slave2 = StartSlave(&exec2);
+ ASSERT_SOME(slave2);
+
+ AWAIT_READY(offers2);
+ EXPECT_NE(0u, offers2.get().size());
+
+ // Now launch the second task with the same executor id but
+ // a different executor command.
+ ExecutorInfo executor2;
+ executor2 = executor1;
+ executor2.mutable_command()->set_value("exit 2");
+
+ TaskInfo task2 = createTask(
+ offers2.get()[0], executor2.command().value(), executor2.executor_id());
+
+ vector<TaskInfo> tasks2;
+ tasks2.push_back(task2);
+
+ EXPECT_CALL(exec2, registered(_, _, _, _))
+ .Times(1);
+
+ EXPECT_CALL(exec2, launchTask(_, _))
+ .WillOnce(SendStatusUpdateFromTask(TASK_RUNNING));
+
+ Future<TaskStatus> status2;
+ EXPECT_CALL(sched, statusUpdate(&driver, _))
+ .WillOnce(FutureArg<1>(&status2));
+
+ EXPECT_CALL(authorizer, authorize(An<const mesos::ACL::RunTasks&>()))
+ .WillOnce(Return(true));
+
+ driver.launchTasks(offers2.get()[0].id(), tasks2);
+
+ AWAIT_READY(status2);
+ ASSERT_EQ(TASK_RUNNING, status2.get().state());
+
+ EXPECT_CALL(exec1, registered(_, _, _, _))
+ .Times(1);
+
+ EXPECT_CALL(exec1, launchTask(_, _))
+ .WillOnce(SendStatusUpdateFromTask(TASK_RUNNING));
+
+ Future<TaskStatus> status1;
+ EXPECT_CALL(sched, statusUpdate(&driver, _))
+ .WillOnce(FutureArg<1>(&status1));
+
+ // Complete authorization of 'task1'.
+ promise.set(true);
+
+ AWAIT_READY(status1);
+ ASSERT_EQ(TASK_RUNNING, status1.get().state());
+
+ EXPECT_CALL(exec1, shutdown(_))
+ .Times(AtMost(1));
+
+ EXPECT_CALL(exec2, shutdown(_))
+ .Times(AtMost(1));
+
+ driver.stop();
+ driver.join();
+
+ Shutdown();
+}
+
+
// This test verifies that a framework registration with authorized
// role is successful.
TEST_F(MasterAuthorizationTest, AuthorizedRole)
http://git-wip-us.apache.org/repos/asf/mesos/blob/dde865e3/src/tests/resource_offers_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/resource_offers_tests.cpp b/src/tests/resource_offers_tests.cpp
index 3ec688a..060039e 100644
--- a/src/tests/resource_offers_tests.cpp
+++ b/src/tests/resource_offers_tests.cpp
@@ -514,8 +514,9 @@ TEST_F(ResourceOffersTest, Request)
class MultipleExecutorsTest : public MesosTest {};
-
-TEST_F(MultipleExecutorsTest, TasksExecutorInfoDiffers)
+// This test verifies that two tasks launched on the same slave with
+// the same executor id but different executor info are rejected.
+TEST_F(MultipleExecutorsTest, ExecutorInfoDiffersOnSameSlave)
{
Try<PID<Master> > master = StartMaster();
ASSERT_SOME(master);
@@ -600,3 +601,116 @@ TEST_F(MultipleExecutorsTest, TasksExecutorInfoDiffers)
Shutdown();
}
+
+
+// This test verifies that two tasks each launched on a different
+// slave with same executor id but different executor info are
+// allowed.
+TEST_F(MultipleExecutorsTest, ExecutorInfoDiffersOnDifferentSlaves)
+{
+ Try<PID<Master> > master = StartMaster();
+ ASSERT_SOME(master);
+
+ MockScheduler sched;
+ MesosSchedulerDriver driver(
+ &sched, DEFAULT_FRAMEWORK_INFO, master.get(), DEFAULT_CREDENTIAL);
+
+ Future<Nothing> registered;
+ EXPECT_CALL(sched, registered(&driver, _, _))
+ .WillOnce(FutureSatisfy(®istered));
+
+ driver.start();
+
+ AWAIT_READY(registered);
+
+ Future<vector<Offer> > offers1;
+ EXPECT_CALL(sched, resourceOffers(&driver, _))
+ .WillOnce(FutureArg<1>(&offers1));
+
+ // Start the first slave.
+ MockExecutor exec1(DEFAULT_EXECUTOR_ID);
+
+ Try<PID<Slave> > slave1 = StartSlave(&exec1);
+ ASSERT_SOME(slave1);
+
+ AWAIT_READY(offers1);
+ EXPECT_NE(0u, offers1.get().size());
+
+ // Launch the first task with the default executor id.
+ ExecutorInfo executor1;
+ executor1 = DEFAULT_EXECUTOR_INFO;
+ executor1.mutable_command()->set_value("exit 1");
+
+ TaskInfo task1 = createTask(
+ offers1.get()[0], executor1.command().value(), executor1.executor_id());
+
+ vector<TaskInfo> tasks1;
+ tasks1.push_back(task1);
+
+ EXPECT_CALL(exec1, registered(_, _, _, _))
+ .Times(1);
+
+ EXPECT_CALL(exec1, launchTask(_, _))
+ .WillOnce(SendStatusUpdateFromTask(TASK_RUNNING));
+
+ Future<TaskStatus> status1;
+ EXPECT_CALL(sched, statusUpdate(&driver, _))
+ .WillOnce(FutureArg<1>(&status1));
+
+ driver.launchTasks(offers1.get()[0].id(), tasks1);
+
+ AWAIT_READY(status1);
+ ASSERT_EQ(TASK_RUNNING, status1.get().state());
+
+ Future<vector<Offer> > offers2;
+ EXPECT_CALL(sched, resourceOffers(&driver, _))
+ .WillOnce(FutureArg<1>(&offers2))
+ .WillRepeatedly(Return()); // Ignore subsequent offers.
+
+ // Now start the second slave.
+ MockExecutor exec2(DEFAULT_EXECUTOR_ID);
+
+ Try<PID<Slave> > slave2 = StartSlave(&exec2);
+ ASSERT_SOME(slave2);
+
+ AWAIT_READY(offers2);
+ EXPECT_NE(0u, offers2.get().size());
+
+ // Now launch the second task with the same executor id but
+ // a different executor command.
+ ExecutorInfo executor2;
+ executor2 = executor1;
+ executor2.mutable_command()->set_value("exit 2");
+
+ TaskInfo task2 = createTask(
+ offers2.get()[0], executor2.command().value(), executor2.executor_id());
+
+ vector<TaskInfo> tasks2;
+ tasks2.push_back(task2);
+
+ EXPECT_CALL(exec2, registered(_, _, _, _))
+ .Times(1);
+
+ EXPECT_CALL(exec2, launchTask(_, _))
+ .WillOnce(SendStatusUpdateFromTask(TASK_RUNNING));
+
+ Future<TaskStatus> status2;
+ EXPECT_CALL(sched, statusUpdate(&driver, _))
+ .WillOnce(FutureArg<1>(&status2));
+
+ driver.launchTasks(offers2.get()[0].id(), tasks2);
+
+ AWAIT_READY(status2);
+ ASSERT_EQ(TASK_RUNNING, status2.get().state());
+
+ EXPECT_CALL(exec1, shutdown(_))
+ .Times(AtMost(1));
+
+ EXPECT_CALL(exec2, shutdown(_))
+ .Times(AtMost(1));
+
+ driver.stop();
+ driver.join();
+
+ Shutdown();
+}