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/09/27 05:04:28 UTC
[2/2] mesos git commit: Supported appc/runtime isolator to be nested
aware.
Supported appc/runtime isolator to be nested aware.
Review: https://reviews.apache.org/r/52005/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/31dfd182
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/31dfd182
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/31dfd182
Branch: refs/heads/master
Commit: 31dfd1828fda3fb8149420096801eee569f53841
Parents: 2f51bc5
Author: Gilbert Song <so...@gmail.com>
Authored: Mon Sep 26 22:04:21 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Mon Sep 26 22:04:21 2016 -0700
----------------------------------------------------------------------
.../mesos/isolators/appc/runtime.cpp | 68 +++++++++++---------
.../mesos/isolators/appc/runtime.hpp | 2 +
2 files changed, 38 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/31dfd182/src/slave/containerizer/mesos/isolators/appc/runtime.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/appc/runtime.cpp b/src/slave/containerizer/mesos/isolators/appc/runtime.cpp
index a96298b..b0782d9 100644
--- a/src/slave/containerizer/mesos/isolators/appc/runtime.cpp
+++ b/src/slave/containerizer/mesos/isolators/appc/runtime.cpp
@@ -40,8 +40,6 @@ using process::PID;
using mesos::slave::ContainerConfig;
using mesos::slave::ContainerLaunchInfo;
-using mesos::slave::ContainerLimitation;
-using mesos::slave::ContainerState;
using mesos::slave::Isolator;
namespace mesos {
@@ -56,6 +54,12 @@ AppcRuntimeIsolatorProcess::AppcRuntimeIsolatorProcess(const Flags& _flags)
AppcRuntimeIsolatorProcess::~AppcRuntimeIsolatorProcess() {}
+bool AppcRuntimeIsolatorProcess::supportsNesting()
+{
+ return true;
+}
+
+
Try<Isolator*> AppcRuntimeIsolatorProcess::create(const Flags& flags)
{
process::Owned<MesosIsolatorProcess> process(
@@ -69,13 +73,11 @@ Future<Option<ContainerLaunchInfo>> AppcRuntimeIsolatorProcess::prepare(
const ContainerID& containerId,
const mesos::slave::ContainerConfig& containerConfig)
{
- const ExecutorInfo& executorInfo = containerConfig.executor_info();
-
- if (!executorInfo.has_container()) {
+ if (!containerConfig.has_container_info()) {
return None();
}
- if (executorInfo.container().type() != ContainerInfo::MESOS) {
+ if (containerConfig.container_info().type() != ContainerInfo::MESOS) {
return Failure("Can only prepare Appc runtime for a MESOS container");
}
@@ -104,20 +106,13 @@ Future<Option<ContainerLaunchInfo>> AppcRuntimeIsolatorProcess::prepare(
}
// If working directory or command exists, operation has to be
- // distinguished for either custom executor or command task. For
- // custom executor case, info will be included in 'launchInfo', and
- // will be passed back to containerizer. For command task case, info
- // will be passed to command executor as flags.
- if (!containerConfig.has_task_info()) {
- // Custom executor case.
- if (workingDirectory.isSome()) {
- launchInfo.set_working_directory(workingDirectory.get());
- }
-
- if (command.isSome()) {
- launchInfo.mutable_command()->CopyFrom(command.get());
- }
- } else {
+ // handled specially for the command task. For the command task,
+ // the working directory and task command will be passed to
+ // command executor as flags. For custom executor, default
+ // executor and nested container cases, these information will
+ // be included in 'ContainerLaunchInfo', and will be passed back
+ // to containerizer.
+ if (containerConfig.has_task_info()) {
// Command task case. The 'executorCommand' below is the
// command with value as 'mesos-executor'.
CommandInfo executorCommand = containerConfig.executor_info().command();
@@ -137,6 +132,15 @@ Future<Option<ContainerLaunchInfo>> AppcRuntimeIsolatorProcess::prepare(
}
launchInfo.mutable_command()->CopyFrom(executorCommand);
+ } else {
+ // The custom executor, default executor and nested container cases.
+ if (workingDirectory.isSome()) {
+ launchInfo.set_working_directory(workingDirectory.get());
+ }
+
+ if (command.isSome()) {
+ launchInfo.mutable_command()->CopyFrom(command.get());
+ }
}
return launchInfo;
@@ -171,7 +175,7 @@ Option<Environment> AppcRuntimeIsolatorProcess::getLaunchEnvironment(
}
-// This method reads the CommandInfo from ExecutorInfo and optional
+// This method reads the CommandInfo from ContainerConfig and optional
// TaskInfo, and merge them with Appc image default 'exec'.
Result<CommandInfo> AppcRuntimeIsolatorProcess::getLaunchCommand(
const ContainerID& containerId,
@@ -182,22 +186,22 @@ Result<CommandInfo> AppcRuntimeIsolatorProcess::getLaunchCommand(
}
// We may or may not mutate the CommandInfo for executor depending
- // on the logic table below. For custom executor case, we make
- // changes to the command directly. For command task case, if no
- // need to change the launch command for the user task, we do not do
- // anything and return the CommandInfo from ExecutorInfo. We only
- // add a flag `--task_command` to carry command as a JSON object if
- // it is neccessary to mutate.
+ // on the logic table below. For custom executor, default executor
+ // and nested container cases, we make changes to the command
+ // directly. For command task case, if no need to change the launch
+ // command for the user task, we do not do anything and return the
+ // CommandInfo from ContainerConfig. We only add a flag
+ // `--task_command` to carry command as a JSON object if it is
+ // necessary to mutate.
CommandInfo command;
- if (!containerConfig.has_task_info()) {
- // Custom executor case.
- CHECK(containerConfig.executor_info().has_command());
- command = containerConfig.executor_info().command();
- } else {
+ if (containerConfig.has_task_info()) {
// Command task case.
CHECK(containerConfig.task_info().has_command());
command = containerConfig.task_info().command();
+ } else {
+ // Custom executor, default executor or nested container case.
+ command = containerConfig.command_info();
}
// We merge the CommandInfo following the logic:
http://git-wip-us.apache.org/repos/asf/mesos/blob/31dfd182/src/slave/containerizer/mesos/isolators/appc/runtime.hpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/appc/runtime.hpp b/src/slave/containerizer/mesos/isolators/appc/runtime.hpp
index c25b0ee..8d22587 100644
--- a/src/slave/containerizer/mesos/isolators/appc/runtime.hpp
+++ b/src/slave/containerizer/mesos/isolators/appc/runtime.hpp
@@ -33,6 +33,8 @@ public:
virtual ~AppcRuntimeIsolatorProcess();
+ virtual bool supportsNesting();
+
virtual process::Future<Option<mesos::slave::ContainerLaunchInfo>> prepare(
const ContainerID& containerId,
const mesos::slave::ContainerConfig& containerConfig);