You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by al...@apache.org on 2017/06/07 14:00:06 UTC

[1/4] mesos git commit: Used glog for logging in executors.

Repository: mesos
Updated Branches:
  refs/heads/master 791a1dc3e -> cbae0ce07


Used glog for logging in executors.

The rule for choosing between glog and cout is described by MESOS-7586.

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


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

Branch: refs/heads/master
Commit: c8178e06be5f9eeb370f81fa3726c06a39318604
Parents: 791a1dc
Author: Andrei Budnik <ab...@mesosphere.com>
Authored: Wed Jun 7 15:17:41 2017 +0200
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Wed Jun 7 15:17:41 2017 +0200

----------------------------------------------------------------------
 src/docker/executor.cpp           | 77 +++++++++++++++-----------------
 src/launcher/default_executor.cpp |  6 ++-
 src/launcher/executor.cpp         | 80 +++++++++++++++++-----------------
 3 files changed, 81 insertions(+), 82 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/c8178e06/src/docker/executor.cpp
----------------------------------------------------------------------
diff --git a/src/docker/executor.cpp b/src/docker/executor.cpp
index 464a748..82b4c87 100644
--- a/src/docker/executor.cpp
+++ b/src/docker/executor.cpp
@@ -111,7 +111,7 @@ public:
       const FrameworkInfo& _frameworkInfo,
       const SlaveInfo& slaveInfo)
   {
-    cout << "Registered docker executor on " << slaveInfo.hostname() << endl;
+    LOG(INFO) << "Registered docker executor on " << slaveInfo.hostname();
     driver = _driver;
     frameworkInfo = _frameworkInfo;
   }
@@ -120,12 +120,12 @@ public:
       ExecutorDriver* driver,
       const SlaveInfo& slaveInfo)
   {
-    cout << "Re-registered docker executor on " << slaveInfo.hostname() << endl;
+    LOG(INFO) << "Re-registered docker executor on " << slaveInfo.hostname();
   }
 
   void disconnected(ExecutorDriver* driver)
   {
-    cout << "Disconnected from the agent" << endl;
+    LOG(INFO) << "Disconnected from the agent";
   }
 
   void launchTask(ExecutorDriver* driver, const TaskInfo& task)
@@ -151,7 +151,7 @@ public:
       killPolicy = task.kill_policy();
     }
 
-    cout << "Starting task " << taskId.get() << endl;
+    LOG(INFO) << "Starting task " << taskId.get();
 
     CHECK(task.has_container());
     CHECK(task.has_command());
