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 2017/02/08 01:40:51 UTC

[5/6] mesos git commit: Disabled ability to launch default executor with ContainerInfo.

Disabled ability to launch default executor with ContainerInfo.

The default executor used to launch TaskGroups is generated by the
agent.  The agent generates the executor's `CommandInfo`, hence why
the user may not specify the `CommandInfo` in the `LAUNCH_TASK_GROUP`
call.

This commit adds similar restrictions for `ContainerInfo` plus the
default executor.  The `CommandInfo` constructed by the agent expects
to be run in the same environment as the agent process.  This commit
prevents the user from specifying a `DockerInfo` or a container image
along with the default executor.

If the user explicitly wants to use the default executor, they could
always package the default executor's binary and libraries into a
container and launch it like any other custom executor.

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


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

Branch: refs/heads/master
Commit: 90afbfd93e8bdb71ee0f79fbd0cfff06fd22ae63
Parents: f7a77bf
Author: Joseph Wu <jo...@apache.org>
Authored: Thu Feb 2 18:18:59 2017 -0800
Committer: Joseph Wu <jo...@apache.org>
Committed: Tue Feb 7 17:35:22 2017 -0800

----------------------------------------------------------------------
 include/mesos/mesos.proto             |  3 +++
 include/mesos/v1/mesos.proto          |  3 +++
 src/master/validation.cpp             | 14 ++++++++++++
 src/tests/master_validation_tests.cpp | 35 ++++++++++++++++++++++++++++--
 4 files changed, 53 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/90afbfd9/include/mesos/mesos.proto
----------------------------------------------------------------------
diff --git a/include/mesos/mesos.proto b/include/mesos/mesos.proto
index 53885cb..34a288b 100644
--- a/include/mesos/mesos.proto
+++ b/include/mesos/mesos.proto
@@ -652,6 +652,9 @@ message ExecutorInfo {
     //
     // 2) Default executor only accepts a *single* `LAUNCH` or `LAUNCH_GROUP`
     //    offer operation.
+    //
+    // 3) If `container` is set, `container.type` must be `MESOS`
+    //    and `container.mesos.image` must not be set.
     DEFAULT = 1;
 
     // For frameworks that need custom functionality to run tasks, a `CUSTOM`

http://git-wip-us.apache.org/repos/asf/mesos/blob/90afbfd9/include/mesos/v1/mesos.proto
----------------------------------------------------------------------
diff --git a/include/mesos/v1/mesos.proto b/include/mesos/v1/mesos.proto
index c4ca6de..6638111 100644
--- a/include/mesos/v1/mesos.proto
+++ b/include/mesos/v1/mesos.proto
@@ -652,6 +652,9 @@ message ExecutorInfo {
     //
     // 2) Default executor only accepts a *single* `LAUNCH` or `LAUNCH_GROUP`
     //    offer operation.
+    //
+    // 3) If `container` is set, `container.type` must be `MESOS`
+    //    and `container.mesos.image` must not be set.
     DEFAULT = 1;
 
     // For frameworks that need custom functionality to run tasks, a `CUSTOM`

http://git-wip-us.apache.org/repos/asf/mesos/blob/90afbfd9/src/master/validation.cpp
----------------------------------------------------------------------
diff --git a/src/master/validation.cpp b/src/master/validation.cpp
index 226c526..37d1715 100644
--- a/src/master/validation.cpp
+++ b/src/master/validation.cpp
@@ -629,6 +629,20 @@ Option<Error> validateType(const ExecutorInfo& executor)
         return Error(
             "'ExecutorInfo.command' must not be set for 'DEFAULT' executor");
       }
+
+      if (executor.has_container()) {
+        if (executor.container().type() != ContainerInfo::MESOS) {
+          return Error(
+              "'ExecutorInfo.container.type' must be 'MESOS' for "
+              "'DEFAULT' executor");
+        }
+
+        if (executor.container().mesos().has_image()) {
+          return Error(
+              "'ExecutorInfo.container.mesos.image' must not be set for "
+              "'DEFAULT' executor");
+        }
+      }
       break;
 
     case ExecutorInfo::CUSTOM:

http://git-wip-us.apache.org/repos/asf/mesos/blob/90afbfd9/src/tests/master_validation_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/master_validation_tests.cpp b/src/tests/master_validation_tests.cpp
index 1f833aa..5118503 100644
--- a/src/tests/master_validation_tests.cpp
+++ b/src/tests/master_validation_tests.cpp
@@ -1987,6 +1987,37 @@ TEST_F(ExecutorValidationTest, ExecutorType)
         error->message,
         "'ExecutorInfo.command' must not be set for 'DEFAULT' executor"));
   }
+
+  {
+    // 'DEFAULT' executor with `ContainerInfo` must be a Mesos container.
+    executorInfo.set_type(ExecutorInfo::DEFAULT);
+    executorInfo.clear_command();
+    executorInfo.mutable_container()->set_type(ContainerInfo::DOCKER);
+
+    Option<Error> error = ::executor::internal::validateType(executorInfo);
+
+    EXPECT_SOME(error);
+    EXPECT_TRUE(strings::contains(
+        error->message,
+        "'ExecutorInfo.container.type' must be 'MESOS' for "
+        "'DEFAULT' executor"));
+  }
+
+  {
+    // 'DEFAULT' executor with `ContainerInfo` may not have a container image.
+    executorInfo.set_type(ExecutorInfo::DEFAULT);
+    executorInfo.clear_command();
+    executorInfo.mutable_container()->set_type(ContainerInfo::MESOS);
+    executorInfo.mutable_container()->mutable_mesos()->mutable_image();
+
+    Option<Error> error = ::executor::internal::validateType(executorInfo);
+
+    EXPECT_SOME(error);
+    EXPECT_TRUE(strings::contains(
+        error->message,
+        "'ExecutorInfo.container.mesos.image' must not be set for "
+        "'DEFAULT' executor"));
+  }
 }
 
 
@@ -2265,14 +2296,14 @@ TEST_F(TaskGroupValidationTest, ExecutorUsesDockerContainerInfo)
   EXPECT_EQ(TASK_ERROR, task1Status->state());
   EXPECT_EQ(TaskStatus::REASON_TASK_GROUP_INVALID, task1Status->reason());
   EXPECT_EQ(
-      "Docker ContainerInfo is not supported on the executor",
+      "'ExecutorInfo.container.type' must be 'MESOS' for 'DEFAULT' executor",
       task1Status->message());
 
   AWAIT_READY(task2Status);
   EXPECT_EQ(TASK_ERROR, task2Status->state());
   EXPECT_EQ(TaskStatus::REASON_TASK_GROUP_INVALID, task2Status->reason());
   EXPECT_EQ(
-      "Docker ContainerInfo is not supported on the executor",
+      "'ExecutorInfo.container.type' must be 'MESOS' for 'DEFAULT' executor",
       task2Status->message());
 
   // Make sure the task is not known to master anymore.