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

qianzhang pushed a commit to branch 1.9.x
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 7e514dcbb96d951fae02484068286ceae8d34c4d
Author: Qian Zhang <zhq527...@gmail.com>
AuthorDate: Wed Sep 18 16:34:05 2019 +0800

    Gc'ed nested container sandbox only if we have root container sandbox.
    
    Review: https://reviews.apache.org/r/71501
---
 src/slave/containerizer/mesos/containerizer.cpp | 36 ++++++++++++++-----------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/src/slave/containerizer/mesos/containerizer.cpp 
b/src/slave/containerizer/mesos/containerizer.cpp
index 16149a1..c61b954 100644
--- a/src/slave/containerizer/mesos/containerizer.cpp
+++ b/src/slave/containerizer/mesos/containerizer.cpp
@@ -2963,10 +2963,12 @@ void MesosContainerizerProcess::______destroy(
 
       CHECK(containers_.contains(rootContainerId));
 
-      const string sandboxPath = containerizer::paths::getSandboxPath(
-        containers_[rootContainerId]->directory.get(), containerId);
+      if (containers_[rootContainerId]->directory.isSome()) {
+        const string sandboxPath = containerizer::paths::getSandboxPath(
+          containers_[rootContainerId]->directory.get(), containerId);
 
-      garbageCollect(sandboxPath);
+        garbageCollect(sandboxPath);
+      }
     }
   } else if (os::exists(runtimePath)) {
     Try<Nothing> rmdir = os::rmdir(runtimePath);
@@ -3083,21 +3085,23 @@ Future<Nothing> MesosContainerizerProcess::remove(
     }
   }
 
-  const string sandboxPath = containerizer::paths::getSandboxPath(
-      containers_[rootContainerId]->directory.get(), containerId);
+  if (containers_[rootContainerId]->directory.isSome()) {
+    const string sandboxPath = containerizer::paths::getSandboxPath(
+        containers_[rootContainerId]->directory.get(), containerId);
 
-  if (os::exists(sandboxPath)) {
-    // Unschedule the nested container sandbox from garbage collection
-    // to prevent potential double-deletion in future.
-    if (flags.gc_non_executor_container_sandboxes) {
-      CHECK_NOTNULL(gc);
-      gc->unschedule(sandboxPath);
-    }
+    if (os::exists(sandboxPath)) {
+      // Unschedule the nested container sandbox from garbage collection
+      // to prevent potential double-deletion in future.
+      if (flags.gc_non_executor_container_sandboxes) {
+        CHECK_NOTNULL(gc);
+        gc->unschedule(sandboxPath);
+      }
 
-    Try<Nothing> rmdir = os::rmdir(sandboxPath);
-    if (rmdir.isError()) {
-      return Failure(
-          "Failed to remove the sandbox directory: " + rmdir.error());
+      Try<Nothing> rmdir = os::rmdir(sandboxPath);
+      if (rmdir.isError()) {
+        return Failure(
+            "Failed to remove the sandbox directory: " + rmdir.error());
+      }
     }
   }
 

Reply via email to