You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2016/03/18 21:40:01 UTC

[1/2] mesos git commit: Cleaned up formatting in command executor.

Repository: mesos
Updated Branches:
  refs/heads/master 888c8af0b -> 630b12ad8


Cleaned up formatting in command executor.

The general pattern for formatting the code is to
reduce jaggedness and increase readability.

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


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

Branch: refs/heads/master
Commit: 20d615bb995dd2cc5175dc7161d4e61c9018ef3c
Parents: 888c8af
Author: Alexander Rukletsov <ru...@gmail.com>
Authored: Fri Mar 18 13:21:51 2016 -0700
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Fri Mar 18 13:21:51 2016 -0700

----------------------------------------------------------------------
 src/launcher/executor.cpp | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/20d615bb/src/launcher/executor.cpp
----------------------------------------------------------------------
diff --git a/src/launcher/executor.cpp b/src/launcher/executor.cpp
index 4149f08..63eb8f1 100644
--- a/src/launcher/executor.cpp
+++ b/src/launcher/executor.cpp
@@ -403,7 +403,6 @@ public:
 #endif // __linux__
       }
 
-
       cout << commandString << endl;
 
       // The child has successfully setsid, now run the command.
@@ -725,12 +724,13 @@ public:
       const Option<string>& user,
       const Option<string>& taskCommand)
   {
-    process = new CommandExecutorProcess(override,
-                                         healthCheckDir,
-                                         sandboxDirectory,
-                                         workingDirectory,
-                                         user,
-                                         taskCommand);
+    process = new CommandExecutorProcess(
+        override,
+        healthCheckDir,
+        sandboxDirectory,
+        workingDirectory,
+        user,
+        taskCommand);
 
     spawn(process);
   }


[2/2] mesos git commit: Removed hard-coded executor shutdown grace period in executor driver.

Posted by bm...@apache.org.
Removed hard-coded executor shutdown grace period in executor driver.

The executor shutdown grace period, which configured on the agent, is
propagated to executors via the `MESOS_EXECUTOR_SHUTDOWN_GRACE_PERIOD`
environment variable. The executor driver uses this timeout to delay
the forcible kill of the executor process group.

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


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

Branch: refs/heads/master
Commit: 630b12ad86c31ad21d536e068ee18f8722d79c48
Parents: 20d615b
Author: Alexander Rukletsov <ru...@gmail.com>
Authored: Fri Mar 18 13:36:26 2016 -0700
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Fri Mar 18 13:39:42 2016 -0700

----------------------------------------------------------------------
 src/exec/exec.cpp         | 42 ++++++++++++++++++++++++++++++++++--------
 src/executor/executor.cpp |  2 +-
 2 files changed, 35 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/630b12ad/src/exec/exec.cpp
----------------------------------------------------------------------
diff --git a/src/exec/exec.cpp b/src/exec/exec.cpp
index ede16f4..8f67260 100644
--- a/src/exec/exec.cpp
+++ b/src/exec/exec.cpp
@@ -81,15 +81,16 @@ namespace internal {
 // Process here, see: MESOS-4729.
 class ShutdownProcess : public Process<ShutdownProcess>
 {
+public:
+  explicit ShutdownProcess(const Duration& _gracePeriod)
+    : gracePeriod(_gracePeriod) {}
+
 protected:
   virtual void initialize()
   {
-    VLOG(1) << "Scheduling shutdown of the executor in "
-            << slave::DEFAULT_EXECUTOR_SHUTDOWN_GRACE_PERIOD;
+    VLOG(1) << "Scheduling shutdown of the executor in " << gracePeriod;
 
-    // TODO(benh): Pass the shutdown timeout with ExecutorRegistered
-    // since it might have gotten configured on the command line.
-    delay(slave::DEFAULT_EXECUTOR_SHUTDOWN_GRACE_PERIOD, self(), &Self::kill);
+    delay(gracePeriod, self(), &Self::kill);
   }
 
   void kill()
@@ -105,6 +106,9 @@ protected:
     os::sleep(Seconds(5));
     exit(EXIT_FAILURE);
   }
+
+private:
+  const Duration gracePeriod;
 };
 
 
@@ -122,6 +126,7 @@ public:
       const string& _directory,
       bool _checkpoint,
       const Duration& _recoveryTimeout,
+      const Duration& _shutdownGracePeriod,
       std::recursive_mutex* _mutex,
       Latch* _latch)
     : ProcessBase(ID::generate("executor")),
@@ -139,7 +144,8 @@ public:
       latch(_latch),
       directory(_directory),
       checkpoint(_checkpoint),
-      recoveryTimeout(_recoveryTimeout)
+      recoveryTimeout(_recoveryTimeout),
+      shutdownGracePeriod(_shutdownGracePeriod)
   {
     LOG(INFO) << "Version: " << MESOS_VERSION;
 
@@ -394,7 +400,7 @@ protected:
 
     if (!local) {
       // Start the Shutdown Process.
-      spawn(new ShutdownProcess(), true);
+      spawn(new ShutdownProcess(shutdownGracePeriod), true);
     }
 
     Stopwatch stopwatch;
@@ -478,7 +484,7 @@ protected:
 
     if (!local) {
       // Start the Shutdown Process.
-      spawn(new ShutdownProcess(), true);
+      spawn(new ShutdownProcess(shutdownGracePeriod), true);
     }
 
     Stopwatch stopwatch;
@@ -562,6 +568,7 @@ private:
   const string directory;
   bool checkpoint;
   Duration recoveryTimeout;
+  Duration shutdownGracePeriod;
 
   LinkedHashMap<UUID, StatusUpdate> updates; // Unacknowledged updates.
 
@@ -697,6 +704,24 @@ Status MesosExecutorDriver::start()
     }
     workDirectory = value.get();
 
+    // Get executor shutdown grace period from the environment.
+    //
+    // NOTE: We do not require this variable to be set
+    // (in contrast to the others above) for backwards
+    // compatibility: agents < 0.28.0 do not set it.
+    Duration shutdownGracePeriod = DEFAULT_EXECUTOR_SHUTDOWN_GRACE_PERIOD;
+    value = os::getenv("MESOS_EXECUTOR_SHUTDOWN_GRACE_PERIOD");
+    if (value.isSome()) {
+      Try<Duration> parse = Duration::parse(value.get());
+      if (parse.isError()) {
+        EXIT(EXIT_FAILURE)
+          << "Failed to parse value '" << value.get() << "' of "
+          << "'MESOS_EXECUTOR_SHUTDOWN_GRACE_PERIOD': " << parse.error();
+      }
+
+      shutdownGracePeriod = parse.get();
+    }
+
     // Get checkpointing status from environment.
     value = os::getenv("MESOS_CHECKPOINT");
     checkpoint = value.isSome() && value.get() == "1";
@@ -733,6 +758,7 @@ Status MesosExecutorDriver::start()
         workDirectory,
         checkpoint,
         recoveryTimeout,
+        shutdownGracePeriod,
         &mutex,
         latch);
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/630b12ad/src/executor/executor.cpp
----------------------------------------------------------------------
diff --git a/src/executor/executor.cpp b/src/executor/executor.cpp
index 87db4e0..48b0050 100644
--- a/src/executor/executor.cpp
+++ b/src/executor/executor.cpp
@@ -232,7 +232,7 @@ public:
       }
     }
 
-    // Get shutdown grace period from environment.
+    // Get executor shutdown grace period from the environment.
     value = os::getenv("MESOS_EXECUTOR_SHUTDOWN_GRACE_PERIOD");
     if (value.isSome()) {
       Try<Duration> _shutdownGracePeriod = Duration::parse(value.get());