[5/8] mesos git commit: Added an equality operator for `TaskGroupInfo`/`TaskInfo`.
Added an equality operator for `TaskGroupInfo`/`TaskInfo`. This is needed for storing \`TaskGroupInfo\` in a list and then invoking \`std::find()\`/\`std::remove()\` on it. Also added a basic test in `src/tests/common/type_utils_tests.cpp`. Review: https://reviews.apache.org/r/51475/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/94827559 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/94827559 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/94827559 Branch: refs/heads/master Commit: 94827559f3727ef6dd0058068e7a4c976000a0f9 Parents: 00815ee Author: Anand Mazumdar Authored: Mon Sep 12 14:21:09 2016 -0700 Committer: Anand Mazumdar Committed: Mon Sep 12 15:17:02 2016 -0700 -- include/mesos/type_utils.hpp | 2 + src/Makefile.am | 1 + src/common/type_utils.cpp | 31 src/tests/common/type_utils_tests.cpp | 78 ++ 4 files changed, 112 insertions(+) -- http://git-wip-us.apache.org/repos/asf/mesos/blob/94827559/include/mesos/type_utils.hpp -- diff --git a/include/mesos/type_utils.hpp b/include/mesos/type_utils.hpp index d10b663..4f4f46e 100644 --- a/include/mesos/type_utils.hpp +++ b/include/mesos/type_utils.hpp @@ -62,6 +62,8 @@ bool operator==( bool operator==(const SlaveInfo& left, const SlaveInfo& right); bool operator==(const Task& left, const Task& right); +bool operator==(const TaskGroupInfo& left, const TaskGroupInfo& right); +bool operator==(const TaskInfo& left, const TaskInfo& right); bool operator==(const TaskStatus& left, const TaskStatus& right); bool operator==(const URL& left, const URL& right); bool operator==(const Volume& left, const Volume& right); http://git-wip-us.apache.org/repos/asf/mesos/blob/94827559/src/Makefile.am -- diff --git a/src/Makefile.am b/src/Makefile.am index fa71381..2dd7913 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2141,6 +2141,7 @@ mesos_tests_SOURCES = \ tests/common/command_utils_tests.cpp \ tests/common/http_tests.cpp \ tests/common/recordio_tests.cpp \ + tests/common/type_utils_tests.cpp\ tests/containerizer/appc_spec_tests.cpp \ tests/containerizer/composing_containerizer_tests.cpp\ tests/containerizer/docker_containerizer_tests.cpp \ http://git-wip-us.apache.org/repos/asf/mesos/blob/94827559/src/common/type_utils.cpp -- diff --git a/src/common/type_utils.cpp b/src/common/type_utils.cpp index c7d5033..9cb6274 100644 --- a/src/common/type_utils.cpp +++ b/src/common/type_utils.cpp @@ -388,6 +388,37 @@ bool operator==(const Task& left, const Task& right) } +bool operator==(const TaskGroupInfo& left, const TaskGroupInfo& right) +{ + // Order of tasks in a task group is not important. + if (left.tasks().size() != right.tasks().size()) { +return false; + } + + for (int i = 0; i < left.tasks().size(); i++) { +bool found = false; +for (int j = 0; j < right.tasks().size(); j++) { + if (left.tasks().Get(i) == right.tasks().Get(j)) { +found = true; +break; + } +} +if (!found) { + return false; +} + } + + return true; +} + + +// TODO(anand): Consider doing a field by field comparison instead. +bool operator==(const TaskInfo& left, const TaskInfo& right) +{ + return left.SerializeAsString() == right.SerializeAsString(); +} + + // TODO(bmahler): Use SerializeToString here? bool operator==(const TaskStatus& left, const TaskStatus& right) { http://git-wip-us.apache.org/repos/asf/mesos/blob/94827559/src/tests/common/type_utils_tests.cpp -- diff --git a/src/tests/common/type_utils_tests.cpp b/src/tests/common/type_utils_tests.cpp new file mode 100644 index 000..a962b39 --- /dev/null +++ b/src/tests/common/type_utils_tests.cpp @@ -0,0 +1,78 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, softw
[4/8] mesos git commit: Implemented `RunTaskGroupMessage` handler on the agent.
Implemented `RunTaskGroupMessage` handler on the agent. This changes implements the `runTaskGroup()` handler on the agent ensuring that task group is sent atomically to the executor via the `LAUNCH_GROUP` event. It also refactors `runTask()`/`_runTask()` to go through a common handler function. Also, it ensures that all tasks in `framework->pending`/`queuedTasks` that are killed before running the task group result in all the tasks being killed. Review: https://reviews.apache.org/r/51477/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/3a4c3f14 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/3a4c3f14 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/3a4c3f14 Branch: refs/heads/master Commit: 3a4c3f14c1b88650b6c1ed8329ff44869de53024 Parents: 3e9ea3b Author: Anand Mazumdar Authored: Mon Sep 12 14:21:28 2016 -0700 Committer: Anand Mazumdar Committed: Mon Sep 12 15:17:02 2016 -0700 -- src/slave/slave.cpp | 819 ++- src/slave/slave.hpp | 52 ++- 2 files changed, 636 insertions(+), 235 deletions(-) -- http://git-wip-us.apache.org/repos/asf/mesos/blob/3a4c3f14/src/slave/slave.cpp -- diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp index fa3610d..c7ab7f2 100644 --- a/src/slave/slave.cpp +++ b/src/slave/slave.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -109,8 +110,10 @@ using mesos::slave::QoSController; using mesos::slave::QoSCorrection; using mesos::slave::ResourceEstimator; +using std::find; using std::list; using std::map; +using std::ostringstream; using std::set; using std::string; using std::tuple; @@ -568,6 +571,12 @@ void Slave::initialize() &RunTaskMessage::pid, &RunTaskMessage::task); + install( + &Slave::runTaskGroup, + &RunTaskGroupMessage::framework, + &RunTaskGroupMessage::executor, + &RunTaskGroupMessage::task_group); + install( &Slave::killTask); @@ -1481,7 +1490,7 @@ void Slave::runTask( const FrameworkInfo& frameworkInfo, const FrameworkID& frameworkId_, const UPID& pid, -TaskInfo task) +const TaskInfo& task) { if (master != from) { LOG(WARNING) << "Ignoring run task message from " << from @@ -1496,17 +1505,44 @@ void Slave::runTask( return; } - // Create frameworkId alias to use in the rest of the function. - const FrameworkID frameworkId = frameworkInfo.id(); + const ExecutorInfo executorInfo = getExecutorInfo(frameworkInfo, task); + + run(frameworkInfo, executorInfo, task, None(), pid); +} + + +void Slave::run( +const FrameworkInfo& frameworkInfo, +const ExecutorInfo& executorInfo, +Option task, +Option taskGroup, +const UPID& pid) +{ + CHECK_NE(task.isSome(), taskGroup.isSome()) +<< "Either task or task group should be set but not both"; + + vector tasks; + if (task.isSome()) { +tasks.push_back(task.get()); + } else { +foreach (const TaskInfo& task, taskGroup->tasks()) { + tasks.push_back(task); +} + } + + const FrameworkID& frameworkId = frameworkInfo.id(); - LOG(INFO) << "Got assigned task " << task.task_id() + LOG(INFO) << "Got assigned " << taskOrTaskGroup(task, taskGroup) << " for framework " << frameworkId; - if (!(task.slave_id() == info.id())) { -LOG(WARNING) - << "Agent " << info.id() << " ignoring task " << task.task_id() - << " because it was intended for old agent " << task.slave_id(); -return; + foreach (const TaskInfo& task, tasks) { +if (!(task.slave_id() == info.id())) { + LOG(WARNING) +<< "Agent " << info.id() << " ignoring running " +<< taskOrTaskGroup(task, taskGroup) << " because " +<< "it was intended for old agent " << task.slave_id(); + return; +} } CHECK(state == RECOVERING || state == DISCONNECTED || @@ -1515,8 +1551,9 @@ void Slave::runTask( // TODO(bmahler): Also ignore if we're DISCONNECTED. if (state == RECOVERING || state == TERMINATING) { -LOG(WARNING) << "Ignoring task " << task.task_id() +LOG(WARNING) << "Ignoring running " << taskOrTaskGroup(task, taskGroup) << " because the agent is " << state; + // TODO(vinod): Consider sending a TASK_LOST here. // Currently it is tricky because 'statusUpdate()' // ignores updates for unknown frameworks. @@ -1570,20 +1607,35 @@ void Slave::runTask( } } - const ExecutorInfo executorInfo = getExecutorInfo(frameworkInfo, task); const ExecutorID& executorId = executorInfo.executor_id(); if (HookManager::hooksAvailable()) { // Set task labels from run task label decorator. -task.mutable_labels()->CopyFrom(HookManager::slaveRu
[8/8] mesos git commit: Minor fix to avoid creating an unnecessary temporary when looping.
Minor fix to avoid creating an unnecessary temporary when looping. This change is done for making the looping style consistent through the code. Review: https://reviews.apache.org/r/51710/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/aaa353ac Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/aaa353ac Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/aaa353ac Branch: refs/heads/master Commit: aaa353acc515c0435a859113c9ee236247b51169 Parents: 2b61afe Author: Anand Mazumdar Authored: Mon Sep 12 14:21:46 2016 -0700 Committer: Anand Mazumdar Committed: Mon Sep 12 15:17:02 2016 -0700 -- src/slave/slave.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/mesos/blob/aaa353ac/src/slave/slave.cpp -- diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp index c7ab7f2..2c7b5ad 100644 --- a/src/slave/slave.cpp +++ b/src/slave/slave.cpp @@ -1596,8 +1596,7 @@ void Slave::run( // executors to this framework and remove it from that list. // TODO(brenden): Consider using stout/cache.hpp instead of boost // circular_buffer. -for (auto it = completedFrameworks.begin(), end = completedFrameworks.end(); - it != end; +for (auto it = completedFrameworks.begin(); it != completedFrameworks.end(); ++it) { if ((*it)->id() == frameworkId) { framework->completedExecutors = (*it)->completedExecutors;
[3/8] mesos git commit: Made the `TaskInfo` argument in `launchExecutor()` optional.
Made the `TaskInfo` argument in `launchExecutor()` optional. Launching a task group requires just the `ExecutorInfo`. We had already refactored the containerizer `launch()` interface to make `TaskInfo` as an optional. This change funnels it through. Review: https://reviews.apache.org/r/51476/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/3e9ea3b2 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/3e9ea3b2 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/3e9ea3b2 Branch: refs/heads/master Commit: 3e9ea3b2090236514bfd5c6a47b9d42e6e306aad Parents: 9482755 Author: Anand Mazumdar Authored: Mon Sep 12 14:21:23 2016 -0700 Committer: Anand Mazumdar Committed: Mon Sep 12 15:17:02 2016 -0700 -- src/slave/slave.cpp | 12 src/slave/slave.hpp | 4 +++- 2 files changed, 11 insertions(+), 5 deletions(-) -- http://git-wip-us.apache.org/repos/asf/mesos/blob/3e9ea3b2/src/slave/slave.cpp -- diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp index 2da5a29..fa3610d 100644 --- a/src/slave/slave.cpp +++ b/src/slave/slave.cpp @@ -5727,7 +5727,7 @@ Framework::~Framework() // Create and launch an executor. Executor* Framework::launchExecutor( const ExecutorInfo& executorInfo, -const TaskInfo& taskInfo) +const Option& taskInfo) { // Generate an ID for the executor's container. // TODO(idownes) This should be done by the containerizer but we @@ -5800,13 +5800,17 @@ Executor* Framework::launchExecutor( .onAny(defer(slave, &Slave::fileAttached, lambda::_1, executor->directory)); // Tell the containerizer to launch the executor. + ExecutorInfo executorInfo_ = executor->info; + Resources resources = executorInfo_.resources(); + // NOTE: We modify the ExecutorInfo to include the task's // resources when launching the executor so that the containerizer // has non-zero resources to work with when the executor has // no resources. This should be revisited after MESOS-600. - ExecutorInfo executorInfo_ = executor->info; - Resources resources = executorInfo_.resources(); - resources += taskInfo.resources(); + if (taskInfo.isSome()) { +resources += taskInfo->resources(); + } + executorInfo_.mutable_resources()->CopyFrom(resources); // Prepare environment variables for the executor. http://git-wip-us.apache.org/repos/asf/mesos/blob/3e9ea3b2/src/slave/slave.hpp -- diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp index 4add4c0..ec02f63 100644 --- a/src/slave/slave.hpp +++ b/src/slave/slave.hpp @@ -922,9 +922,11 @@ struct Framework ~Framework(); + // If an executor is launched for a task group, `taskInfo` would + // not be set. Executor* launchExecutor( const ExecutorInfo& executorInfo, - const TaskInfo& taskInfo); + const Option& taskInfo); void destroyExecutor(const ExecutorID& executorId); Executor* getExecutor(const ExecutorID& executorId); Executor* getExecutor(const TaskID& taskId);
[7/8] mesos git commit: Added mock overloads for `runTaskGroup()`/`launchGroup()`.
Added mock overloads for `runTaskGroup()`/`launchGroup()`. Review: https://reviews.apache.org/r/51479/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/f8734b7a Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/f8734b7a Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/f8734b7a Branch: refs/heads/master Commit: f8734b7a2572ac48fbd1cb763e732d68d7752529 Parents: 8f9f17b Author: Anand Mazumdar Authored: Mon Sep 12 14:22:54 2016 -0700 Committer: Anand Mazumdar Committed: Mon Sep 12 15:17:02 2016 -0700 -- src/tests/mesos.cpp | 12 src/tests/mesos.hpp | 15 ++- 2 files changed, 26 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/mesos/blob/f8734b7a/src/tests/mesos.cpp -- diff --git a/src/tests/mesos.cpp b/src/tests/mesos.cpp index 4ec21e7..539634e 100644 --- a/src/tests/mesos.cpp +++ b/src/tests/mesos.cpp @@ -543,6 +543,8 @@ MockSlave::MockSlave( .WillRepeatedly(Invoke(this, &MockSlave::unmocked_runTask)); EXPECT_CALL(*this, _run(_, _, _, _, _)) .WillRepeatedly(Invoke(this, &MockSlave::unmocked__run)); + EXPECT_CALL(*this, runTaskGroup(_, _, _, _)) +.WillRepeatedly(Invoke(this, &MockSlave::unmocked_runTaskGroup)); EXPECT_CALL(*this, killTask(_, _)) .WillRepeatedly(Invoke(this, &MockSlave::unmocked_killTask)); EXPECT_CALL(*this, removeFramework(_)) @@ -585,6 +587,16 @@ void MockSlave::unmocked__run( } +void MockSlave::unmocked_runTaskGroup( +const process::UPID& from, +const FrameworkInfo& frameworkInfo, +const ExecutorInfo& executorInfo, +const TaskGroupInfo& taskGroup) +{ + slave::Slave::runTaskGroup(from, frameworkInfo, executorInfo, taskGroup); +} + + void MockSlave::unmocked_killTask( const UPID& from, const KillTaskMessage& killTaskMessage) http://git-wip-us.apache.org/repos/asf/mesos/blob/f8734b7a/src/tests/mesos.hpp -- diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp index 946e03d..92d7d94 100644 --- a/src/tests/mesos.hpp +++ b/src/tests/mesos.hpp @@ -1140,6 +1140,7 @@ public: MOCK_METHOD1_T(disconnected, void(Mesos*)); MOCK_METHOD2_T(subscribed, void(Mesos*, const typename Event::Subscribed&)); MOCK_METHOD2_T(launch, void(Mesos*, const typename Event::Launch&)); + MOCK_METHOD2_T(launchGroup, void(Mesos*, const typename Event::LaunchGroup&)); MOCK_METHOD2_T(kill, void(Mesos*, const typename Event::Kill&)); MOCK_METHOD2_T(message, void(Mesos*, const typename Event::Message&)); MOCK_METHOD1_T(shutdown, void(Mesos*)); @@ -1157,7 +1158,7 @@ public: launch(mesos, event.launch()); break; case Event::LAUNCH_GROUP: -// TODO(vinod): Implement this. +launchGroup(mesos, event.launch_group()); break; case Event::KILL: kill(mesos, event.kill()); @@ -1380,6 +1381,18 @@ public: const Option& task, const Option& taskGroup); + MOCK_METHOD4(runTaskGroup, void( + const process::UPID& from, + const FrameworkInfo& frameworkInfo, + const ExecutorInfo& executorInfo, + const TaskGroupInfo& taskGroup)); + + void unmocked_runTaskGroup( + const process::UPID& from, + const FrameworkInfo& frameworkInfo, + const ExecutorInfo& executorInfo, + const TaskGroupInfo& taskGroup); + MOCK_METHOD2(killTask, void( const process::UPID& from, const KillTaskMessage& killTaskMessage));
[2/8] mesos git commit: Modified tests to account for `runTask()`/`_runTask()` refactoring.
Modified tests to account for `runTask()`/`_runTask()` refactoring. This change modified the agent mocks/tests to account for the \`runTask()\`/\`\_runTask()\` refactoring. Review: https://reviews.apache.org/r/51478/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/8f9f17bb Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/8f9f17bb Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/8f9f17bb Branch: refs/heads/master Commit: 8f9f17bbdbcd08b46037816bc3d23e66aa3d2f16 Parents: aaa353a Author: Anand Mazumdar Authored: Mon Sep 12 14:22:45 2016 -0700 Committer: Anand Mazumdar Committed: Mon Sep 12 15:17:02 2016 -0700 -- src/tests/master_slave_reconciliation_tests.cpp | 6 +-- src/tests/mesos.cpp | 15 --- src/tests/mesos.hpp | 16 +--- src/tests/slave_tests.cpp | 43 4 files changed, 47 insertions(+), 33 deletions(-) -- http://git-wip-us.apache.org/repos/asf/mesos/blob/8f9f17bb/src/tests/master_slave_reconciliation_tests.cpp -- diff --git a/src/tests/master_slave_reconciliation_tests.cpp b/src/tests/master_slave_reconciliation_tests.cpp index 7dda6f6..2983c1b 100644 --- a/src/tests/master_slave_reconciliation_tests.cpp +++ b/src/tests/master_slave_reconciliation_tests.cpp @@ -426,9 +426,9 @@ TEST_F(MasterSlaveReconciliationTest, SlaveReregisterPendingTask) EXPECT_CALL(sched, statusUpdate(&driver, _)) .Times(0); - // We drop the _runTask dispatch to ensure the task remains + // We drop the _run dispatch to ensure the task remains // pending in the slave. - Future _runTask = DROP_DISPATCH(slave.get()->pid, &Slave::_runTask); + Future _run = DROP_DISPATCH(slave.get()->pid, &Slave::_run); TaskInfo task1; task1.set_name("test task"); @@ -439,7 +439,7 @@ TEST_F(MasterSlaveReconciliationTest, SlaveReregisterPendingTask) driver.launchTasks(offers.get()[0].id(), {task1}); - AWAIT_READY(_runTask); + AWAIT_READY(_run); Future slaveReregisteredMessage = FUTURE_PROTOBUF(SlaveReregisteredMessage(), _, _); http://git-wip-us.apache.org/repos/asf/mesos/blob/8f9f17bb/src/tests/mesos.cpp -- diff --git a/src/tests/mesos.cpp b/src/tests/mesos.cpp index f5034f9..4ec21e7 100644 --- a/src/tests/mesos.cpp +++ b/src/tests/mesos.cpp @@ -541,8 +541,8 @@ MockSlave::MockSlave( // Set up default behaviors, calling the original methods. EXPECT_CALL(*this, runTask(_, _, _, _, _)) .WillRepeatedly(Invoke(this, &MockSlave::unmocked_runTask)); - EXPECT_CALL(*this, _runTask(_, _, _)) -.WillRepeatedly(Invoke(this, &MockSlave::unmocked__runTask)); + EXPECT_CALL(*this, _run(_, _, _, _, _)) +.WillRepeatedly(Invoke(this, &MockSlave::unmocked__run)); EXPECT_CALL(*this, killTask(_, _)) .WillRepeatedly(Invoke(this, &MockSlave::unmocked_killTask)); EXPECT_CALL(*this, removeFramework(_)) @@ -567,18 +567,21 @@ void MockSlave::unmocked_runTask( const FrameworkInfo& frameworkInfo, const FrameworkID& frameworkId, const UPID& pid, -TaskInfo task) +const TaskInfo& task) { slave::Slave::runTask(from, frameworkInfo, frameworkInfo.id(), pid, task); } -void MockSlave::unmocked__runTask( +void MockSlave::unmocked__run( const Future& future, const FrameworkInfo& frameworkInfo, -const TaskInfo& task) +const ExecutorInfo& executorInfo, +const Option& taskInfo, +const Option& taskGroup) { - slave::Slave::_runTask(future, frameworkInfo, task); + slave::Slave::_run( + future, frameworkInfo, executorInfo, taskInfo, taskGroup); } http://git-wip-us.apache.org/repos/asf/mesos/blob/8f9f17bb/src/tests/mesos.hpp -- diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp index 9bcdaf1..946e03d 100644 --- a/src/tests/mesos.hpp +++ b/src/tests/mesos.hpp @@ -1357,24 +1357,28 @@ public: const FrameworkInfo& frameworkInfo, const FrameworkID& frameworkId, const process::UPID& pid, - TaskInfo task)); + const TaskInfo& task)); void unmocked_runTask( const process::UPID& from, const FrameworkInfo& frameworkInfo, const FrameworkID& frameworkId, const process::UPID& pid, - TaskInfo task); + const TaskInfo& task); - MOCK_METHOD3(_runTask, void( + MOCK_METHOD5(_run, void( const process::Future& future, const FrameworkInfo& frameworkInfo, - const TaskInfo& task)); + const ExecutorInfo& executorInfo, + const Option& task, + const Option& taskGroup)); - void unmocked__runTask( + void unmocked__run( con
[1/8] mesos git commit: Added tests for launching task groups on the agent.
Repository: mesos Updated Branches: refs/heads/master 00815ee93 -> 170c01f1a Added tests for launching task groups on the agent. This change adds tests for testing the `runTaskGroup()` handler on the agent. Review: https://reviews.apache.org/r/51480/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/170c01f1 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/170c01f1 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/170c01f1 Branch: refs/heads/master Commit: 170c01f1a184e7fdc6cd057e5ef7dbf2fbc658af Parents: f8734b7 Author: Anand Mazumdar Authored: Mon Sep 12 14:23:00 2016 -0700 Committer: Anand Mazumdar Committed: Mon Sep 12 15:17:02 2016 -0700 -- src/tests/slave_tests.cpp | 318 + 1 file changed, 318 insertions(+) -- http://git-wip-us.apache.org/repos/asf/mesos/blob/170c01f1/src/tests/slave_tests.cpp -- diff --git a/src/tests/slave_tests.cpp b/src/tests/slave_tests.cpp index 55dba3f..2f3fa5f 100644 --- a/src/tests/slave_tests.cpp +++ b/src/tests/slave_tests.cpp @@ -77,6 +77,9 @@ using mesos::internal::protobuf::createLabel; using mesos::master::detector::MasterDetector; using mesos::master::detector::StandaloneMasterDetector; +using mesos::v1::scheduler::Call; +using mesos::v1::scheduler::Mesos; + using process::Clock; using process::Future; using process::Owned; @@ -4304,6 +4307,321 @@ TEST_F(SlaveTest, ExecutorShutdownGracePeriod) driver.join(); } + +// This test verifies that the agent can forward a task group to an +// executor atomically via the `LAUNCH_GROUP` event. +TEST_F(SlaveTest, RunTaskGroup) +{ + Try> master = StartMaster(); + ASSERT_SOME(master); + + auto scheduler = std::make_shared(); + auto executor = std::make_shared(); + + Resources resources = +Resources::parse("cpus:0.1;mem:32;disk:32").get(); + + ExecutorInfo executorInfo = DEFAULT_EXECUTOR_INFO; + executorInfo.set_type(ExecutorInfo::CUSTOM); + + executorInfo.mutable_resources()->CopyFrom(resources); + + const ExecutorID& executorId = executorInfo.executor_id(); + TestContainerizer containerizer(executorId, executor); + + Owned detector = master.get()->createDetector(); + Try> slave = StartSlave(detector.get(), &containerizer); + ASSERT_SOME(slave); + + Future connected; + EXPECT_CALL(*scheduler, connected(_)) +.WillOnce(FutureSatisfy(&connected)); + + scheduler::TestV1Mesos mesos( + master.get()->pid, ContentType::PROTOBUF, scheduler); + + AWAIT_READY(connected); + + Future subscribed; + EXPECT_CALL(*scheduler, subscribed(_, _)) +.WillOnce(FutureArg<1>(&subscribed)); + + Future offers; + EXPECT_CALL(*scheduler, offers(_, _)) +.WillOnce(FutureArg<1>(&offers)); + + EXPECT_CALL(*scheduler, heartbeat(_)) +.WillRepeatedly(Return()); // Ignore heartbeats. + + { +Call call; +call.set_type(Call::SUBSCRIBE); +Call::Subscribe* subscribe = call.mutable_subscribe(); +subscribe->mutable_framework_info()->CopyFrom(DEFAULT_V1_FRAMEWORK_INFO); + +mesos.send(call); + } + + AWAIT_READY(subscribed); + + v1::FrameworkID frameworkId(subscribed->framework_id()); + + // Update `executorInfo` with the subscribed `frameworkId`. + executorInfo.mutable_framework_id()->CopyFrom(devolve(frameworkId)); + + AWAIT_READY(offers); + EXPECT_NE(0, offers->offers().size()); + + EXPECT_CALL(*executor, connected(_)) +.WillOnce(executor::SendSubscribe(frameworkId, evolve(executorId))); + + EXPECT_CALL(*executor, subscribed(_, _)); + + EXPECT_CALL(*executor, launch(_, _)) +.Times(0); + + Future launchGroupEvent; + EXPECT_CALL(*executor, launchGroup(_, _)) +.WillOnce(FutureArg<1>(&launchGroupEvent)); + + const v1::Offer& offer = offers->offers(0); + const SlaveID slaveId = devolve(offer.agent_id()); + + v1::TaskInfo taskInfo1 = +evolve(createTask(slaveId, resources, "")); + + v1::TaskInfo taskInfo2 = +evolve(createTask(slaveId, resources, "")); + + v1::TaskGroupInfo taskGroup; + taskGroup.add_tasks()->CopyFrom(taskInfo1); + taskGroup.add_tasks()->CopyFrom(taskInfo2); + + { +Call call; +call.mutable_framework_id()->CopyFrom(frameworkId); +call.set_type(Call::ACCEPT); + +Call::Accept* accept = call.mutable_accept(); +accept->add_offer_ids()->CopyFrom(offer.id()); + +v1::Offer::Operation* operation = accept->add_operations(); +operation->set_type(v1::Offer::Operation::LAUNCH_GROUP); + +v1::Offer::Operation::LaunchGroup* launchGroup = + operation->mutable_launch_group(); + +launchGroup->mutable_executor()->CopyFrom(evolve(executorInfo)); +launchGroup->mutable_task_group()->CopyFrom(taskGroup); + +mesos.send(call); + } + + AWAIT_READY(launchGroupEvent); + + ASSERT_EQ(2, launc
[6/8] mesos git commit: Removed a no longer needed comment after the `runTasks()` refactoring.
Removed a no longer needed comment after the `runTasks()` refactoring. Review: https://reviews.apache.org/r/51709/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/2b61afe5 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/2b61afe5 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/2b61afe5 Branch: refs/heads/master Commit: 2b61afe547209020a61387c7dba0b9a7fa3f8b33 Parents: 3a4c3f1 Author: Anand Mazumdar Authored: Mon Sep 12 14:21:34 2016 -0700 Committer: Anand Mazumdar Committed: Mon Sep 12 15:17:02 2016 -0700 -- src/slave/slave.hpp | 3 --- 1 file changed, 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/mesos/blob/2b61afe5/src/slave/slave.hpp -- diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp index 903a48d..e659c44 100644 --- a/src/slave/slave.hpp +++ b/src/slave/slave.hpp @@ -325,9 +325,6 @@ public: // been updated for the given tasks and task groups. If the update is // successful, we flush the given tasks to the executor by sending // RunTaskMessages or `LAUNCH_GROUP` events. - // TODO(jieyu): Consider renaming it to '__runTasks' once the slave - // starts to support launching multiple tasks in one call (i.e., - // multi-tasks version of 'runTask'). void __run( const process::Future& future, const FrameworkID& frameworkId,
mesos git commit: Fixed potential FD double close in the libevent socket.
Repository: mesos Updated Branches: refs/heads/master 630e4c9bc -> 00815ee93 Fixed potential FD double close in the libevent socket. `evbuffer_add_file` will take ownership of the file descriptor passed into it. Normally, this file descriptor is owned by the `FileEncoder` in the libprocess's `SocketManager`. Since there are two owners, one of the owners may close the file descriptor when it has been re-used. In this case, when multiple threads access the master's web UI at once with SSL enabled, the master may CHECK-fail due to a bad (closed) file descriptor. Review: https://reviews.apache.org/r/51509/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/00815ee9 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/00815ee9 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/00815ee9 Branch: refs/heads/master Commit: 00815ee93b69b1f93a4c8e42e0bc548a021804bc Parents: 630e4c9 Author: Joseph Wu Authored: Mon Sep 12 12:40:09 2016 -0700 Committer: Joseph Wu Committed: Mon Sep 12 12:57:47 2016 -0700 -- 3rdparty/libprocess/src/libevent_ssl_socket.cpp | 38 ++-- 1 file changed, 36 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/mesos/blob/00815ee9/3rdparty/libprocess/src/libevent_ssl_socket.cpp -- diff --git a/3rdparty/libprocess/src/libevent_ssl_socket.cpp b/3rdparty/libprocess/src/libevent_ssl_socket.cpp index 99a12b8..a26ff80 100644 --- a/3rdparty/libprocess/src/libevent_ssl_socket.cpp +++ b/3rdparty/libprocess/src/libevent_ssl_socket.cpp @@ -750,6 +750,36 @@ Future LibeventSSLSocketImpl::sendfile( std::swap(request, send_request); } + // Duplicate the file descriptor because Libevent will take ownership + // and control the lifecycle separately. + // + // TODO(josephw): We can avoid duplicating the file descriptor in + // future versions of Libevent. In Libevent versions 2.1.2 and later, + // we may use `evbuffer_file_segment_new` and `evbuffer_add_file_segment` + // instead of `evbuffer_add_file`. + int owned_fd = dup(fd); + if (fd == -1) { +return Failure(ErrnoError("Failed to duplicate file descriptor")); + } + + // Set the close-on-exec flag. + Try cloexec = os::cloexec(owned_fd); + if (cloexec.isError()) { +os::close(owned_fd); +return Failure( +"Failed to set close-on-exec on duplicated file descriptor: " + +cloexec.error()); + } + + // Make the file descriptor non-blocking. + Try nonblock = os::nonblock(owned_fd); + if (nonblock.isError()) { +os::close(owned_fd); +return Failure( +"Failed to make duplicated file descriptor non-blocking: " + +nonblock.error()); + } + // Extend the life-time of 'this' through the execution of the // lambda in the event loop. Note: The 'self' needs to be explicitly // captured because we're not using it in the body of the lambda. We @@ -758,7 +788,7 @@ Future LibeventSSLSocketImpl::sendfile( auto self = shared(this); run_in_event_loop( - [self, fd, offset, size]() { + [self, owned_fd, offset, size]() { CHECK(__in_event_loop__); CHECK(self); @@ -774,12 +804,16 @@ Future LibeventSSLSocketImpl::sendfile( } if (write) { + // NOTE: `evbuffer_add_file` will take ownership of the file + // descriptor and close it after it has finished reading it. int result = evbuffer_add_file( bufferevent_get_output(self->bev), - fd, + owned_fd, offset, size); CHECK_EQ(0, result); +} else { + os::close(owned_fd); } }, DISALLOW_SHORT_CIRCUIT);
mesos git commit: Added missing #includes in docker containerizer.
Repository: mesos Updated Branches: refs/heads/master 0b623f9d2 -> 630e4c9bc Added missing #includes in docker containerizer. Review: https://reviews.apache.org/r/51425/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/630e4c9b Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/630e4c9b Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/630e4c9b Branch: refs/heads/master Commit: 630e4c9bc26dbbb30c81acefa75955b50ba773e1 Parents: 0b623f9 Author: Yubo Li Authored: Mon Sep 12 12:45:11 2016 -0700 Committer: Benjamin Mahler Committed: Mon Sep 12 12:47:06 2016 -0700 -- src/slave/containerizer/docker.hpp | 4 1 file changed, 4 insertions(+) -- http://git-wip-us.apache.org/repos/asf/mesos/blob/630e4c9b/src/slave/containerizer/docker.hpp -- diff --git a/src/slave/containerizer/docker.hpp b/src/slave/containerizer/docker.hpp index b172a8e..a378fa9 100644 --- a/src/slave/containerizer/docker.hpp +++ b/src/slave/containerizer/docker.hpp @@ -17,6 +17,10 @@ #ifndef __DOCKER_CONTAINERIZER_HPP__ #define __DOCKER_CONTAINERIZER_HPP__ +#include +#include +#include + #include #include
mesos git commit: Added meta tags in project website to support Twitter Cards.
Repository: mesos Updated Branches: refs/heads/master 3562f95d0 -> 0b623f9d2 Added meta tags in project website to support Twitter Cards. Slack depends on Twitter Summary Card to show small preview logo. This patch followed https://dev.twitter.com/cards/types/summary to add meta tags in project website template to support Twitter Cards. For consistency, we completed the similar Open Graph meta tags which supported by Facebook in this patch as well. Review: https://reviews.apache.org/r/51485/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/0b623f9d Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/0b623f9d Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/0b623f9d Branch: refs/heads/master Commit: 0b623f9d2177f2456f3ade43a33920f3d2b70352 Parents: 3562f95 Author: haosdent huang Authored: Mon Sep 12 11:13:04 2016 -0700 Committer: Vinod Kone Committed: Mon Sep 12 11:13:04 2016 -0700 -- site/source/layouts/basic.erb | 21 - 1 file changed, 20 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/mesos/blob/0b623f9d/site/source/layouts/basic.erb -- diff --git a/site/source/layouts/basic.erb b/site/source/layouts/basic.erb index 253de38..7464e40 100755 --- a/site/source/layouts/basic.erb +++ b/site/source/layouts/basic.erb @@ -4,7 +4,26 @@ <%= current_page.data.title %> - + + + + + +http://mesos.apache.org/"/> +http://mesos.apache.org/assets/img/mesos_logo_fb_preview.png"/> + + + + + +http://mesos.apache.org/assets/img/mesos_logo_fb_preview.png"/> +