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

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

commit 4941bf445902d519dda4943518016f269482a0b7
Author: Qian Zhang <[email protected]>
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 0432448..7d553bf 100644
--- a/src/slave/containerizer/mesos/containerizer.cpp
+++ b/src/slave/containerizer/mesos/containerizer.cpp
@@ -2919,10 +2919,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);
@@ -3039,21 +3041,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