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 2017/06/05 21:44:02 UTC
mesos git commit: Attach latest symlink when executor is registered.
Repository: mesos
Updated Branches:
refs/heads/master cb4dc7643 -> 588bb0b9f
Attach latest symlink when executor is registered.
This will assist framework developers in making features that need
to access the latest sandbox when hitting various operator API
endpoints.
Review: https://reviews.apache.org/r/59641/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/588bb0b9
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/588bb0b9
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/588bb0b9
Branch: refs/heads/master
Commit: 588bb0b9f9ee6f47bd70ba0f93c8ddb4c3bc5e1c
Parents: cb4dc76
Author: Aaron Wood <aa...@verizon.com>
Authored: Mon Jun 5 14:43:21 2017 -0700
Committer: Vinod Kone <vi...@gmail.com>
Committed: Mon Jun 5 14:43:21 2017 -0700
----------------------------------------------------------------------
src/slave/slave.cpp | 37 +++++++++++++++++++++++++++++++++++--
src/tests/gc_tests.cpp | 20 ++++++++++++++++++++
2 files changed, 55 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/588bb0b9/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index 0c7e5f4..7d147ac 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -5414,8 +5414,16 @@ void Slave::removeExecutor(Framework* framework, Executor* executor)
const string path = paths::getExecutorPath(
flags.work_dir, info.id(), framework->id(), executor->id);
+ // Make sure we detach the "latest" symlink.
+ const string latestPath = paths::getExecutorLatestRunPath(
+ flags.work_dir,
+ info.id(),
+ framework->id(),
+ executor->id);
+
os::utime(path); // Update the modification time.
- garbageCollect(path);
+ garbageCollect(path)
+ .then(defer(self(), &Self::detachFile, latestPath));
}
if (executor->checkpoint) {
@@ -7095,6 +7103,18 @@ Executor* Framework::addExecutor(const ExecutorInfo& executorInfo)
executorId);
};
+ // Attach the "latest" symlink. This allows for frameworks to
+ // easily construct paths to the sandbox directory for a given task
+ // without having to know the container id.
+ string latestPath = paths::getExecutorLatestRunPath(
+ slave->flags.work_dir,
+ slave->info.id(),
+ id(),
+ executorInfo.executor_id());
+
+ slave->files->attach(executor->directory, latestPath, authorize)
+ .onAny(defer(slave, &Slave::fileAttached, lambda::_1, executor->directory));
+
slave->files->attach(executor->directory, executor->directory, authorize)
.onAny(defer(slave, &Slave::fileAttached, lambda::_1, executor->directory));
@@ -7256,6 +7276,18 @@ void Framework::recoverExecutor(
executorId);
};
+ // Attach the "latest" symlink. This allows for frameworks to
+ // easily construct paths to the sandbox directory for a given task
+ // without having to know the container id.
+ string latestPath = paths::getExecutorLatestRunPath(
+ slave->flags.work_dir,
+ slave->info.id(),
+ id(),
+ state.id);
+
+ slave->files->attach(executor->directory, latestPath, authorize)
+ .onAny(defer(slave, &Slave::fileAttached, lambda::_1, executor->directory));
+
// Expose the executor's files.
slave->files->attach(executor->directory, executor->directory, authorize)
.onAny(defer(slave, &Slave::fileAttached, lambda::_1, executor->directory));
@@ -7290,7 +7322,8 @@ void Framework::recoverExecutor(
// GC the top level executor work directory.
slave->garbageCollect(paths::getExecutorPath(
- slave->flags.work_dir, slave->info.id(), id(), state.id));
+ slave->flags.work_dir, slave->info.id(), id(), state.id))
+ .then(defer(slave, &Slave::detachFile, latestPath));
// GC the top level executor meta directory.
slave->garbageCollect(paths::getExecutorPath(
http://git-wip-us.apache.org/repos/asf/mesos/blob/588bb0b9/src/tests/gc_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/gc_tests.cpp b/src/tests/gc_tests.cpp
index b8fa6a4..d4daad3 100644
--- a/src/tests/gc_tests.cpp
+++ b/src/tests/gc_tests.cpp
@@ -555,6 +555,18 @@ TEST_F(GarbageCollectorIntegrationTest, ExitedExecutor)
ASSERT_TRUE(os::exists(executorDir));
+ const string& latestDir = slave::paths::getExecutorLatestRunPath(
+ flags.work_dir, slaveId, frameworkId.get(), DEFAULT_EXECUTOR_ID);
+
+ process::UPID latest("files", process::address());
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(
+ process::http::OK().status,
+ process::http::get(
+ latest,
+ "browse",
+ "path=" + latestDir,
+ createBasicAuthHeaders(DEFAULT_CREDENTIAL)));
+
Clock::pause();
// Kiling the executor will cause the slave to schedule its
@@ -593,6 +605,14 @@ TEST_F(GarbageCollectorIntegrationTest, ExitedExecutor)
"path=" + executorDir,
createBasicAuthHeaders(DEFAULT_CREDENTIAL)));
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(
+ process::http::NotFound().status,
+ process::http::get(
+ latest,
+ "browse",
+ "path=" + latestDir,
+ createBasicAuthHeaders(DEFAULT_CREDENTIAL)));
+
Clock::resume();
driver.stop();