summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-02-24 09:24:20 -0500
committerGitHub <noreply@github.com>2021-02-24 09:24:20 -0500
commit4846f877b83ea55b1d70155fd668c79a4a0f88f4 (patch)
treefb52b6435e12e46f2d7a087dd3273d1f62b1084d
parent49fa19dff6717e419ebbaba029e84cbc5bd97904 (diff)
parent90050671b71cd4629b27809055bd562ab76c4460 (diff)
downloadpodman-4846f877b83ea55b1d70155fd668c79a4a0f88f4.tar.gz
podman-4846f877b83ea55b1d70155fd668c79a4a0f88f4.tar.bz2
podman-4846f877b83ea55b1d70155fd668c79a4a0f88f4.zip
Merge pull request #9501 from Luap99/dns-search-cni
Add dns search domains from cni response to resolv.conf
-rw-r--r--libpod/container_internal_linux.go12
-rw-r--r--test/e2e/run_networking_test.go14
2 files changed, 23 insertions, 3 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go
index 9c3e91a97..dc0418148 100644
--- a/libpod/container_internal_linux.go
+++ b/libpod/container_internal_linux.go
@@ -1713,8 +1713,9 @@ rootless=%d
// generateResolvConf generates a containers resolv.conf
func (c *Container) generateResolvConf() (string, error) {
var (
- nameservers []string
- cniNameServers []string
+ nameservers []string
+ cniNameServers []string
+ cniSearchDomains []string
)
resolvConf := "/etc/resolv.conf"
@@ -1766,6 +1767,10 @@ func (c *Container) generateResolvConf() (string, error) {
cniNameServers = append(cniNameServers, i.DNS.Nameservers...)
logrus.Debugf("adding nameserver(s) from cni response of '%q'", i.DNS.Nameservers)
}
+ if i.DNS.Search != nil {
+ cniSearchDomains = append(cniSearchDomains, i.DNS.Search...)
+ logrus.Debugf("adding search domain(s) from cni response of '%q'", i.DNS.Search)
+ }
}
dns := make([]net.IP, 0, len(c.runtime.config.Containers.DNSServers))
@@ -1797,10 +1802,11 @@ func (c *Container) generateResolvConf() (string, error) {
}
var search []string
- if len(c.config.DNSSearch) > 0 || len(c.runtime.config.Containers.DNSSearches) > 0 {
+ if len(c.config.DNSSearch) > 0 || len(c.runtime.config.Containers.DNSSearches) > 0 || len(cniSearchDomains) > 0 {
if !util.StringInSlice(".", c.config.DNSSearch) {
search = c.runtime.config.Containers.DNSSearches
search = append(search, c.config.DNSSearch...)
+ search = append(search, cniSearchDomains...)
}
} else {
search = resolvconf.GetSearchDomains(resolv.Content)
diff --git a/test/e2e/run_networking_test.go b/test/e2e/run_networking_test.go
index a6237a49a..0e6e636bc 100644
--- a/test/e2e/run_networking_test.go
+++ b/test/e2e/run_networking_test.go
@@ -766,4 +766,18 @@ var _ = Describe("Podman run networking", func() {
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(BeZero())
})
+
+ It("podman run check dnsname adds dns search domain", func() {
+ Skip("needs dnsname#57")
+ net := "dnsname" + stringid.GenerateNonCryptoID()
+ session := podmanTest.Podman([]string{"network", "create", net})
+ session.WaitWithDefaultTimeout()
+ defer podmanTest.removeCNINetwork(net)
+ Expect(session.ExitCode()).To(BeZero())
+
+ session = podmanTest.Podman([]string{"run", "--network", net, ALPINE, "cat", "/etc/resolv.conf"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(BeZero())
+ Expect(session.OutputToString()).To(ContainSubstring("search dns.podman"))
+ })
})