diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-11-12 19:40:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-12 19:40:31 +0100 |
commit | 2aa6a8577d088271251604b028100f00a442f5cd (patch) | |
tree | ba5f781412045c7bbd7a3313e306b36c4b92b208 /libpod/container_internal.go | |
parent | 7774f63319be64a0a96fb7ec7c9f0b7c28faac03 (diff) | |
parent | 8d56eb5342ad8afa35750f7f14791c44e37a8c30 (diff) | |
download | podman-2aa6a8577d088271251604b028100f00a442f5cd.tar.gz podman-2aa6a8577d088271251604b028100f00a442f5cd.tar.bz2 podman-2aa6a8577d088271251604b028100f00a442f5cd.zip |
Merge pull request #8298 from mheon/db_network_connect
Add support for network connect / disconnect to DB
Diffstat (limited to 'libpod/container_internal.go')
-rw-r--r-- | libpod/container_internal.go | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go index 3a8566760..108954bad 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -641,12 +641,17 @@ func (c *Container) removeIPv4Allocations() error { cniDefaultNetwork = c.runtime.netPlugin.GetDefaultNetworkName() } + networks, err := c.networks() + if err != nil { + return err + } + switch { - case len(c.config.Networks) > 0 && len(c.config.Networks) != len(c.state.NetworkStatus): - return errors.Wrapf(define.ErrInternal, "network mismatch: asked to join %d CNI networks but got %d CNI results", len(c.config.Networks), len(c.state.NetworkStatus)) - case len(c.config.Networks) == 0 && len(c.state.NetworkStatus) != 1: + case len(networks) > 0 && 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(c.config.Networks) == 0 && cniDefaultNetwork == "": + case len(networks) == 0 && cniDefaultNetwork == "": return errors.Wrapf(define.ErrInternal, "could not retrieve name of CNI default network") } @@ -656,11 +661,11 @@ func (c *Container) removeIPv4Allocations() error { continue } candidate := "" - if len(c.config.Networks) > 0 { + if len(networks) > 0 { // CNI returns networks in order we passed them. // So our index into results should be our index // into networks. - candidate = filepath.Join(cniNetworksDir, c.config.Networks[index], ctrIP.Address.IP.String()) + candidate = filepath.Join(cniNetworksDir, networks[index], ctrIP.Address.IP.String()) } else { candidate = filepath.Join(cniNetworksDir, cniDefaultNetwork, ctrIP.Address.IP.String()) } |