diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-01-24 14:04:49 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-24 14:04:49 -0500 |
commit | 667dfb4ac3ca4b7d7726240db04de4d4b10f8bbd (patch) | |
tree | da16228cfb0bbd59e16a06e1de3446a7b2edbffa | |
parent | 54bfabb78a09bc50f270a81756a303e49965f253 (diff) | |
parent | 2f371cb12c0a637ac4fc5e58e7bb63d4deefbd03 (diff) | |
download | podman-667dfb4ac3ca4b7d7726240db04de4d4b10f8bbd.tar.gz podman-667dfb4ac3ca4b7d7726240db04de4d4b10f8bbd.tar.bz2 podman-667dfb4ac3ca4b7d7726240db04de4d4b10f8bbd.zip |
Merge pull request #12991 from Luap99/aliases
container create: do not check for network dns support
-rw-r--r-- | libpod/networking_linux.go | 7 | ||||
-rw-r--r-- | libpod/runtime_ctr.go | 9 | ||||
-rw-r--r-- | test/e2e/run_networking_test.go | 13 |
3 files changed, 13 insertions, 16 deletions
diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go index 110f37b91..f3707a77d 100644 --- a/libpod/networking_linux.go +++ b/libpod/networking_linux.go @@ -1198,13 +1198,6 @@ func (c *Container) NetworkConnect(nameOrID, netName string, netOpts types.PerNe // get network status before we connect networkStatus := c.getNetworkStatus() - network, err := c.runtime.network.NetworkInspect(netName) - if err != nil { - return err - } - if !network.DNSEnabled && len(netOpts.Aliases) > 0 { - return errors.Wrapf(define.ErrInvalidArg, "cannot set network aliases for network %q because dns is disabled", netName) - } // always add the short id as alias for docker compat netOpts.Aliases = append(netOpts.Aliases, c.config.ID[:12]) diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go index 6ee25c0ec..9ab12732f 100644 --- a/libpod/runtime_ctr.go +++ b/libpod/runtime_ctr.go @@ -254,15 +254,6 @@ func (r *Runtime) setupContainer(ctx context.Context, ctr *Container) (_ *Contai if err != nil { return nil, err } - if len(opts.Aliases) > 0 { - network, err := r.network.NetworkInspect(netName) - if err != nil { - return nil, err - } - if !network.DNSEnabled { - return nil, errors.Wrapf(define.ErrInvalidArg, "cannot set network aliases for network %q because dns is disabled", netName) - } - } // assign interface name if empty if opts.InterfaceName == "" { for i < 100000 { diff --git a/test/e2e/run_networking_test.go b/test/e2e/run_networking_test.go index 87b1f143e..4868fbd01 100644 --- a/test/e2e/run_networking_test.go +++ b/test/e2e/run_networking_test.go @@ -867,4 +867,17 @@ EXPOSE 2004-2005/tcp`, ALPINE) Expect(inspectOut[0].NetworkSettings.Networks).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Networks).To(HaveKey("podman")) }) + + // see https://github.com/containers/podman/issues/12972 + It("podman run check network-alias works on networks without dns", func() { + net := "dns" + stringid.GenerateNonCryptoID() + session := podmanTest.Podman([]string{"network", "create", "--disable-dns", net}) + session.WaitWithDefaultTimeout() + defer podmanTest.removeCNINetwork(net) + Expect(session).Should(Exit(0)) + + session = podmanTest.Podman([]string{"run", "--network", net, "--network-alias", "abcdef", ALPINE, "true"}) + session.WaitWithDefaultTimeout() + Expect(session).Should(Exit(0)) + }) }) |