You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by al...@apache.org on 2018/08/28 14:48:43 UTC

[mesos] branch master updated (b02c054 -> 5fbfb8d)

This is an automated email from the ASF dual-hosted git repository.

alexr pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git.


    from b02c054  Added `cli_new` to the excluded directories for python2 mesos-style.py.
     new 8496b36  Added `AgentAPITest.LaunchNestedContainerWithUnknownParent` test.
     new 5fbfb8d  Cleaned up container on launch failures in composing containerizer.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/slave/containerizer/composing.cpp |  5 ++
 src/tests/api_tests.cpp               | 96 +++++++++++++++++++++++++++++++++++
 2 files changed, 101 insertions(+)


[mesos] 01/02: Added `AgentAPITest.LaunchNestedContainerWithUnknownParent` test.

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

alexr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 8496b369d52d27e90da88787242fd6f9d9abb78e
Author: Andrei Budnik <ab...@mesosphere.com>
AuthorDate: Tue Aug 28 16:46:54 2018 +0200

    Added `AgentAPITest.LaunchNestedContainerWithUnknownParent` test.
    
    This test verifies that launch nested container fails when the parent
    container is unknown to the containerizer.
    
    Review: https://reviews.apache.org/r/68234/
---
 src/tests/api_tests.cpp | 96 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 96 insertions(+)

diff --git a/src/tests/api_tests.cpp b/src/tests/api_tests.cpp
index ee82350..43541af 100644
--- a/src/tests/api_tests.cpp
+++ b/src/tests/api_tests.cpp
@@ -5972,6 +5972,102 @@ TEST_P_TEMP_DISABLED_ON_WINDOWS(
 }
 
 
+// This test verifies that launch nested container fails when the parent
+// container is unknown to the containerizer.
+TEST_P_TEMP_DISABLED_ON_WINDOWS(
+    AgentAPITest,
+    LaunchNestedContainerWithUnknownParent)
+{
+  Try<Owned<cluster::Master>> master = StartMaster();
+  ASSERT_SOME(master);
+
+  slave::Flags flags = CreateSlaveFlags();
+  Fetcher fetcher(flags);
+
+  Try<MesosContainerizer*> _containerizer =
+    MesosContainerizer::create(flags, false, &fetcher);
+
+  ASSERT_SOME(_containerizer);
+
+  Owned<slave::Containerizer> containerizer(_containerizer.get());
+  Owned<MasterDetector> detector = master.get()->createDetector();
+
+  Try<Owned<cluster::Slave>> slave =
+    StartSlave(detector.get(), containerizer.get(), flags);
+
+  ASSERT_SOME(slave);
+
+  MockScheduler sched;
+  MesosSchedulerDriver driver(
+      &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
+
+  EXPECT_CALL(sched, registered(&driver, _, _));
+
+  Future<vector<Offer>> offers;
+  EXPECT_CALL(sched, resourceOffers(&driver, _))
+    .WillOnce(FutureArg<1>(&offers));
+
+  driver.start();
+
+  AWAIT_READY(offers);
+  ASSERT_FALSE(offers->empty());
+
+  const Offer& offer = offers.get()[0];
+
+  Future<TaskStatus> statusStarting;
+  Future<TaskStatus> statusRunning;
+  EXPECT_CALL(sched, statusUpdate(_, _))
+    .WillOnce(FutureArg<1>(&statusStarting))
+    .WillOnce(FutureArg<1>(&statusRunning))
+    .WillRepeatedly(Return());
+
+  TaskInfo taskInfo = createTask(offer, "sleep 1000");
+
+  driver.acceptOffers({offer.id()}, {LAUNCH({taskInfo})});
+
+  AWAIT_READY(statusStarting);
+  ASSERT_EQ(TASK_STARTING, statusStarting->state());
+
+  AWAIT_READY(statusRunning);
+  ASSERT_EQ(TASK_RUNNING, statusRunning->state());
+
+  Future<hashset<ContainerID>> containerIds = containerizer->containers();
+  AWAIT_READY(containerIds);
+  ASSERT_EQ(1u, containerIds->size());
+
+  // Launch the child container with the random parent ContainerId.
+  v1::ContainerID containerId;
+  containerId.set_value(id::UUID::random().toString());
+  containerId.mutable_parent()->set_value(id::UUID::random().toString());
+
+  {
+    v1::agent::Call call;
+    call.set_type(v1::agent::Call::LAUNCH_NESTED_CONTAINER);
+
+    call.mutable_launch_nested_container()->mutable_container_id()
+      ->CopyFrom(containerId);
+
+    call.mutable_launch_nested_container()->mutable_command()
+      ->CopyFrom(v1::createCommandInfo("cat"));
+
+    call.mutable_launch_nested_container()->mutable_container()
+      ->set_type(mesos::v1::ContainerInfo::MESOS);
+
+    Future<http::Response> response = http::post(
+        slave.get()->pid,
+        "api/v1",
+        createBasicAuthHeaders(DEFAULT_CREDENTIAL),
+        serialize(ContentType::PROTOBUF, call),
+        stringify(ContentType::PROTOBUF));
+
+    AWAIT_EXPECT_RESPONSE_STATUS_EQ(http::BadRequest().status, response);
+  }
+
+  driver.stop();
+  driver.join();
+}
+
+
 // This test verifies that launching a nested container session results
 // in stdout and stderr being streamed correctly.
 TEST_P_TEMP_DISABLED_ON_WINDOWS(AgentAPITest, LaunchNestedContainerSession)


[mesos] 02/02: Cleaned up container on launch failures in composing containerizer.

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

alexr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 5fbfb8da5ad62c40752fa7b7e0a0842c892f6857
Author: Andrei Budnik <ab...@mesosphere.com>
AuthorDate: Tue Aug 28 16:47:04 2018 +0200

    Cleaned up container on launch failures in composing containerizer.
    
    Previously, if a parent container was unknown to the composing
    containerizer during an attempt to launch a nested container
    via `ComposingContainerizerProcess::launch()`, the composing
    containerizer returned an error without cleaning up the container.
    The `containerizer` field was uninitialized, so a further attempt
    to remove or destroy the nested container led to segfault.
    
    This patch removes the container when the parent container is unknown.
    
    Review: https://reviews.apache.org/r/68235/
---
 src/slave/containerizer/composing.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/slave/containerizer/composing.cpp b/src/slave/containerizer/composing.cpp
index 5216458..d854794 100644
--- a/src/slave/containerizer/composing.cpp
+++ b/src/slave/containerizer/composing.cpp
@@ -445,6 +445,11 @@ Future<Containerizer::LaunchResult> ComposingContainerizerProcess::launch(
   if (containerId.has_parent()) {
     ContainerID rootContainerId = protobuf::getRootContainerId(containerId);
     if (!containers_.contains(rootContainerId)) {
+      // We do cleanup here, otherwise we cannot remove or destroy the nested
+      // container due to its undefined `containerizer` field.
+      containers_.erase(containerId);
+      delete container;
+
       return Failure(
           "Root container " + stringify(rootContainerId) + " not found");
     }