@@ -243,8 +243,8 @@ public:
       }));
 
     inspect.onFailed(defer(self(), [=](const string& failure) {
-      cerr << "Failed to inspect container '" << containerName << "'"
-           << ": " << failure << endl;
+      LOG(ERROR) << "Failed to inspect container '" << containerName << "'"
+                 << ": " << failure;
 
       // TODO(bmahler): This is fatal, try to shut down cleanly.
       // Since we don't have a container id, we can only discard
@@ -259,7 +259,7 @@ public:
 
   void killTask(ExecutorDriver* driver, const TaskID& taskId)
   {
-    cout << "Received killTask for task " << taskId.value() << endl;
+    LOG(INFO) << "Received killTask for task " << taskId.value();
 
     // Using shutdown grace period as a default is backwards compatible
     // with the `stop_timeout` flag, deprecated in 1.0.
@@ -276,7 +276,7 @@ public:
 
   void shutdown(ExecutorDriver* driver)
   {
-    cout << "Shutting down" << endl;
+    LOG(INFO) << "Shutting down";
 
     // Currently, 'docker->run' uses the reaper internally, hence we need
     // to account for the reap interval. We also leave a small buffer of
@@ -318,8 +318,8 @@ protected:
       return;
     }
 
-    cout << "Received task health update, healthy: "
-         << stringify(healthStatus.healthy()) << endl;
+    LOG(INFO) << "Received task health update, healthy: "
+              << stringify(healthStatus.healthy());
 
     // TODO(alexr): Use `protobuf::createTaskStatus()`
     // instead of manually setting fields.
@@ -533,8 +533,8 @@ private:
         docker->validateVersion(Version(1, 3, 0));
 
       if (validateVersion.isError()) {
-        cerr << "Unable to launch health check process: "
-             << validateVersion.error() << endl;
+        LOG(ERROR) << "Unable to launch health check process: "
+                   << validateVersion.error();
         return;
       }
 
@@ -585,8 +585,8 @@ private:
 
     if (_checker.isError()) {
       // TODO(gilbert): Consider ABORT and return a TASK_FAILED here.
-      cerr << "Failed to create health checker: "
-           << _checker.error() << endl;
+      LOG(ERROR) << "Failed to create health checker: "
+                 << _checker.error();
     } else {
       checker = _checker.get();
     }
@@ -735,6 +735,11 @@ int main(int argc, char** argv)
     return EXIT_FAILURE;
   }
 
+  if (flags.help) {
+    cout << flags.usage() << endl;
+    return EXIT_SUCCESS;
+  }
+
   mesos::internal::logging::initialize(argv[0], flags, true); // Catch signals.
 
   // Log any flag warnings (after logging is initialized).
@@ -744,29 +749,22 @@ int main(int argc, char** argv)
 
   VLOG(1) << stringify(flags);
 
-  if (flags.help) {
-    cout << flags.usage() << endl;
-    return EXIT_SUCCESS;
-  }
-
   if (flags.docker.isNone()) {
-    cerr << flags.usage("Missing required option --docker") << endl;
-    return EXIT_FAILURE;
+    EXIT(EXIT_FAILURE) << flags.usage("Missing required option --docker");
   }
 
   if (flags.container.isNone()) {
-    cerr << flags.usage("Missing required option --container") << endl;
-    return EXIT_FAILURE;
+    EXIT(EXIT_FAILURE) << flags.usage("Missing required option --container");
   }
 
   if (flags.sandbox_directory.isNone()) {
-    cerr << flags.usage("Missing required option --sandbox_directory") << endl;
-    return EXIT_FAILURE;
+    EXIT(EXIT_FAILURE)
+      << flags.usage("Missing required option --sandbox_directory");
   }
 
   if (flags.mapped_directory.isNone()) {
-    cerr << flags.usage("Missing required option --mapped_directory") << endl;
-    return EXIT_FAILURE;
+    EXIT(EXIT_FAILURE)
+      << flags.usage("Missing required option --mapped_directory");
   }
 
   map<string, string> taskEnvironment;
@@ -776,9 +774,8 @@ int main(int argc, char** argv)
       JSON::parse<JSON::Object>(flags.task_environment.get());
 
     if (json.isError()) {
-      cerr << flags.usage("Failed to parse --task_environment: " + json.error())
-           << endl;
-      return EXIT_FAILURE;
+      EXIT(EXIT_FAILURE)
+        << flags.usage("Failed to parse --task_environment: " + json.error());
     }
 
     // Convert from JSON to map.
@@ -787,11 +784,8 @@ int main(int argc, char** argv)
         const JSON::Value& value,
         json->values) {
       if (!value.is<JSON::String>()) {
-        cerr << flags.usage(
-            "Value of key '" + key +
-            "' in --task_environment is not a string")
-             << endl;
-        return EXIT_FAILURE;
+        EXIT(EXIT_FAILURE) << flags.usage(
+            "Value of key '" + key + "' in --task_environment is not a string");
       }
 
       // Save the parsed and validated key/value.
@@ -811,9 +805,9 @@ int main(int argc, char** argv)
   if (value.isSome()) {
     Try<Duration> parse = Duration::parse(value.get());
     if (parse.isError()) {
-      cerr << "Failed to parse value '" << value.get() << "'"
-           << " of 'MESOS_EXECUTOR_SHUTDOWN_GRACE_PERIOD': " << parse.error();
-      return EXIT_FAILURE;
+      EXIT(EXIT_FAILURE)
+        << "Failed to parse value '" << value.get() << "'"
+        << " of 'MESOS_EXECUTOR_SHUTDOWN_GRACE_PERIOD': " << parse.error();
     }
 
     shutdownGracePeriod = parse.get();
@@ -828,8 +822,7 @@ int main(int argc, char** argv)
   }
 
   if (flags.launcher_dir.isNone()) {
-    cerr << flags.usage("Missing required option --launcher_dir") << endl;
-    return EXIT_FAILURE;
+    EXIT(EXIT_FAILURE) << flags.usage("Missing required option --launcher_dir");
   }
 
   // The 2nd argument for docker create is set to false so we skip
@@ -841,8 +834,8 @@ int main(int argc, char** argv)
       false);
 
   if (docker.isError()) {
-    cerr << "Unable to create docker abstraction: " << docker.error() << endl;
-    return EXIT_FAILURE;
+    EXIT(EXIT_FAILURE)
+      << "Unable to create docker abstraction: " << docker.error();
   }
 
   Owned<mesos::internal::docker::DockerExecutor> executor(

http://git-wip-us.apache.org/repos/asf/mesos/blob/c8178e06/src/launcher/default_executor.cpp
----------------------------------------------------------------------
diff --git a/src/launcher/default_executor.cpp b/src/launcher/default_executor.cpp
index 1a60e3b..55ce19d 100644
--- a/src/launcher/default_executor.cpp
+++ b/src/launcher/default_executor.cpp
@@ -53,6 +53,8 @@
 #include "internal/devolve.hpp"
 #include "internal/evolve.hpp"
 
+#include "logging/logging.hpp"
+
 using mesos::executor::Call;
 using mesos::executor::Event;
 
@@ -1323,7 +1325,7 @@ private:
 } // namespace mesos {
 
 
-class Flags : public virtual flags::FlagsBase
+class Flags : public virtual mesos::internal::logging::Flags
 {
 public:
   Flags()
@@ -1362,6 +1364,8 @@ int main(int argc, char** argv)
     return EXIT_FAILURE;
   }
 
+  mesos::internal::logging::initialize(argv[0], flags, true); // Catch signals.
+
   Option<string> value = os::getenv("MESOS_FRAMEWORK_ID");
   if (value.isNone()) {
     EXIT(EXIT_FAILURE)

http://git-wip-us.apache.org/repos/asf/mesos/blob/c8178e06/src/launcher/executor.cpp
----------------------------------------------------------------------
diff --git a/src/launcher/executor.cpp b/src/launcher/executor.cpp
index 9ac3c3d..f5a46b5 100644
--- a/src/launcher/executor.cpp
+++ b/src/launcher/executor.cpp
@@ -166,12 +166,12 @@ public:
 
   void received(const Event& event)
   {
-    cout << "Received " << event.type() << " event" << endl;
+    LOG(INFO) << "Received " << event.type() << " event";
 
     switch (event.type()) {
       case Event::SUBSCRIBED: {
-        cout << "Subscribed executor on "
-             << event.subscribed().slave_info().hostname() << endl;
+        LOG(INFO) << "Subscribed executor on "
+                  << event.subscribed().slave_info().hostname();
 
         frameworkInfo = event.subscribed().framework_info();
         state = SUBSCRIBED;
@@ -184,7 +184,7 @@ public:
       }
 
       case Event::LAUNCH_GROUP: {
-        cerr << "LAUNCH_GROUP event is not supported" << endl;
+        LOG(ERROR) << "LAUNCH_GROUP event is not supported";
         // Shut down because this is unexpected; `LAUNCH_GROUP` event
         // should only ever go to a group-capable default executor and
         // not the command executor.
@@ -238,7 +238,7 @@ public:
       }
 
       case Event::ERROR: {
-        cerr << "Error: " << event.error().message() << endl;
+        LOG(ERROR) << "Error: " << event.error().message();
         break;
       }
 
@@ -300,7 +300,7 @@ protected:
       return;
     }
 
-    cout << "Received check update '" << checkStatus << "'" << endl;
+    LOG(INFO) << "Received check update '" << checkStatus << "'";
 
     // Use the previous task status to preserve all attached information.
     CHECK_SOME(lastTaskStatus);
@@ -333,8 +333,8 @@ protected:
       return;
     }
 
-    cout << "Received task health update, healthy: "
-         << stringify(healthStatus.healthy()) << endl;
+    LOG(INFO) << "Received task health update, healthy: "
+              << stringify(healthStatus.healthy());
 
     // Use the previous task status to preserve all attached information.
     CHECK_SOME(lastTaskStatus);
@@ -465,7 +465,7 @@ protected:
         path::join(launcherDir, MESOS_CONTAINERIZER),
         MesosContainerizerLaunch::NAME).get();
 
-    cout << "Running '" << commandString << "'" << endl;
+    LOG(INFO) << "Running '" << commandString << "'";
 
     // Fork the child using launcher.
     vector<string> argv(2);
@@ -594,7 +594,7 @@ protected:
         const string& name = variable.name();
         if (environment.contains(name) &&
             environment[name].value() != variable.value()) {
-          cout << "Overwriting environment variable '" << name << "'" << endl;
+          LOG(INFO) << "Overwriting environment variable '" << name << "'";
         }
         environment[name] = variable;
       }
@@ -610,7 +610,7 @@ protected:
         const string& name = variable.name();
         if (environment.contains(name) &&
             environment[name].value() != variable.value()) {
-          cout << "Overwriting environment variable '" << name << "'" << endl;
+          LOG(INFO) << "Overwriting environment variable '" << name << "'";
         }
         environment[name] = variable;
       }
