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 2018/08/21 20:30:10 UTC

[mesos] branch master updated: Skip the container if there's no container network.

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

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


The following commit(s) were added to refs/heads/master by this push:
     new e6828b7  Skip the container if there's no container network.
e6828b7 is described below

commit e6828b778ca3bcac0f1400049440661702668cc5
Author: Sergey Urbanovich <se...@gmail.com>
AuthorDate: Tue Aug 21 13:23:08 2018 -0700

    Skip the container if there's no container network.
    
    If the container wants to join host network it won't have container
    networks. In that case `rootDir` could be not configured and
    `rootDir.get()` in `usage()` will cause mesos agent crash.
    
    Review: https://reviews.apache.org/r/68448/
---
 src/slave/containerizer/mesos/isolators/network/cni/cni.cpp | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp b/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
index 6df52a5..ed47046 100644
--- a/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
+++ b/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
@@ -1513,6 +1513,16 @@ Future<ResourceStatistics> NetworkCniIsolatorProcess::usage(
     return ResourceStatistics();
   }
 
+  // Skip the container if there's no container network, e.g.
+  // container joins host network.
+  if (infos[containerId]->containerNetworks.empty()) {
+    return ResourceStatistics();
+  }
+
+  // If the `network/cni` isolator is providing network isolation to
+  // the container its `rootDir` should always be set.
+  CHECK_SOME(rootDir);
+
   const string netns = paths::getNamespacePath(rootDir.get(), containerId);
 
   // We collect networking statistics only for known interfaces.