You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2012/12/07 01:46:20 UTC
svn commit: r1418150 - in /incubator/mesos/trunk/src: slave/gc.hpp
slave/slave.cpp slave/slave.hpp tests/gc_tests.cpp
Author: benh
Date: Fri Dec 7 00:46:19 2012
New Revision: 1418150
URL: http://svn.apache.org/viewvc?rev=1418150&view=rev
Log:
Detached executor work directories after getting GC'ed.
From: Ben Mahler <be...@gmail.com>
Review: https://reviews.apache.org/r/8009
Modified:
incubator/mesos/trunk/src/slave/gc.hpp
incubator/mesos/trunk/src/slave/slave.cpp
incubator/mesos/trunk/src/slave/slave.hpp
incubator/mesos/trunk/src/tests/gc_tests.cpp
Modified: incubator/mesos/trunk/src/slave/gc.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/slave/gc.hpp?rev=1418150&r1=1418149&r2=1418150&view=diff
==============================================================================
--- incubator/mesos/trunk/src/slave/gc.hpp (original)
+++ incubator/mesos/trunk/src/slave/gc.hpp Fri Dec 7 00:46:19 2012
@@ -48,9 +48,9 @@ public:
~GarbageCollector();
// Schedules the specified path for removal after the specified
- // duration of time has elapsed and returns true if the file was
- // successfully removed and false if the file didn't exist (or an
- // error, e.g., permission denied).
+ // duration of time has elapsed.
+ // The future will become ready when the path has been removed.
+ // If the directory did not exist, or an error occurred, the future will fail.
process::Future<Nothing> schedule(const Duration& d, const std::string& path);
// Deletes all the directories, whose scheduled garbage collection time
Modified: incubator/mesos/trunk/src/slave/slave.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/slave/slave.cpp?rev=1418150&r1=1418149&r2=1418150&view=diff
==============================================================================
--- incubator/mesos/trunk/src/slave/slave.cpp (original)
+++ incubator/mesos/trunk/src/slave/slave.cpp Fri Dec 7 00:46:19 2012
@@ -363,6 +363,13 @@ void Slave::fileAttached(const Future<No
}
+void Slave::detachFile(const Future<Nothing>& result, const std::string& path)
+{
+ CHECK(!result.isDiscarded());
+ files->detach(path);
+}
+
+
void Slave::newMasterDetected(const UPID& pid)
{
LOG(INFO) << "New master detected at " << pid;
@@ -1069,7 +1076,8 @@ void Slave::executorTerminated(
}
// Schedule the executor directory to get garbage collected.
- gc.schedule(flags.gc_delay, executor->directory);
+ gc.schedule(flags.gc_delay, executor->directory)
+ .onAny(defer(self(), &Self::detachFile, params::_1, executor->directory));
framework->destroyExecutor(executor->id);
}
@@ -1116,7 +1124,8 @@ void Slave::shutdownExecutorTimeout(
executor->id);
// Schedule the executor directory to get garbage collected.
- gc.schedule(flags.gc_delay, executor->directory);
+ gc.schedule(flags.gc_delay, executor->directory)
+ .onAny(defer(self(), &Self::detachFile, params::_1, executor->directory));;
framework->destroyExecutor(executor->id);
}
Modified: incubator/mesos/trunk/src/slave/slave.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/slave/slave.hpp?rev=1418150&r1=1418149&r2=1418150&view=diff
==============================================================================
--- incubator/mesos/trunk/src/slave/slave.hpp (original)
+++ incubator/mesos/trunk/src/slave/slave.hpp Fri Dec 7 00:46:19 2012
@@ -160,6 +160,8 @@ protected:
void fileAttached(const Future<Nothing>& result, const std::string& path);
+ void detachFile(const Future<Nothing>& result, const std::string& path);
+
// Helper routine to lookup a framework.
Framework* getFramework(const FrameworkID& frameworkId);
Modified: incubator/mesos/trunk/src/tests/gc_tests.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/gc_tests.cpp?rev=1418150&r1=1418149&r2=1418150&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/gc_tests.cpp (original)
+++ incubator/mesos/trunk/src/tests/gc_tests.cpp Fri Dec 7 00:46:19 2012
@@ -23,6 +23,7 @@
#include <process/dispatch.hpp>
#include <process/future.hpp>
+#include <process/http.hpp>
#include <stout/duration.hpp>
#include <stout/os.hpp>
@@ -43,6 +44,7 @@
#include "slave/flags.hpp"
#include "slave/slave.hpp"
+#include "tests/assert.hpp"
#include "tests/filter.hpp"
#include "tests/utils.hpp"
@@ -303,6 +305,9 @@ TEST_F(GarbageCollectorTest, ExitedExecu
isolationModule->directories[DEFAULT_EXECUTOR_ID];
ASSERT_TRUE(os::exists(executorDir));
+ EXPECT_RESPONSE_STATUS_WILL_EQ(
+ process::http::OK().status,
+ process::http::get(files->pid(), "browse.json", "path=" + executorDir));
Clock::pause();
@@ -335,6 +340,9 @@ TEST_F(GarbageCollectorTest, ExitedExecu
// Executor's directory should be gc'ed by now.
ASSERT_FALSE(os::exists(executorDir));
+ EXPECT_RESPONSE_STATUS_WILL_EQ(
+ process::http::NotFound().status,
+ process::http::get(files->pid(), "browse.json", "path=" + executorDir));
Clock::resume();
@@ -389,6 +397,9 @@ TEST_F(GarbageCollectorTest, DiskUsage)
isolationModule->directories[DEFAULT_EXECUTOR_ID];
ASSERT_TRUE(os::exists(executorDir));
+ EXPECT_RESPONSE_STATUS_WILL_EQ(
+ process::http::OK().status,
+ process::http::get(files->pid(), "browse.json", "path=" + executorDir));
Clock::pause();
@@ -424,6 +435,9 @@ TEST_F(GarbageCollectorTest, DiskUsage)
// Executor's directory should be gc'ed by now.
ASSERT_FALSE(os::exists(executorDir));
+ EXPECT_RESPONSE_STATUS_WILL_EQ(
+ process::http::NotFound().status,
+ process::http::get(files->pid(), "browse.json", "path=" + executorDir));
Clock::resume();