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/14 01:26:56 UTC

mesos git commit: Added runtime isolator interface to run appc containers.

Repository: mesos
Updated Branches:
  refs/heads/master b23fc8b53 -> c2c3a2c65


Added runtime isolator interface to run appc containers.

Review: https://reviews.apache.org/r/49219/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/c2c3a2c6
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/c2c3a2c6
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/c2c3a2c6

Branch: refs/heads/master
Commit: c2c3a2c65145b8105ab4c7221d74ec0ec9b58420
Parents: b23fc8b
Author: Srinivas Brahmaroutu <sr...@us.ibm.com>
Authored: Wed Jul 13 18:26:49 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed Jul 13 18:26:49 2016 -0700

----------------------------------------------------------------------
 src/CMakeLists.txt                              |  1 +
 src/Makefile.am                                 |  2 +
 .../mesos/isolators/appc/runtime.cpp            | 99 ++++++++++++++++++++
 .../mesos/isolators/appc/runtime.hpp            | 61 ++++++++++++
 4 files changed, 163 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/c2c3a2c6/src/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 760519c..9d8a8ba 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -158,6 +158,7 @@ set(LINUX_SRC
   linux/perf.cpp
   linux/systemd.cpp
   slave/containerizer/mesos/linux_launcher.cpp
+  slave/containerizer/mesos/isolators/appc/runtime.cpp
   slave/containerizer/mesos/isolators/cgroups/cpushare.cpp
   slave/containerizer/mesos/isolators/cgroups/devices.cpp
   slave/containerizer/mesos/isolators/cgroups/mem.cpp

http://git-wip-us.apache.org/repos/asf/mesos/blob/c2c3a2c6/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 9f2b058..1d798d6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1044,6 +1044,7 @@ MESOS_LINUX_FILES =							\
   linux/perf.cpp							\
   linux/systemd.cpp							\
   slave/containerizer/mesos/linux_launcher.cpp				\
+  slave/containerizer/mesos/isolators/appc/runtime.cpp			\
   slave/containerizer/mesos/isolators/cgroups/cpushare.cpp		\
   slave/containerizer/mesos/isolators/cgroups/devices.cpp		\
   slave/containerizer/mesos/isolators/cgroups/mem.cpp			\
@@ -1072,6 +1073,7 @@ MESOS_LINUX_FILES +=							\
   linux/sched.hpp							\
   linux/systemd.hpp							\
   slave/containerizer/mesos/linux_launcher.hpp				\
+  slave/containerizer/mesos/isolators/appc/runtime.hpp			\
   slave/containerizer/mesos/isolators/cgroups/constants.hpp		\
   slave/containerizer/mesos/isolators/cgroups/cpushare.hpp		\
   slave/containerizer/mesos/isolators/cgroups/devices.hpp		\

http://git-wip-us.apache.org/repos/asf/mesos/blob/c2c3a2c6/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
new file mode 100644
index 0000000..19c68e8
--- /dev/null
+++ b/src/slave/containerizer/mesos/isolators/appc/runtime.cpp
@@ -0,0 +1,99 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <list>
+#include <string>
+
+#include <glog/logging.h>
+
+#include <stout/error.hpp>
+#include <stout/foreach.hpp>
+#include <stout/stringify.hpp>
+#include <stout/strings.hpp>
+
+#include "slave/flags.hpp"
+
+#include "slave/containerizer/mesos/isolators/appc/runtime.hpp"
+
+using std::list;
+using std::string;
+
+using process::Failure;
+using process::Future;
+using process::Owned;
+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 {
+namespace internal {
+namespace slave {
+
+AppcRuntimeIsolatorProcess::AppcRuntimeIsolatorProcess(const Flags& _flags)
+  : flags(_flags) {}
+
+
+AppcRuntimeIsolatorProcess::~AppcRuntimeIsolatorProcess() {}
+
+
+Try<Isolator*> AppcRuntimeIsolatorProcess::create(const Flags& flags)
+{
+  process::Owned<MesosIsolatorProcess> process(
+      new AppcRuntimeIsolatorProcess(flags));
+
+  return new MesosIsolator(process);
+}
+
+
+Future<Option<ContainerLaunchInfo>> AppcRuntimeIsolatorProcess::prepare(
+    const ContainerID& containerId,
+    const mesos::slave::ContainerConfig& containerConfig)
+{
+  return None();
+}
+
+
+Option<Environment> AppcRuntimeIsolatorProcess::getLaunchEnvironment(
+    const ContainerID& containerId,
+    const mesos::slave::ContainerConfig& containerConfig)
+{
+  return None();
+}
+
+
+// This method reads the CommandInfo from ExecutorInfo and optional
+// TaskInfo, and merge them with Appc image default 'exec'.
+Result<CommandInfo> AppcRuntimeIsolatorProcess::getLaunchCommand(
+    const ContainerID& containerId,
+    const mesos::slave::ContainerConfig& containerConfig)
+{
+  return None();
+}
+
+
+Option<string> AppcRuntimeIsolatorProcess::getWorkingDirectory(
+    const mesos::slave::ContainerConfig& containerConfig)
+{
+  return None();
+}
+
+} // namespace slave {
+} // namespace internal {
+} // namespace mesos {

http://git-wip-us.apache.org/repos/asf/mesos/blob/c2c3a2c6/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
new file mode 100644
index 0000000..c25b0ee
--- /dev/null
+++ b/src/slave/containerizer/mesos/isolators/appc/runtime.hpp
@@ -0,0 +1,61 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef __APPC_RUNTIME_ISOLATOR_HPP__
+#define __APPC_RUNTIME_ISOLATOR_HPP__
+
+#include "slave/containerizer/mesos/isolator.hpp"
+
+namespace mesos {
+namespace internal {
+namespace slave {
+
+// The Appc runtime isolator is responsible for preparing mesos
+// container by merging runtime configuration specified by user
+// and Appc image default configuration.
+class AppcRuntimeIsolatorProcess : public MesosIsolatorProcess
+{
+public:
+  static Try<mesos::slave::Isolator*> create(const Flags& flags);
+
+  virtual ~AppcRuntimeIsolatorProcess();
+
+  virtual process::Future<Option<mesos::slave::ContainerLaunchInfo>> prepare(
+      const ContainerID& containerId,
+      const mesos::slave::ContainerConfig& containerConfig);
+
+private:
+  AppcRuntimeIsolatorProcess(const Flags& flags);
+
+  Option<Environment> getLaunchEnvironment(
+      const ContainerID& containerId,
+      const mesos::slave::ContainerConfig& containerConfig);
+
+  Result<CommandInfo> getLaunchCommand(
+      const ContainerID& containerId,
+      const mesos::slave::ContainerConfig& containerConfig);
+
+  Option<std::string> getWorkingDirectory(
+      const mesos::slave::ContainerConfig& containerConfig);
+
+  const Flags flags;
+};
+
+} // namespace slave {
+} // namespace internal {
+} // namespace mesos {
+
+#endif // __APPC_RUNTIME_ISOLATOR_HPP__