mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bmah...@apache.org
Subject [1/4] mesos git commit: Log the virtual path of attached files in the agent.
Date Tue, 19 Sep 2017 22:07:49 GMT
Repository: mesos
Updated Branches:
  refs/heads/master 87a3ce946 -> c644a35e6


Log the virtual path of attached files in the agent.

Files exposed via the /files endpoints are exposed via
"virtual" paths that may be different from the real path.

Review: https://reviews.apache.org/r/62040/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/af483f50
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/af483f50
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/af483f50

Branch: refs/heads/master
Commit: af483f507ef992832423b29b2c5b4ee2397a78f7
Parents: 87a3ce9
Author: Zhitao Li <zhitaoli.cs@gmail.com>
Authored: Tue Sep 19 14:06:02 2017 -0700
Committer: Benjamin Mahler <bmahler@apache.org>
Committed: Tue Sep 19 14:06:02 2017 -0700

----------------------------------------------------------------------
 src/slave/constants.hpp |  3 +++
 src/slave/slave.cpp     | 53 +++++++++++++++++++++++++++++++++++---------
 src/slave/slave.hpp     |  3 ++-
 3 files changed, 47 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/af483f50/src/slave/constants.hpp
----------------------------------------------------------------------
diff --git a/src/slave/constants.hpp b/src/slave/constants.hpp
index 435c37e..4015906 100644
--- a/src/slave/constants.hpp
+++ b/src/slave/constants.hpp
@@ -164,6 +164,9 @@ Duration DEFAULT_MASTER_PING_TIMEOUT();
 // Name of the executable for default executor.
 constexpr char MESOS_DEFAULT_EXECUTOR[] = "mesos-default-executor";
 
+// Virtual path on which agent logs are mounted in `/files/` endpoint.
+constexpr char AGENT_LOG_VIRTUAL_PATH[] = "/slave/log";
+
 std::vector<SlaveInfo::Capability> AGENT_CAPABILITIES();
 
 } // namespace slave {

http://git-wip-us.apache.org/repos/asf/mesos/blob/af483f50/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index 391a0d6..d66c72e 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -809,11 +809,13 @@ void Slave::initialize()
   // Expose the log file for the webui. Fall back to 'log_dir' if
   // an explicit file was not specified.
   if (flags.external_log_file.isSome()) {
-    files->attach(flags.external_log_file.get(), "/slave/log", authorize)
+    files->attach(
+        flags.external_log_file.get(), AGENT_LOG_VIRTUAL_PATH, authorize)
       .onAny(defer(self(),
                    &Self::fileAttached,
                    lambda::_1,
-                   flags.external_log_file.get()));
+                   flags.external_log_file.get(),
+                   AGENT_LOG_VIRTUAL_PATH));
   } else if (flags.log_dir.isSome()) {
     Try<string> log =
       logging::getLogFile(logging::getLogSeverity(flags.logging_level));
@@ -821,8 +823,12 @@ void Slave::initialize()
     if (log.isError()) {
       LOG(ERROR) << "Agent log file cannot be found: " << log.error();
     } else {
-      files->attach(log.get(), "/slave/log", authorize)
-        .onAny(defer(self(), &Self::fileAttached, lambda::_1, log.get()));
+      files->attach(log.get(), AGENT_LOG_VIRTUAL_PATH, authorize)
+        .onAny(defer(self(),
+                     &Self::fileAttached,
+                     lambda::_1,
+                     log.get(),
+                     AGENT_LOG_VIRTUAL_PATH));
     }
   }
 
@@ -936,12 +942,17 @@ void Slave::shutdown(const UPID& from, const string& message)
 }
 
 
-void Slave::fileAttached(const Future<Nothing>& result, const string& path)
+void Slave::fileAttached(
+    const Future<Nothing>& result,
+    const string& path,
+    const string& virtualPath)
 {
   if (result.isReady()) {
-    VLOG(1) << "Successfully attached file '" << path << "'";
+    VLOG(1) << "Successfully attached '" << path << "'"
+            << " to virtual path '" << virtualPath << "'";
   } else {
-    LOG(ERROR) << "Failed to attach file '" << path << "': "
+    LOG(ERROR) << "Failed to attach '" << path << "'"
+               << " to virtual path '" << virtualPath << "': "
                << (result.isFailed() ? result.failure() : "discarded");
   }
 }
@@ -7286,10 +7297,20 @@ Executor* Framework::addExecutor(const ExecutorInfo& executorInfo)
       executorInfo.executor_id());
 
   slave->files->attach(executor->directory, latestPath, authorize)
-    .onAny(defer(slave, &Slave::fileAttached, lambda::_1, executor->directory));
+    .onAny(defer(
+        slave,
+        &Slave::fileAttached,
+        lambda::_1,
+        executor->directory,
+        latestPath));
 
   slave->files->attach(executor->directory, executor->directory, authorize)
-    .onAny(defer(slave, &Slave::fileAttached, lambda::_1, executor->directory));
+    .onAny(defer(
+        slave,
+        &Slave::fileAttached,
+        lambda::_1,
+        executor->directory,
+        executor->directory));
 
   return executor;
 }
@@ -7459,11 +7480,21 @@ void Framework::recoverExecutor(
       state.id);
 
   slave->files->attach(executor->directory, latestPath, authorize)
-    .onAny(defer(slave, &Slave::fileAttached, lambda::_1, executor->directory));
+    .onAny(defer(
+        slave,
+        &Slave::fileAttached,
+        lambda::_1,
+        executor->directory,
+        latestPath));
 
   // Expose the executor's files.
   slave->files->attach(executor->directory, executor->directory, authorize)
-    .onAny(defer(slave, &Slave::fileAttached, lambda::_1, executor->directory));
+    .onAny(defer(
+        slave,
+        &Slave::fileAttached,
+        lambda::_1,
+        executor->directory,
+        executor->directory));
 
   // Add the executor to the framework.
   executors[executor->id] = executor;

http://git-wip-us.apache.org/repos/asf/mesos/blob/af483f50/src/slave/slave.hpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp
index 7d07868..aea1e94 100644
--- a/src/slave/slave.hpp
+++ b/src/slave/slave.hpp
@@ -375,7 +375,8 @@ public:
       const Option<TaskInfo>& taskInfo);
 
   void fileAttached(const process::Future<Nothing>& result,
-                    const std::string& path);
+                    const std::string& path,
+                    const std::string& virtualPath);
 
   Nothing detachFile(const std::string& path);
 


Mime
View raw message