You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2016/02/15 19:56:45 UTC
mesos git commit: Added flag to disable systemd support.
Repository: mesos
Updated Branches:
refs/heads/master e7e6ed610 -> 0c53a34e3
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/0c53a34e
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/0c53a34e
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/0c53a34e
Branch: refs/heads/master
Commit: 0c53a34e35c2bd345251281c21a5932448c34683
Parents: e7e6ed6
Author: Joris Van Remoortere <jo...@gmail.com>
Authored: Mon Feb 15 12:30:27 2016 -0500
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Mon Feb 15 13:47:48 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/0c53a34e/docs/configuration.md
----------------------------------------------------------------------
diff --git a/docs/configuration.md b/docs/configuration.md
index eea985c..3d82368 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -1508,6 +1508,18 @@ therefore the flag currently does not exist on that platform. (default: true)
</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/0c53a34e/src/linux/systemd.cpp
----------------------------------------------------------------------
diff --git a/src/linux/systemd.cpp b/src/linux/systemd.cpp
index 13b5c82..e120d2c 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/0c53a34e/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/0c53a34e/src/slave/flags.cpp
----------------------------------------------------------------------
diff --git a/src/slave/flags.cpp b/src/slave/flags.cpp
index 14ad4dc..46ccf7f 100644
--- a/src/slave/flags.cpp
+++ b/src/slave/flags.cpp
@@ -389,6 +389,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/0c53a34e/src/slave/flags.hpp
----------------------------------------------------------------------
diff --git a/src/slave/flags.hpp b/src/slave/flags.hpp
index 20232d6..3704376 100644
--- a/src/slave/flags.hpp
+++ b/src/slave/flags.hpp
@@ -93,6 +93,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/0c53a34e/src/slave/main.cpp
----------------------------------------------------------------------
diff --git a/src/slave/main.cpp b/src/slave/main.cpp
index 222198c..e3a4d13 100644
--- a/src/slave/main.cpp
+++ b/src/slave/main.cpp
@@ -236,10 +236,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;