You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by qi...@apache.org on 2019/08/06 02:06:38 UTC
[mesos] 01/02: Looked up parent's IP for the non-checkpointed
nested containers.
This is an automated email from the ASF dual-hosted git repository.
qianzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git
commit b76d19aff3419cf684ad64f0ca1fe35bf100f884
Author: Qian Zhang <zh...@gmail.com>
AuthorDate: Sat Jul 27 15:34:23 2019 +0800
Looked up parent's IP for the non-checkpointed nested containers.
Review: https://reviews.apache.org/r/71172
---
.../containerizer/mesos/isolators/network/cni/cni.cpp | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp b/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
index f2989cf..8d03733 100644
--- a/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
+++ b/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
@@ -1437,12 +1437,29 @@ Future<Nothing> NetworkCniIsolatorProcess::_attach(
Future<ContainerStatus> NetworkCniIsolatorProcess::status(
const ContainerID& containerId)
{
+ const bool isNestedContainer = containerId.has_parent();
+
// TODO(jieyu): We don't create 'Info' struct for containers that
// want to join the host network and have no image. Currently, we
// rely on the slave/containerizer to set the IP addresses in
// ContainerStatus. Consider returning the IP address of the slave
// here.
if (!infos.contains(containerId)) {
+ if (isNestedContainer) {
+ // There are two cases that `infos` does not contain a nested container:
+ // 1. The nested container has no image and joins host network (i.e.,
+ // it does not specify `NetworkInfo.name` and its parent joins host
+ // network). In this case, we do not create `Info` struct for this
+ // nested container.
+ // 2. The nested container joins the CNI network that its parent joins,
+ // and then agent is restarted. After recovery `infos` will not
+ // contain the nested container since we do not checkpoint it in the
+ // runtime directory.
+ // For both of these two cases, to obtain the network info of the nested
+ // container, we should look up its parent.
+ return status(containerId.parent());
+ }
+
return ContainerStatus();
}
@@ -1450,8 +1467,6 @@ Future<ContainerStatus> NetworkCniIsolatorProcess::status(
// wants to joins the parent's network, we should look up the IP
// address of the root container of the hierarchy to which this
// container belongs.
- const bool isNestedContainer = containerId.has_parent();
-
if (isNestedContainer && infos[containerId]->joinsParentsNetwork) {
return status(containerId.parent());
}