@@ -621,7 +621,7 @@ protected:
       launchEnvironment.add_variables()->CopyFrom(variable);
     }
 
-    cout << "Starting task " << taskId.get() << endl;
+    LOG(INFO) << "Starting task " << taskId.get();
 
     pid = launchTaskSubprocess(
         command,
@@ -633,7 +633,7 @@ protected:
         workingDirectory,
         capabilities);
 
-    cout << "Forked command at " << pid << endl;
+    LOG(INFO) << "Forked command at " << pid;
 
     if (task.has_check()) {
       vector<string> namespaces;
@@ -659,7 +659,7 @@ protected:
 
       if (_checker.isError()) {
         // TODO(alexr): Consider ABORT and return a TASK_FAILED here.
-        cerr << "Failed to create checker: " << _checker.error() << endl;
+        LOG(ERROR) << "Failed to create checker: " << _checker.error();
       } else {
         checker = _checker.get();
       }
@@ -689,8 +689,8 @@ protected:
 
       if (_healthChecker.isError()) {
         // TODO(gilbert): Consider ABORT and return a TASK_FAILED here.
-        cerr << "Failed to create health checker: "
-             << _healthChecker.error() << endl;
+        LOG(ERROR) << "Failed to create health checker: "
+                   << _healthChecker.error();
       } else {
         healthChecker = _healthChecker.get();
       }
@@ -722,15 +722,15 @@ protected:
       gracePeriod = Nanoseconds(killPolicy->grace_period().nanoseconds());
     }
 
