You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2016/04/25 23:36:15 UTC
[34/48] mesos git commit: Added flag to disable systemd support.
Added flag to disable systemd support.
Review: https://reviews.apache.org/r/43582
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/8afbcc39
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/8afbcc39
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/8afbcc39
Branch: refs/heads/0.27.x
Commit: 8afbcc39d55a1e4525298098c0b74a260f5b8755
Parents: 531cb60
Author: Joris Van Remoortere <jo...@gmail.com>
Authored: Mon Feb 15 12:30:27 2016 -0500
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Tue Feb 16 18:21:10 2016 -0500
----------------------------------------------------------------------
docs/configuration.md | 12 ++++++++++++
src/linux/systemd.cpp | 15 ++++++++++++++-
src/linux/systemd.hpp | 1 +
src/slave/flags.cpp | 8 ++++++++
src/slave/flags.hpp | 1 +
src/slave/main.cpp | 3 ++-
6 files changed, 38 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/8afbcc39/docs/configuration.md
----------------------------------------------------------------------
diff --git a/docs/configuration.md b/docs/configuration.md
index b1ef131..29a6b65 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -866,6 +866,18 @@ file:///path/to/file (where file contains one of the above)</code></pre>
</tr>
<tr>
<td>
+ --[no-]systemd_enable_support
+ </td>
+ <td>
+ Top level control of systemd support. When enabled, features such as
+ executor life-time extension are enabled unless there is an explicit
+ flag to disable these (see other flags). This should be enabled when
+ the agent is launched as a systemd unit.
+ (default: true)
+ </td>
+ </tr>
+ <tr>
+ <td>
--systemd_runtime_directory=VALUE
</td>
<td>
http://git-wip-us.apache.org/repos/asf/mesos/blob/8afbcc39/src/linux/systemd.cpp
----------------------------------------------------------------------
diff --git a/src/linux/systemd.cpp b/src/linux/systemd.cpp
index 0142caf..0a9baa7 100644
--- a/src/linux/systemd.cpp
+++ b/src/linux/systemd.cpp
@@ -39,6 +39,13 @@ int DELEGATE_MINIMUM_VERSION = 218;
Flags::Flags()
{
+ add(&Flags::enabled,
+ "enabled",
+ "Top level control of systemd support. When enabled, features such as\n"
+ "processes life-time extension are enabled unless there is an explicit\n"
+ "flag to disable these (see other flags).",
+ true);
+
add(&Flags::runtime_directory,
"runtime_directory",
"The path to the systemd system run time directory\n",
@@ -108,6 +115,12 @@ Try<Nothing> initialize(const Flags& flags)
systemd_flags = new Flags(flags);
+ // Do not initialize any state if we do not have systemd support enabled.
+ if (!systemd_flags->enabled) {
+ initialized->done();
+ return Nothing();
+ }
+
// If flags->runtime_directory doesn't exist, then we can't proceed.
if (!os::exists(CHECK_NOTNULL(systemd_flags)->runtime_directory)) {
return Error("Failed to locate systemd runtime directory: " +
@@ -245,7 +258,7 @@ bool exists()
bool enabled()
{
- return exists() && systemd_flags != NULL;
+ return systemd_flags != NULL && flags().enabled && exists();
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/8afbcc39/src/linux/systemd.hpp
----------------------------------------------------------------------
diff --git a/src/linux/systemd.hpp b/src/linux/systemd.hpp
index d868fda..6b240b9 100644
--- a/src/linux/systemd.hpp
+++ b/src/linux/systemd.hpp
@@ -59,6 +59,7 @@ class Flags : public virtual flags::FlagsBase
public:
Flags();
+ bool enabled;
std::string runtime_directory;
std::string cgroups_hierarchy;
};
http://git-wip-us.apache.org/repos/asf/mesos/blob/8afbcc39/src/slave/flags.cpp
----------------------------------------------------------------------
diff --git a/src/slave/flags.cpp b/src/slave/flags.cpp
index 75d7429..2e88d74 100644
--- a/src/slave/flags.cpp
+++ b/src/slave/flags.cpp
@@ -386,6 +386,14 @@ mesos::internal::slave::Flags::Flags()
"supported by the cgroups/cpu isolator.",
true);
+ add(&Flags::systemd_enable_support,
+ "systemd_enable_support",
+ "Top level control of systemd support. When enabled, features such as\n"
+ "executor life-time extension are enabled unless there is an explicit\n"
+ "flag to disable these (see other flags). This should be enabled when\n"
+ "the agent is launched as a systemd unit.",
+ true);
+
add(&Flags::systemd_runtime_directory,
"systemd_runtime_directory",
"The path to the systemd system run time directory\n",
http://git-wip-us.apache.org/repos/asf/mesos/blob/8afbcc39/src/slave/flags.hpp
----------------------------------------------------------------------
diff --git a/src/slave/flags.hpp b/src/slave/flags.hpp
index 23ec158..1293397 100644
--- a/src/slave/flags.hpp
+++ b/src/slave/flags.hpp
@@ -92,6 +92,7 @@ public:
Duration perf_interval;
Duration perf_duration;
bool revocable_cpu_low_priority;
+ bool systemd_enable_support;
std::string systemd_runtime_directory;
#endif
Option<Firewall> firewall_rules;
http://git-wip-us.apache.org/repos/asf/mesos/blob/8afbcc39/src/slave/main.cpp
----------------------------------------------------------------------
diff --git a/src/slave/main.cpp b/src/slave/main.cpp
index ff406ac..a5d5976 100644
--- a/src/slave/main.cpp
+++ b/src/slave/main.cpp
@@ -228,10 +228,11 @@ int main(int argc, char** argv)
#ifdef __linux__
// Initialize systemd if it exists.
- if (systemd::exists()) {
+ if (systemd::exists() && flags.systemd_enable_support) {
LOG(INFO) << "Inializing systemd state";
systemd::Flags systemdFlags;
+ systemdFlags.enabled = flags.systemd_enable_support;
systemdFlags.runtime_directory = flags.systemd_runtime_directory;
systemdFlags.cgroups_hierarchy = flags.cgroups_hierarchy;