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 2016/07/04 21:03:50 UTC
mesos git commit: Renamed 'commands' to 'pre_exec_commands' in
ContainerLaunchInfo.
Repository: mesos
Updated Branches:
refs/heads/master 29252ba26 -> deff8eb29
Renamed 'commands' to 'pre_exec_commands' in ContainerLaunchInfo.
Review: https://reviews.apache.org/r/49605/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/deff8eb2
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/deff8eb2
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/deff8eb2
Branch: refs/heads/master
Commit: deff8eb295cf115ab393d48cb2787e1ea6f1980c
Parents: 29252ba
Author: Gilbert Song <so...@gmail.com>
Authored: Mon Jul 4 14:03:33 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Mon Jul 4 14:03:33 2016 -0700
----------------------------------------------------------------------
include/mesos/slave/isolator.proto | 4 ++-
src/slave/containerizer/mesos/containerizer.cpp | 2 +-
.../mesos/isolators/docker/volume/isolator.cpp | 2 +-
.../mesos/isolators/filesystem/linux.cpp | 2 +-
.../mesos/isolators/filesystem/shared.cpp | 2 +-
.../mesos/isolators/namespaces/pid.cpp | 6 ++--
.../mesos/isolators/network/port_mapping.cpp | 2 +-
src/tests/containerizer/isolator_tests.cpp | 9 +++---
.../containerizer/mesos_containerizer_tests.cpp | 12 ++++----
src/tests/containerizer/port_mapping_tests.cpp | 31 ++++++++++----------
10 files changed, 39 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/deff8eb2/include/mesos/slave/isolator.proto
----------------------------------------------------------------------
diff --git a/include/mesos/slave/isolator.proto b/include/mesos/slave/isolator.proto
index 22be7c0..a971a58 100644
--- a/include/mesos/slave/isolator.proto
+++ b/include/mesos/slave/isolator.proto
@@ -105,7 +105,9 @@ message ContainerConfig {
* shell commands for the preparation commands.
*/
message ContainerLaunchInfo {
- repeated CommandInfo commands = 1;
+ // The additional preparation commands to execute before
+ // executing the command.
+ repeated CommandInfo pre_exec_commands = 1;
optional Environment environment = 2;
// The root filesystem for the container.
http://git-wip-us.apache.org/repos/asf/mesos/blob/deff8eb2/src/slave/containerizer/mesos/containerizer.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/containerizer.cpp b/src/slave/containerizer/mesos/containerizer.cpp
index 856dd82..f53b01b 100644
--- a/src/slave/containerizer/mesos/containerizer.cpp
+++ b/src/slave/containerizer/mesos/containerizer.cpp
@@ -1176,7 +1176,7 @@ Future<bool> MesosContainerizerProcess::__launch(
// Populate the list of additional commands to be run inside the container
// context.
- foreach (const CommandInfo& command, launchInfo->commands()) {
+ foreach (const CommandInfo& command, launchInfo->pre_exec_commands()) {
preExecCommands.values.emplace_back(JSON::protobuf(command));
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/deff8eb2/src/slave/containerizer/mesos/isolators/docker/volume/isolator.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/docker/volume/isolator.cpp b/src/slave/containerizer/mesos/isolators/docker/volume/isolator.cpp
index c72d360..96806a7 100644
--- a/src/slave/containerizer/mesos/isolators/docker/volume/isolator.cpp
+++ b/src/slave/containerizer/mesos/isolators/docker/volume/isolator.cpp
@@ -493,7 +493,7 @@ Future<Option<ContainerLaunchInfo>> DockerVolumeIsolatorProcess::_prepare(
const string command = "mount -n --rbind " + source + " " + target;
- launchInfo.add_commands()->set_value(command);
+ launchInfo.add_pre_exec_commands()->set_value(command);
}
return launchInfo;
http://git-wip-us.apache.org/repos/asf/mesos/blob/deff8eb2/src/slave/containerizer/mesos/isolators/filesystem/linux.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/filesystem/linux.cpp b/src/slave/containerizer/mesos/isolators/filesystem/linux.cpp
index 1f1ec0c..db3ed8f 100644
--- a/src/slave/containerizer/mesos/isolators/filesystem/linux.cpp
+++ b/src/slave/containerizer/mesos/isolators/filesystem/linux.cpp
@@ -291,7 +291,7 @@ Future<Option<ContainerLaunchInfo>> LinuxFilesystemIsolatorProcess::prepare(
return Failure("Failed to generate isolation script: " + _script.error());
}
- CommandInfo* command = launchInfo.add_commands();
+ CommandInfo* command = launchInfo.add_pre_exec_commands();
command->set_value(_script.get());
return update(containerId, containerConfig.executor_info().resources())
http://git-wip-us.apache.org/repos/asf/mesos/blob/deff8eb2/src/slave/containerizer/mesos/isolators/filesystem/shared.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/filesystem/shared.cpp b/src/slave/containerizer/mesos/isolators/filesystem/shared.cpp
index 1846806..51d1518 100644
--- a/src/slave/containerizer/mesos/isolators/filesystem/shared.cpp
+++ b/src/slave/containerizer/mesos/isolators/filesystem/shared.cpp
@@ -203,7 +203,7 @@ Future<Option<ContainerLaunchInfo>> SharedFilesystemIsolatorProcess::prepare(
}
}
- launchInfo.add_commands()->set_value(
+ launchInfo.add_pre_exec_commands()->set_value(
"mount -n --bind " + hostPath + " " + volume.container_path());
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/deff8eb2/src/slave/containerizer/mesos/isolators/namespaces/pid.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/namespaces/pid.cpp b/src/slave/containerizer/mesos/isolators/namespaces/pid.cpp
index bfc4698..b41e266 100644
--- a/src/slave/containerizer/mesos/isolators/namespaces/pid.cpp
+++ b/src/slave/containerizer/mesos/isolators/namespaces/pid.cpp
@@ -162,7 +162,7 @@ Future<Option<ContainerLaunchInfo>> NamespacesPidIsolatorProcess::prepare(
// Mask the bind mount root directory in each container so
// containers cannot see the namespace bind mount of other
// containers.
- launchInfo.add_commands()->set_value(
+ launchInfo.add_pre_exec_commands()->set_value(
"mount -n --bind " + string(PID_NS_BIND_MOUNT_MASK_DIR) +
" " + string(PID_NS_BIND_MOUNT_ROOT));
@@ -175,9 +175,9 @@ Future<Option<ContainerLaunchInfo>> NamespacesPidIsolatorProcess::prepare(
// taken from unshare.c in utils-linux for --mount-proc. We use the
// -n flag so the mount is not added to the mtab where it will not
// be correctly removed with the namespace terminates.
- launchInfo.add_commands()->set_value(
+ launchInfo.add_pre_exec_commands()->set_value(
"mount none /proc --make-private -o rec");
- launchInfo.add_commands()->set_value(
+ launchInfo.add_pre_exec_commands()->set_value(
"mount -n -t proc proc /proc -o nosuid,noexec,nodev");
return launchInfo;
http://git-wip-us.apache.org/repos/asf/mesos/blob/deff8eb2/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp b/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp
index 25d2a57..79ee960 100644
--- a/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp
+++ b/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp
@@ -2514,7 +2514,7 @@ Future<Option<ContainerLaunchInfo>> PortMappingIsolatorProcess::prepare(
<< executorInfo.executor_id() << "'";
ContainerLaunchInfo launchInfo;
- launchInfo.add_commands()->set_value(scripts(infos[containerId]));
+ launchInfo.add_pre_exec_commands()->set_value(scripts(infos[containerId]));
// NOTE: the port mapping isolator itself doesn't require mount
// namespace. However, if mount namespace is enabled because of
http://git-wip-us.apache.org/repos/asf/mesos/blob/deff8eb2/src/tests/containerizer/isolator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/isolator_tests.cpp b/src/tests/containerizer/isolator_tests.cpp
index 7b4d47b..4887473 100644
--- a/src/tests/containerizer/isolator_tests.cpp
+++ b/src/tests/containerizer/isolator_tests.cpp
@@ -1348,7 +1348,7 @@ TEST_F(SharedFilesystemIsolatorTest, DISABLED_ROOT_RelativeVolume)
AWAIT_READY(prepare);
ASSERT_SOME(prepare.get());
- ASSERT_EQ(1, prepare.get().get().commands().size());
+ ASSERT_EQ(1, prepare.get().get().pre_exec_commands().size());
EXPECT_TRUE(prepare.get().get().has_namespaces());
// The test will touch a file in container path.
@@ -1361,7 +1361,8 @@ TEST_F(SharedFilesystemIsolatorTest, DISABLED_ROOT_RelativeVolume)
args.push_back("sh");
args.push_back("-x");
args.push_back("-c");
- args.push_back(prepare.get().get().commands(0).value() + " && touch " + file);
+ args.push_back(
+ prepare.get().get().pre_exec_commands(0).value() + " && touch " + file);
Try<pid_t> pid = launcher->fork(
containerId,
@@ -1453,7 +1454,7 @@ TEST_F(SharedFilesystemIsolatorTest, DISABLED_ROOT_AbsoluteVolume)
AWAIT_READY(prepare);
ASSERT_SOME(prepare.get());
- ASSERT_EQ(1, prepare.get().get().commands().size());
+ ASSERT_EQ(1, prepare.get().get().pre_exec_commands().size());
EXPECT_TRUE(prepare.get().get().has_namespaces());
// Test the volume mounting by touching a file in the container's
@@ -1465,7 +1466,7 @@ TEST_F(SharedFilesystemIsolatorTest, DISABLED_ROOT_AbsoluteVolume)
args.push_back("sh");
args.push_back("-x");
args.push_back("-c");
- args.push_back(prepare.get().get().commands(0).value() +
+ args.push_back(prepare.get().get().pre_exec_commands(0).value() +
" && touch " +
path::join(containerPath, filename));
http://git-wip-us.apache.org/repos/asf/mesos/blob/deff8eb2/src/tests/containerizer/mesos_containerizer_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/mesos_containerizer_tests.cpp b/src/tests/containerizer/mesos_containerizer_tests.cpp
index 7ffec9e..57588cc 100644
--- a/src/tests/containerizer/mesos_containerizer_tests.cpp
+++ b/src/tests/containerizer/mesos_containerizer_tests.cpp
@@ -165,7 +165,7 @@ TEST_F(MesosContainerizerIsolatorPreparationTest, ScriptSucceeds)
Fetcher fetcher;
ContainerLaunchInfo launchInfo;
- launchInfo.add_commands()->set_value("touch " + file);
+ launchInfo.add_pre_exec_commands()->set_value("touch " + file);
Try<Owned<MesosContainerizer>> containerizer = CreateContainerizer(
&fetcher,
@@ -214,11 +214,13 @@ TEST_F(MesosContainerizerIsolatorPreparationTest, ScriptFails)
Fetcher fetcher;
ContainerLaunchInfo launchInfo;
- launchInfo.add_commands()->set_value("touch " + file + " && exit 1");
+ launchInfo.add_pre_exec_commands()->set_value(
+ "touch " + file + " && exit 1");
Try<Owned<MesosContainerizer>> containerizer = CreateContainerizer(
&fetcher,
launchInfo);
+
ASSERT_SOME(containerizer);
ContainerID containerId;
@@ -268,12 +270,12 @@ TEST_F(MesosContainerizerIsolatorPreparationTest, MultipleScripts)
// This isolator prepare command one will succeed if called first, otherwise
// it won't get run.
ContainerLaunchInfo launch1;
- launch1.add_commands()->set_value("touch " + file1 + " && exit 0");
+ launch1.add_pre_exec_commands()->set_value("touch " + file1 + " && exit 0");
launchInfos.push_back(launch1);
// This will fail, either first or after the successful command.
ContainerLaunchInfo launch2;
- launch2.add_commands()->set_value("touch " + file2 + " && exit 1");
+ launch2.add_pre_exec_commands()->set_value("touch " + file2 + " && exit 1");
launchInfos.push_back(launch2);
Fetcher fetcher;
@@ -698,7 +700,7 @@ TEST_F(MesosContainerizerDestroyTest, DestroyWhilePreparing)
// Need to help the compiler to disambiguate between overloads.
ContainerLaunchInfo launchInfo;
- launchInfo.add_commands()->CopyFrom(commandInfo);
+ launchInfo.add_pre_exec_commands()->CopyFrom(commandInfo);
Option<ContainerLaunchInfo> option = launchInfo;
promise.set(option);
http://git-wip-us.apache.org/repos/asf/mesos/blob/deff8eb2/src/tests/containerizer/port_mapping_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/port_mapping_tests.cpp b/src/tests/containerizer/port_mapping_tests.cpp
index eeb8938..3675c02 100644
--- a/src/tests/containerizer/port_mapping_tests.cpp
+++ b/src/tests/containerizer/port_mapping_tests.cpp
@@ -323,12 +323,13 @@ protected:
launchFlags.pipe_read = pipes[0];
launchFlags.pipe_write = pipes[1];
- if (launchInfo->commands().size() != 1) {
+ if (launchInfo->pre_exec_commands().size() != 1) {
return Error("No valid commands inside ContainerLaunchInfo.");
}
JSON::Array preExecCommands;
- preExecCommands.values.push_back(JSON::protobuf(launchInfo->commands(0)));
+ preExecCommands.values.push_back(JSON::protobuf(
+ launchInfo->pre_exec_commands(0)));
launchFlags.pre_exec_commands = preExecCommands;
@@ -473,7 +474,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_NC_ContainerToContainerTCP)
AWAIT_READY(launchInfo1);
ASSERT_SOME(launchInfo1.get());
- ASSERT_EQ(1, launchInfo1.get()->commands().size());
+ ASSERT_EQ(1, launchInfo1.get()->pre_exec_commands().size());
ostringstream command1;
@@ -542,7 +543,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_NC_ContainerToContainerTCP)
AWAIT_READY(launchInfo2);
ASSERT_SOME(launchInfo2.get());
- ASSERT_EQ(1, launchInfo2.get()->commands().size());
+ ASSERT_EQ(1, launchInfo2.get()->pre_exec_commands().size());
ostringstream command2;
@@ -636,7 +637,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_NC_ContainerToContainerUDP)
AWAIT_READY(launchInfo1);
ASSERT_SOME(launchInfo1.get());
- ASSERT_EQ(1, launchInfo1.get()->commands().size());
+ ASSERT_EQ(1, launchInfo1.get()->pre_exec_commands().size());
ostringstream command1;
@@ -705,7 +706,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_NC_ContainerToContainerUDP)
AWAIT_READY(launchInfo2);
ASSERT_SOME(launchInfo2.get());
- ASSERT_EQ(1, launchInfo2.get()->commands().size());
+ ASSERT_EQ(1, launchInfo2.get()->pre_exec_commands().size());
ostringstream command2;
@@ -801,7 +802,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_NC_HostToContainerUDP)
AWAIT_READY(launchInfo);
ASSERT_SOME(launchInfo.get());
- ASSERT_EQ(1, launchInfo.get()->commands().size());
+ ASSERT_EQ(1, launchInfo.get()->pre_exec_commands().size());
ostringstream command1;
@@ -919,7 +920,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_NC_HostToContainerTCP)
AWAIT_READY(launchInfo);
ASSERT_SOME(launchInfo.get());
- ASSERT_EQ(1, launchInfo.get()->commands().size());
+ ASSERT_EQ(1, launchInfo.get()->pre_exec_commands().size());
ostringstream command1;
@@ -1045,7 +1046,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_ContainerICMPExternal)
AWAIT_READY(launchInfo);
ASSERT_SOME(launchInfo.get());
- ASSERT_EQ(1, launchInfo.get()->commands().size());
+ ASSERT_EQ(1, launchInfo.get()->pre_exec_commands().size());
ostringstream command;
for (unsigned int i = 0; i < nameServers.size(); i++) {
@@ -1132,7 +1133,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_ContainerICMPInternal)
AWAIT_READY(launchInfo);
ASSERT_SOME(launchInfo.get());
- ASSERT_EQ(1, launchInfo.get()->commands().size());
+ ASSERT_EQ(1, launchInfo.get()->pre_exec_commands().size());
ostringstream command;
command << "ping -c1 127.0.0.1 && ping -c1 " << hostIP
@@ -1222,7 +1223,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_ContainerARPExternal)
AWAIT_READY(launchInfo);
ASSERT_SOME(launchInfo.get());
- ASSERT_EQ(1, launchInfo.get()->commands().size());
+ ASSERT_EQ(1, launchInfo.get()->pre_exec_commands().size());
ostringstream command;
for (unsigned int i = 0; i < nameServers.size(); i++) {
@@ -1318,7 +1319,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_DNS)
AWAIT_READY(launchInfo);
ASSERT_SOME(launchInfo.get());
- ASSERT_EQ(1, launchInfo.get()->commands().size());
+ ASSERT_EQ(1, launchInfo.get()->pre_exec_commands().size());
ostringstream command;
for (unsigned int i = 0; i < nameServers.size(); i++) {
@@ -1410,7 +1411,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_TooManyContainers)
AWAIT_READY(launchInfo1);
ASSERT_SOME(launchInfo1.get());
- ASSERT_EQ(1, launchInfo1.get()->commands().size());
+ ASSERT_EQ(1, launchInfo1.get()->pre_exec_commands().size());
ostringstream command1;
command1 << "sleep 1000";
@@ -1529,7 +1530,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_NC_SmallEgressLimit)
AWAIT_READY(launchInfo);
ASSERT_SOME(launchInfo.get());
- ASSERT_EQ(1, launchInfo.get()->commands().size());
+ ASSERT_EQ(1, launchInfo.get()->pre_exec_commands().size());
// Fill 'size' bytes of data. The actual content does not matter.
string data(size.bytes(), 'a');
@@ -1693,7 +1694,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_NC_PortMappingStatistics)
AWAIT_READY(launchInfo);
ASSERT_SOME(launchInfo.get());
- ASSERT_EQ(1, launchInfo.get()->commands().size());
+ ASSERT_EQ(1, launchInfo.get()->pre_exec_commands().size());
// Fill 'size' bytes of data. The actual content does not matter.
string data(size.bytes(), 'a');