aboutsummaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorMatthew Heon <mheon@redhat.com>2020-10-20 12:01:53 -0400
committerMatthew Heon <mheon@redhat.com>2020-10-20 13:27:33 -0400
commitc1b844ecc8620f446e95253e9a5124a628576e57 (patch)
tree94fee0a18bc0e6b7156feb3049971303ba7455ff /libpod
parent36682115b0f3f5f7cfcc6bc4580e5a7435b9a4d8 (diff)
downloadpodman-c1b844ecc8620f446e95253e9a5124a628576e57.tar.gz
podman-c1b844ecc8620f446e95253e9a5124a628576e57.tar.bz2
podman-c1b844ecc8620f446e95253e9a5124a628576e57.zip
Retrieve network inspect info from dependency container
When a container either joins a pod that shares the network namespace or uses `--net=container:` to share the network namespace of another container, it does not have its own copy of the CNI results used to generate `podman inspect` output. As such, to inspect these containers, we should be going to the container we share the namespace with for network info. Fixes #8073 Signed-off-by: Matthew Heon <mheon@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/networking_linux.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go
index f87c311ce..df0ff6c32 100644
--- a/libpod/networking_linux.go
+++ b/libpod/networking_linux.go
@@ -823,6 +823,20 @@ func getContainerNetIO(ctr *Container) (*netlink.LinkStatistics, error) {
// Produce an InspectNetworkSettings containing information on the container
// network.
func (c *Container) getContainerNetworkInfo() (*define.InspectNetworkSettings, error) {
+ if c.config.NetNsCtr != "" {
+ netNsCtr, err := c.runtime.GetContainer(c.config.NetNsCtr)
+ if err != nil {
+ return nil, err
+ }
+ // Have to sync to ensure that state is populated
+ if err := netNsCtr.syncContainer(); err != nil {
+ return nil, err
+ }
+ logrus.Debugf("Container %s shares network namespace, retrieving network info of container %s", c.ID(), c.config.NetNsCtr)
+
+ return netNsCtr.getContainerNetworkInfo()
+ }
+
settings := new(define.InspectNetworkSettings)
settings.Ports = makeInspectPortBindings(c.config.PortMappings)