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:33:08 UTC
[mesos] 01/02: 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 1.7.x
in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 821494e785cc215d605d3f4a0771e3a24fac59ec
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/
(cherry picked from commit e6828b778ca3bcac0f1400049440661702668cc5)
---
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.