This is an automated email from the ASF dual-hosted git repository. qianzhang pushed a commit to branch 1.6.x in repository https://gitbox.apache.org/repos/asf/mesos.git
commit a34993f8e273dc5c4ea4ff37ef776864ca2a0e2c Author: Qian Zhang <[email protected]> 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 2200192..0526013 100644 --- a/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp +++ b/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp @@ -1409,12 +1409,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(); } @@ -1422,8 +1439,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()); }