-    cout << "Received kill for task " << _taskId.value()
-         << " with grace period of " << gracePeriod << endl;
+    LOG(INFO) << "Received kill for task " << _taskId.value()
+              << " with grace period of " << gracePeriod;
 
     kill(_taskId, gracePeriod);
   }
 
   void shutdown()
   {
-    cout << "Shutting down" << endl;
+    LOG(INFO) << "Shutting down";
 
     // NOTE: We leave a small buffer of time to do the forced kill, otherwise
     // the agent may destroy the container before we can send `TASK_KILLED`.
@@ -801,8 +801,8 @@ private:
         ? gracePeriod - elapsed
         : Duration::zero();
 
-      cout << "Rescheduling escalation to SIGKILL in " << remaining
-           << " from now" << endl;
+      LOG(INFO) << "Rescheduling escalation to SIGKILL in " << remaining
+                << " from now";
 
       Clock::cancel(killGracePeriodTimer.get());
       killGracePeriodTimer = delay(
@@ -837,25 +837,25 @@ private:
       // Now perform signal escalation to begin killing the task.
       CHECK_GT(pid, 0);
 
-      cout << "Sending SIGTERM to process tree at pid " << pid << endl;
+      LOG(INFO) << "Sending SIGTERM to process tree at pid " << pid;
 
       Try<std::list<os::ProcessTree>> trees =
         os::killtree(pid, SIGTERM, true, true);
 
       if (trees.isError()) {
-        cerr << "Failed to kill the process tree rooted at pid " << pid
-             << ": " << trees.error() << endl;
+        LOG(ERROR) << "Failed to kill the process tree rooted at pid " << pid
+                   << ": " << trees.error();
 
         // Send SIGTERM directly to process 'pid' as it may not have
         // received signal before os::killtree() failed.
         os::kill(pid, SIGTERM);
       } else {
-        cout << "Sent SIGTERM to the following process trees:\n"
-             << stringify(trees.get()) << endl;
+        LOG(INFO) << "Sent SIGTERM to the following process trees:\n"
+                  << stringify(trees.get());
       }
 
-      cout << "Scheduling escalation to SIGKILL in " << gracePeriod
-           << " from now" << endl;
+      LOG(INFO) << "Scheduling escalation to SIGKILL in " << gracePeriod
+                << " from now";
 
       killGracePeriodTimer =
         delay(gracePeriod, self(), &Self::escalated, gracePeriod);
@@ -912,7 +912,7 @@ private:
       message = "Command " + WSTRINGIFY(status);
     }
 
-    cout << message << " (pid: " << pid << ")" << endl;
+    LOG(INFO) << message << " (pid: " << pid << ")";
 
     CHECK_SOME(taskId);
 
@@ -951,8 +951,8 @@ private:
       return;
     }
 
