You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2017/06/17 04:11:17 UTC
[12/13] mesos git commit: Rename the `--allowed_capabilities` flag to
`--effective_capabilities`.
Rename the `--allowed_capabilities` flag to `--effective_capabilities`.
Since the `--allowed_capabilities` flag was being used to actually
grant capabilities, rename it to `--effective_capabilities` which better
conveys the intention and semantics of this flag.
Review: https://reviews.apache.org/r/59554/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/1496243d
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/1496243d
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/1496243d
Branch: refs/heads/master
Commit: 1496243d46ec47b9885a267f0291cbd11e25bf8c
Parents: 32e605e
Author: James Peach <jp...@apache.org>
Authored: Fri Jun 16 20:45:03 2017 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Jun 16 21:01:33 2017 -0700
----------------------------------------------------------------------
docs/configuration.md | 16 ++++-------
docs/linux_capabilities.md | 10 +++----
.../mesos/isolators/linux/capabilities.cpp | 10 ++++---
src/slave/flags.cpp | 29 ++++++++------------
src/slave/flags.hpp | 2 +-
.../linux_capabilities_isolator_tests.cpp | 17 ++++++------
6 files changed, 38 insertions(+), 46 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/1496243d/docs/configuration.md
----------------------------------------------------------------------
diff --git a/docs/configuration.md b/docs/configuration.md
index ed510fa..e2a1a2e 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -1019,24 +1019,18 @@ cgroup.
</tr>
<tr>
<td>
- --allowed_capabilities=VALUE
+ --effective_capabilities=VALUE
</td>
<td>
-JSON representation of system capabilities that the operator allows for
-tasks run in containers launched by the containerizer (currently only
+JSON representation of the Linux capabilities the that the agent will grant
+to tasks run in containers launched by the containerizer (currently only
supported by the Mesos Containerizer). This set overrides the default
capabilities requested by the framework.
<p/>
-The net capability for a task running in the container will be:
-<pre><code>((F & A) & U)</code>
- where F = capabilities requested by the framework.
- A = allowed capabilities specified by this flag.
- U = permitted capabilities for the agent process.
-</pre>
To set capabilities the agent should have the <code>SETPCAP</code> capability.
<p/>
-This flag is effective iff <code>capabilities</code> isolation is enabled.
-When <code>capabilities</code> isolation is enabled, the absence of this flag
+This flag is effective iff <code>linux/capabilities</code> isolation is enabled.
+When <code>linux/capabilities</code> isolation is enabled, the absence of this flag
implies that the operator intends to allow ALL capabilities.
<p/>
Example:
http://git-wip-us.apache.org/repos/asf/mesos/blob/1496243d/docs/linux_capabilities.md
----------------------------------------------------------------------
diff --git a/docs/linux_capabilities.md b/docs/linux_capabilities.md
index b588aff..75dc0c0 100644
--- a/docs/linux_capabilities.md
+++ b/docs/linux_capabilities.md
@@ -20,7 +20,7 @@ list of currently exposed capabilities.
The Linux capabilities isolator is loaded when `linux/capabilities` is
present in the agent's `--isolation` flag.
Capabilities which should be allowed are passed with the
-`--allowed_capabilities` flag. This isolator requires the
+`--effective_capabilities` flag. This isolator requires the
`CAP_SETPCAP` capability so agent processes typically need to be
started as root. A possible agent startup invocation could be
@@ -28,12 +28,12 @@ started as root. A possible agent startup invocation could be
sudo mesos-agent --master=<master ip> --ip=<agent ip>
--work_dir=/var/lib/mesos
--isolation=linux/capabilities[,other isolation flags]
- --allowed_capabilities='{"capabilities":[NET_RAW,MKNOD]}'
+ --effective_capabilities='{"capabilities":[NET_RAW,MKNOD]}'
```
-An empty list for `--allowed_capabilities` signifies that no
-capabilities are allowed, while an absent `--allowed_capabilities` flag
-signifies that all capabilities are allowed.
+An empty list for `--effective_capabilities` signifies that no
+capabilities are allowed, while an absent `--effective_capabilities`
+flag signifies that all capabilities are allowed.
## Task setup
http://git-wip-us.apache.org/repos/asf/mesos/blob/1496243d/src/slave/containerizer/mesos/isolators/linux/capabilities.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/linux/capabilities.cpp b/src/slave/containerizer/mesos/isolators/linux/capabilities.cpp
index 26676ff..ff7b9f1 100644
--- a/src/slave/containerizer/mesos/isolators/linux/capabilities.cpp
+++ b/src/slave/containerizer/mesos/isolators/linux/capabilities.cpp
@@ -56,10 +56,12 @@ Try<Isolator*> LinuxCapabilitiesIsolatorProcess::create(const Flags& flags)
return Error("Failed to initialize capabilities: " + create.error());
}
- if (flags.allowed_capabilities.isSome() &&
+ if (flags.effective_capabilities.isSome() &&
flags.bounding_capabilities.isSome()) {
- const set<Capability> bounding = convert(flags.bounding_capabilities.get());
- const set<Capability> effective = convert(flags.allowed_capabilities.get());
+ const set<Capability> bounding = convert(
+ flags.bounding_capabilities.get());
+ const set<Capability> effective = convert(
+ flags.effective_capabilities.get());
if ((effective & bounding).size() != effective.size()) {
return Error(
@@ -95,7 +97,7 @@ Future<Option<ContainerLaunchInfo>> LinuxCapabilitiesIsolatorProcess::prepare(
// If the framework didn't specify, use the operator effective set.
if (effective.isNone()) {
- effective = flags.allowed_capabilities;
+ effective = flags.effective_capabilities;
}
// TODO(jpeach): MESOS-7671: If the framework specified a bounding set,
http://git-wip-us.apache.org/repos/asf/mesos/blob/1496243d/src/slave/flags.cpp
----------------------------------------------------------------------
diff --git a/src/slave/flags.cpp b/src/slave/flags.cpp
index 37d2f3f..c84aa67 100644
--- a/src/slave/flags.cpp
+++ b/src/slave/flags.cpp
@@ -587,25 +587,20 @@ mesos::internal::slave::Flags::Flags()
"The path to the systemd system run time directory\n",
"/run/systemd/system");
- add(&Flags::allowed_capabilities,
- "allowed_capabilities",
- "JSON representation of system capabilities that the operator\n"
- "allows tasks run in containers launched by the containerizer\n"
- "(currently only supported by the Mesos Containerizer). This set\n"
- "overrides the default capabilities for the user and the\n"
- "capabilities requested by the framework.\n"
- "\n"
- "The net capability for a task running in the container will be:\n"
- " ((F & A) & U)\n"
- " where F = capabilities requested by the framework.\n"
- " A = allowed capabilities specified by this flag.\n"
- " U = permitted capabilities for the agent process.\n"
+ add(&Flags::effective_capabilities,
+ "effective_capabilities",
+ flags::DeprecatedName("allowed_capabilities"),
+ "JSON representation of the Linux capabilities that the agent will\n"
+ "grant to a task that will be run in containers launched by the\n"
+ "containerizer (currently only supported by the Mesos Containerizer).\n"
+ "This set overrides the default capabilities for the user but not\n"
+ "the capabilities requested by the framework.\n"
"\n"
"To set capabilities the agent should have the `SETPCAP` capability.\n"
"\n"
- "This flag is effective iff `capabilities` isolation is enabled.\n"
- "When `capabilities` isolation is enabled, the absence of this flag\n"
- "implies that the operator intends to allow ALL capabilities.\n"
+ "This flag is effective iff `linux/capabilities` isolation is enabled.\n"
+ "When `linux/capabilities` isolation is enabled, the absence of this\n"
+ "flag implies that the operator intends to allow ALL capabilities.\n"
"\n"
"Example:\n"
"{\n"
@@ -626,7 +621,7 @@ mesos::internal::slave::Flags::Flags()
"When `linux/capabilities` isolation is enabled, the absence of this\n"
"flag implies that the operator allows ALL capabilities.\n"
"\n"
- "This flag has the same syntax as `--allowed_capabilities`."
+ "This flag has the same syntax as `--effective_capabilities`."
);
#endif
http://git-wip-us.apache.org/repos/asf/mesos/blob/1496243d/src/slave/flags.hpp
----------------------------------------------------------------------
diff --git a/src/slave/flags.hpp b/src/slave/flags.hpp
index 578ea0f..e75c1b4 100644
--- a/src/slave/flags.hpp
+++ b/src/slave/flags.hpp
@@ -110,7 +110,7 @@ public:
bool revocable_cpu_low_priority;
bool systemd_enable_support;
std::string systemd_runtime_directory;
- Option<CapabilityInfo> allowed_capabilities;
+ Option<CapabilityInfo> effective_capabilities;
Option<CapabilityInfo> bounding_capabilities;
#endif
Option<Firewall> firewall_rules;
http://git-wip-us.apache.org/repos/asf/mesos/blob/1496243d/src/tests/containerizer/linux_capabilities_isolator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/linux_capabilities_isolator_tests.cpp b/src/tests/containerizer/linux_capabilities_isolator_tests.cpp
index ba510fb..31fc54e 100644
--- a/src/tests/containerizer/linux_capabilities_isolator_tests.cpp
+++ b/src/tests/containerizer/linux_capabilities_isolator_tests.cpp
@@ -185,7 +185,7 @@ TEST_P(LinuxCapabilitiesIsolatorTest, ROOT_Ping)
slave::Flags flags = CreateSlaveFlags();
flags.isolation = "linux/capabilities";
- flags.allowed_capabilities = param.allowed;
+ flags.effective_capabilities = param.allowed;
flags.bounding_capabilities = param.allowed;
if (param.useImage == TestParam::WITH_IMAGE) {
@@ -395,38 +395,39 @@ TEST_F(LinuxCapabilitiesIsolatorFlagsTest, ROOT_IsolatorFlags)
Try<Owned<cluster::Slave>> slave = Owned<cluster::Slave>();
+
// Allowed is not a subset of bounding, so this should fail.
- flags.allowed_capabilities = convert(set<Capability>({NET_RAW, NET_ADMIN}));
+ flags.effective_capabilities = convert(set<Capability>({NET_RAW, NET_ADMIN}));
flags.bounding_capabilities = convert(set<Capability>({NET_RAW}));
slave = StartSlave(&detector, flags);
ASSERT_ERROR(slave);
// Allowed is the same as bounding, which is OK.
- flags.allowed_capabilities = convert(set<Capability>({NET_RAW, NET_ADMIN}));
+ flags.effective_capabilities = convert(set<Capability>({NET_RAW, NET_ADMIN}));
flags.bounding_capabilities = convert(set<Capability>({NET_RAW, NET_ADMIN}));
slave = StartSlave(&detector, flags);
ASSERT_SOME(slave);
// Allowed is a subset of bounding, which is OK.
- flags.allowed_capabilities = convert(set<Capability>({NET_RAW}));
+ flags.effective_capabilities = convert(set<Capability>({NET_RAW}));
flags.bounding_capabilities = convert(set<Capability>({NET_RAW, NET_ADMIN}));
slave = StartSlave(&detector, flags);
ASSERT_SOME(slave);
// Both sets are allowed to be missing.
- flags.allowed_capabilities = None();
+ flags.effective_capabilities = None();
flags.bounding_capabilities = None();
slave = StartSlave(&detector, flags);
ASSERT_SOME(slave);
// Bounding capabilities are allowed to be missing.
- flags.allowed_capabilities = convert(set<Capability>({NET_RAW}));
+ flags.effective_capabilities = convert(set<Capability>({NET_RAW}));
flags.bounding_capabilities = None();
slave = StartSlave(&detector, flags);
ASSERT_SOME(slave);
- // Allowed capabilities are allowed to be missing.
- flags.allowed_capabilities = None();
+ // Effective capabilities are allowed to be missing.
+ flags.effective_capabilities = None();
flags.bounding_capabilities = convert(set<Capability>({NET_RAW}));
slave = StartSlave(&detector, flags);
ASSERT_SOME(slave);