Repository: mesos Updated Branches: refs/heads/master 542288a15 -> 3b16439be
Reintroduced chown stdout/stderr in FetcherProcess::run(). rb30774 erased a call to chown() in FetcherProcess::run() that should have stayed there. It gets reintroduced here. Review: https://reviews.apache.org/r/34892 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/3b16439b Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/3b16439b Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/3b16439b Branch: refs/heads/master Commit: 3b16439be60d8a80de3a1574b40d84cb17600123 Parents: 542288a Author: Bernd Mathiske <[email protected]> Authored: Mon Jun 1 08:56:48 2015 -0700 Committer: Benjamin Hindman <[email protected]> Committed: Mon Jun 1 08:56:50 2015 -0700 ---------------------------------------------------------------------- src/slave/containerizer/fetcher.cpp | 18 +++++++++++++++++- src/slave/containerizer/fetcher.hpp | 2 ++ src/tests/fetcher_cache_tests.cpp | 12 ++++++------ src/tests/mesos.cpp | 11 +++++++++-- src/tests/mesos.hpp | 6 +++++- 5 files changed, 39 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/3b16439b/src/slave/containerizer/fetcher.cpp ---------------------------------------------------------------------- diff --git a/src/slave/containerizer/fetcher.cpp b/src/slave/containerizer/fetcher.cpp index d4f127a..f77652b 100644 --- a/src/slave/containerizer/fetcher.cpp +++ b/src/slave/containerizer/fetcher.cpp @@ -510,7 +510,7 @@ Future<Nothing> FetcherProcess::__fetch( info.set_frameworks_home(flags.frameworks_home); } - return run(containerId, info, flags) + return run(containerId, sandboxDirectory, user, info, flags) .repair(defer(self(), [=](const Future<Nothing>& future) { LOG(ERROR) << "Failed to run mesos-fetcher: " << future.failure(); @@ -675,6 +675,8 @@ FetcherProcess::reserveCacheSpace( Future<Nothing> FetcherProcess::run( const ContainerID& containerId, + const string& sandboxDirectory, + const Option<string>& user, const FetcherInfo& info, const Flags& flags) { @@ -707,6 +709,20 @@ Future<Nothing> FetcherProcess::run( return Failure("Failed to create 'stderr' file: " + err.error()); } + if (user.isSome()) { + // This is a recursive chown that both checks if we have a valid user + // and also chowns the files we just opened. + Try<Nothing> chown = os::chown(user.get(), sandboxDirectory, true); + if (chown.isError()) { + os::close(out.get()); + os::close(err.get()); + + return Failure("Failed to chown directory: '" + sandboxDirectory + + "' to user '" + user.get() + + "' with error: " + chown.error()); + } + } + string fetcherPath = path::join(flags.launcher_dir, "mesos-fetcher"); Result<string> realpath = os::realpath(fetcherPath); http://git-wip-us.apache.org/repos/asf/mesos/blob/3b16439b/src/slave/containerizer/fetcher.hpp ---------------------------------------------------------------------- diff --git a/src/slave/containerizer/fetcher.hpp b/src/slave/containerizer/fetcher.hpp index 16553ff..1722507 100644 --- a/src/slave/containerizer/fetcher.hpp +++ b/src/slave/containerizer/fetcher.hpp @@ -132,6 +132,8 @@ public: // in the given directory, using these for trace output. virtual process::Future<Nothing> run( const ContainerID& containerId, + const std::string& sandboxDirectory, + const Option<std::string>& user, const FetcherInfo& info, const Flags& flags); http://git-wip-us.apache.org/repos/asf/mesos/blob/3b16439b/src/tests/fetcher_cache_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/fetcher_cache_tests.cpp b/src/tests/fetcher_cache_tests.cpp index bd53fc1..cbd44b9 100644 --- a/src/tests/fetcher_cache_tests.cpp +++ b/src/tests/fetcher_cache_tests.cpp @@ -609,8 +609,8 @@ TEST_F(FetcherCacheTest, CachedFallback) // Bring back the asset just before running mesos-fetcher to fetch it. Future<FetcherInfo> fetcherInfo; - EXPECT_CALL(*fetcherProcess, run(_, _, _)) - .WillOnce(DoAll(FutureArg<1>(&fetcherInfo), + EXPECT_CALL(*fetcherProcess, run(_, _, _, _, _)) + .WillOnce(DoAll(FutureArg<3>(&fetcherInfo), InvokeWithoutArgs(this, &FetcherCacheTest::setupCommandFileAsset), Invoke(fetcherProcess, @@ -1221,14 +1221,14 @@ TEST_F(FetcherCacheTest, FallbackFromEviction) Future<FetcherInfo> fetcherInfo0; Future<FetcherInfo> fetcherInfo1; Future<FetcherInfo> fetcherInfo2; - EXPECT_CALL(*fetcherProcess, run(_, _, _)) - .WillOnce(DoAll(FutureArg<1>(&fetcherInfo0), + EXPECT_CALL(*fetcherProcess, run(_, _, _, _, _)) + .WillOnce(DoAll(FutureArg<3>(&fetcherInfo0), Invoke(fetcherProcess, &MockFetcherProcess::unmocked_run))) - .WillOnce(DoAll(FutureArg<1>(&fetcherInfo1), + .WillOnce(DoAll(FutureArg<3>(&fetcherInfo1), Invoke(fetcherProcess, &MockFetcherProcess::unmocked_run))) - .WillOnce(DoAll(FutureArg<1>(&fetcherInfo2), + .WillOnce(DoAll(FutureArg<3>(&fetcherInfo2), Invoke(fetcherProcess, &MockFetcherProcess::unmocked_run))); http://git-wip-us.apache.org/repos/asf/mesos/blob/3b16439b/src/tests/mesos.cpp ---------------------------------------------------------------------- diff --git a/src/tests/mesos.cpp b/src/tests/mesos.cpp index 830d362..d3a8bb7 100644 --- a/src/tests/mesos.cpp +++ b/src/tests/mesos.cpp @@ -453,7 +453,7 @@ MockFetcherProcess::MockFetcherProcess() EXPECT_CALL(*this, _fetch(_, _, _, _, _, _)). WillRepeatedly( Invoke(this, &MockFetcherProcess::unmocked__fetch)); - EXPECT_CALL(*this, run(_, _, _)). + EXPECT_CALL(*this, run(_, _, _, _, _)). WillRepeatedly(Invoke(this, &MockFetcherProcess::unmocked_run)); } @@ -479,10 +479,17 @@ process::Future<Nothing> MockFetcherProcess::unmocked__fetch( process::Future<Nothing> MockFetcherProcess::unmocked_run( const ContainerID& containerId, + const string& sandboxDirectory, + const Option<string>& user, const FetcherInfo& info, const slave::Flags& flags) { - return slave::FetcherProcess::run(containerId, info, flags); + return slave::FetcherProcess::run( + containerId, + sandboxDirectory, + user, + info, + flags); } http://git-wip-us.apache.org/repos/asf/mesos/blob/3b16439b/src/tests/mesos.hpp ---------------------------------------------------------------------- diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp index bfd820c..c00adb1 100644 --- a/src/tests/mesos.hpp +++ b/src/tests/mesos.hpp @@ -831,13 +831,17 @@ public: const Option<std::string>& user, const slave::Flags& flags); - MOCK_METHOD3(run, process::Future<Nothing>( + MOCK_METHOD5(run, process::Future<Nothing>( const ContainerID& containerId, + const std::string& sandboxDirectory, + const Option<std::string>& user, const FetcherInfo& info, const slave::Flags& flags)); process::Future<Nothing> unmocked_run( const ContainerID& containerId, + const std::string& sandboxDirectory, + const Option<std::string>& user, const FetcherInfo& info, const slave::Flags& flags); };