-    cout << "Process " << pid << " did not terminate after " << timeout
-         << ", sending SIGKILL to process tree at " << pid << endl;
+    LOG(INFO) << "Process " << pid << " did not terminate after " << timeout
+              << ", sending SIGKILL to process tree at " << pid;
 
     // TODO(nnielsen): Sending SIGTERM in the first stage of the
     // shutdown may leave orphan processes hanging off init. This
@@ -962,16 +962,16 @@ private:
       os::killtree(pid, SIGKILL, true, true);
 
     if (trees.isError()) {
-      cerr << "Failed to kill the process tree rooted at pid "
-           << pid << ": " << trees.error() << endl;
+      LOG(ERROR) << "Failed to kill the process tree rooted at pid "
+                 << pid << ": " << trees.error();
 
       // Process 'pid' may not have received signal before
       // os::killtree() failed. To make sure process 'pid' is reaped
       // we send SIGKILL directly.
       os::kill(pid, SIGKILL);
     } else {
-      cout << "Killed the following process trees:\n" << stringify(trees.get())
-           << endl;
+      LOG(INFO) << "Killed the following process trees:\n"
+                << stringify(trees.get());
     }
   }
 
@@ -1132,7 +1132,7 @@ private:
 } // namespace mesos {
 
 
-class Flags : public virtual flags::FlagsBase
+class Flags : public virtual mesos::internal::logging::Flags
 {
 public:
   Flags()
@@ -1212,6 +1212,8 @@ int main(int argc, char** argv)
     return EXIT_SUCCESS;
   }
 
