summaryrefslogtreecommitdiff
path: root/libpod/container_internal.go
diff options
context:
space:
mode:
authorMatthew Heon <mheon@redhat.com>2020-11-20 13:49:40 -0500
committerMatthew Heon <mheon@redhat.com>2020-11-20 14:03:24 -0500
commitce775248ada62c117dd5303989052b268e6594bd (patch)
treeffec30ad79d2ec8a51d7387ee46d5e1e9be8d517 /libpod/container_internal.go
parent864fe21ed02ca6faa72e6a94f06c9961167aca7d (diff)
downloadpodman-ce775248ada62c117dd5303989052b268e6594bd.tar.gz
podman-ce775248ada62c117dd5303989052b268e6594bd.tar.bz2
podman-ce775248ada62c117dd5303989052b268e6594bd.zip
Make c.networks() list include the default network
This makes things a lot more clear - if we are actually joining a CNI network, we are guaranteed to get a non-zero length list of networks. We do, however, need to know if the network we are joining is the default network for inspecting containers as it determines how we populate the response struct. To handle this, add a bool to indicate that the network listed was the default network, and only the default network. Signed-off-by: Matthew Heon <mheon@redhat.com>
Diffstat (limited to 'libpod/container_internal.go')
-rw-r--r--libpod/container_internal.go9
1 files changed, 2 insertions, 7 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index 108954bad..823e5fb3a 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -641,18 +641,13 @@ func (c *Container) removeIPv4Allocations() error {
cniDefaultNetwork = c.runtime.netPlugin.GetDefaultNetworkName()
}
- networks, err := c.networks()
+ networks, _, err := c.networks()
if err != nil {
return err
}
- switch {
- case len(networks) > 0 && len(networks) != len(c.state.NetworkStatus):
+ if len(networks) != len(c.state.NetworkStatus) {
return errors.Wrapf(define.ErrInternal, "network mismatch: asked to join %d CNI networks but got %d CNI results", len(networks), len(c.state.NetworkStatus))
- case len(networks) == 0 && len(c.state.NetworkStatus) != 1:
- return errors.Wrapf(define.ErrInternal, "network mismatch: did not specify CNI networks but joined more than one (%d)", len(c.state.NetworkStatus))
- case len(networks) == 0 && cniDefaultNetwork == "":
- return errors.Wrapf(define.ErrInternal, "could not retrieve name of CNI default network")
}
for index, result := range c.state.NetworkStatus {