+  mesos::internal::logging::initialize(argv[0], flags, true); // Catch signals.
+
   // Log any flag warnings (after logging is initialized).
   foreach (const flags::Warning& warning, load->warnings) {
     LOG(WARNING) << warning.message;
@@ -1242,9 +1244,9 @@ int main(int argc, char** argv)
   if (value.isSome()) {
     Try<Duration> parse = Duration::parse(value.get());
     if (parse.isError()) {
-      cerr << "Failed to parse value '" << value.get() << "'"
-           << " of 'MESOS_EXECUTOR_SHUTDOWN_GRACE_PERIOD': " << parse.error();
-      return EXIT_FAILURE;
+      EXIT(EXIT_FAILURE)
+        << "Failed to parse value '" << value.get() << "'"
+        << " of 'MESOS_EXECUTOR_SHUTDOWN_GRACE_PERIOD': " << parse.error();
     }
 
     shutdownGracePeriod = parse.get();


[4/4] mesos git commit: Added a TODO about glog initialization in master and slave main().

Posted by al...@apache.org.
Added a TODO about glog initialization in master and slave main().


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

Branch: refs/heads/master
Commit: cbae0ce07f39db58ef466245d7d4ad5412136f6d
Parents: e1e10d5
Author: Alexander Rukletsov <al...@apache.org>
Authored: Wed Jun 7 15:55:37 2017 +0200
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Wed Jun 7 15:55:37 2017 +0200

----------------------------------------------------------------------
 src/master/main.cpp | 1 +
 src/slave/main.cpp  | 6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/cbae0ce0/src/master/main.cpp
----------------------------------------------------------------------
diff --git a/src/master/main.cpp b/src/master/main.cpp
index 06c735e..1a78a55 100644
--- a/src/master/main.cpp
+++ b/src/master/main.cpp
@@ -252,6 +252,7 @@ int main(int argc, char** argv)
                        << "`main()` was not the function's first invocation";
   }
 
+  // TODO(alexr): This should happen before we start using glog, see MESOS-7586.
   logging::initialize(argv[0], flags, true); // Catch signals.
 
   // Log any flag warnings (after logging is initialized).

http://git-wip-us.apache.org/repos/asf/mesos/blob/cbae0ce0/src/slave/main.cpp
----------------------------------------------------------------------
diff --git a/src/slave/main.cpp b/src/slave/main.cpp
index 80a957b..66ae7db 100644
--- a/src/slave/main.cpp
+++ b/src/slave/main.cpp
@@ -265,10 +265,9 @@ int main(int argc, char** argv)
     return EXIT_SUCCESS;
   }
 
-  // TODO(marco): this pattern too should be abstracted away
-  // in FlagsBase; I have seen it at least 15 times.
   if (load.isError()) {
-    EXIT(EXIT_FAILURE) << flags.usage(load.error());
+    cerr << flags.usage(load.error()) << endl;
+    return EXIT_FAILURE;
   }
 
   // Check that agent's version has the expected format (SemVer).
@@ -355,6 +354,7 @@ int main(int argc, char** argv)
                        << "`main()` was not the function's first invocation";
   }
 
+  // TODO(alexr): This should happen before we start using glog, see MESOS-7586.
   logging::initialize(argv[0], flags, true); // Catch signals.
 
   // Log any flag warnings (after logging is initialized).


[2/4] mesos git commit: Added logging of flag warnings in the default executor.

Posted by al...@apache.org.
Added logging of flag warnings in the default executor.

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


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

Branch: refs/heads/master
Commit: cf71c5efaf0e6f5c269ce26b361b917d29c75ecc
Parents: c8178e0
Author: Andrei Budnik <ab...@mesosphere.com>
Authored: Wed Jun 7 15:17:55 2017 +0200
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Wed Jun 7 15:17:55 2017 +0200

----------------------------------------------------------------------
 src/launcher/default_executor.cpp | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/cf71c5ef/src/launcher/default_executor.cpp
----------------------------------------------------------------------
diff --git a/src/launcher/default_executor.cpp b/src/launcher/default_executor.cpp
index 55ce19d..91a4e1e 100644
--- a/src/launcher/default_executor.cpp
+++ b/src/launcher/default_executor.cpp
@@ -1366,6 +1366,11 @@ int main(int argc, char** argv)
 
   mesos::internal::logging::initialize(argv[0], flags, true); // Catch signals.
 
+  // Log any flag warnings (after logging is initialized).
+  foreach (const flags::Warning& warning, load->warnings) {
+    LOG(WARNING) << warning.message;
+  }
+
   Option<string> value = os::getenv("MESOS_FRAMEWORK_ID");
   if (value.isNone()) {
     EXIT(EXIT_FAILURE)


[3/4] mesos git commit: Reordered flags help and error checks for consistency in executors.

Posted by al...@apache.org.
Reordered flags help and error checks for consistency in executors.

We are inconsistent throughout our code base about what should happen
first: check for `--help` or check for errors. This patch makes the
behaviour consistent for major binaries: master, slave, built-in
executors. A general clean-up is addressed in MESOS-7586.


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

Branch: refs/heads/master
Commit: e1e10d55ff654050ea5628d0f3e6f8b398304958
Parents: cf71c5e
Author: Alexander Rukletsov <al...@apache.org>
Authored: Wed Jun 7 15:54:12 2017 +0200
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Wed Jun 7 15:54:12 2017 +0200

----------------------------------------------------------------------
 src/docker/executor.cpp   | 10 +++++-----
 src/launcher/executor.cpp | 10 +++++-----
 2 files changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/e1e10d55/src/docker/executor.cpp
----------------------------------------------------------------------
diff --git a/src/docker/executor.cpp b/src/docker/executor.cpp
index 82b4c87..e03f244 100644
--- a/src/docker/executor.cpp
+++ b/src/docker/executor.cpp
@@ -730,16 +730,16 @@ int main(int argc, char** argv)
   // Load flags from environment and command line.
   Try<flags::Warnings> load = flags.load(None(), &argc, &argv);
 
-  if (load.isError()) {
-    cerr << flags.usage(load.error()) << endl;
-    return EXIT_FAILURE;
-  }
-
   if (flags.help) {
     cout << flags.usage() << endl;
     return EXIT_SUCCESS;
   }
 
+  if (load.isError()) {
+    cerr << flags.usage(load.error()) << endl;
+    return EXIT_FAILURE;
+  }
+
   mesos::internal::logging::initialize(argv[0], flags, true); // Catch signals.
 
   // Log any flag warnings (after logging is initialized).

http://git-wip-us.apache.org/repos/asf/mesos/blob/e1e10d55/src/launcher/executor.cpp
----------------------------------------------------------------------
diff --git a/src/launcher/executor.cpp b/src/launcher/executor.cpp
index f5a46b5..a620678 100644
--- a/src/launcher/executor.cpp
+++ b/src/launcher/executor.cpp
@@ -1202,16 +1202,16 @@ int main(int argc, char** argv)
   // Load flags from command line.
   Try<flags::Warnings> load = flags.load(None(), &argc, &argv);
 
-  if (load.isError()) {
-    cerr << flags.usage(load.error()) << endl;
-    return EXIT_FAILURE;
-  }
-
   if (flags.help) {
     cout << flags.usage() << endl;
     return EXIT_SUCCESS;
   }
 
+  if (load.isError()) {
+    cerr << flags.usage(load.error()) << endl;
+    return EXIT_FAILURE;
+  }
+
   mesos::internal::logging::initialize(argv[0], flags, true); // Catch signals.
 
   // Log any flag warnings (after logging is initialized).