summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-09-04 21:57:43 +0200
committerGitHub <noreply@github.com>2019-09-04 21:57:43 +0200
commit84140f5331cebd7a63a44de277244d48452fe040 (patch)
tree54fa853ae8b7aa985ca237df1867688fab20d422 /libpod
parentf1a3e02aea68a37f85cb924c934be1bcc4131d7d (diff)
parent8818e358bf4d934b494bb38c545c7e72a4fb26e6 (diff)
downloadpodman-84140f5331cebd7a63a44de277244d48452fe040.tar.gz
podman-84140f5331cebd7a63a44de277244d48452fe040.tar.bz2
podman-84140f5331cebd7a63a44de277244d48452fe040.zip
Merge pull request #3902 from baude/dnsmasqaddresponse
handle dns response from cni
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_internal_linux.go30
1 files changed, 24 insertions, 6 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go
index 5aa4ee9a9..cb19b5484 100644
--- a/libpod/container_internal_linux.go
+++ b/libpod/container_internal_linux.go
@@ -1039,6 +1039,11 @@ func (c *Container) makeBindMounts() error {
// generateResolvConf generates a containers resolv.conf
func (c *Container) generateResolvConf() (string, error) {
+ var (
+ nameservers []string
+ cniNameServers []string
+ )
+
resolvConf := "/etc/resolv.conf"
for _, namespace := range c.config.Spec.Linux.Namespaces {
if namespace.Type == spec.NetworkNamespace {
@@ -1074,18 +1079,31 @@ func (c *Container) generateResolvConf() (string, error) {
return "", errors.Wrapf(err, "error parsing host resolv.conf")
}
- // Make a new resolv.conf
- nameservers := resolvconf.GetNameservers(resolv.Content)
- // slirp4netns has a built in DNS server.
- if c.config.NetMode.IsSlirp4netns() {
- nameservers = append([]string{"10.0.2.3"}, nameservers...)
+ // Check if CNI gave back and DNS servers for us to add in
+ cniResponse := c.state.NetworkStatus
+ for _, i := range cniResponse {
+ if i.DNS.Nameservers != nil {
+ cniNameServers = append(cniNameServers, i.DNS.Nameservers...)
+ logrus.Debugf("adding nameserver(s) from cni response of '%q'", i.DNS.Nameservers)
+ }
}
+
+ // If the user provided dns, it trumps all; then dns masq; then resolv.conf
if len(c.config.DNSServer) > 0 {
// We store DNS servers as net.IP, so need to convert to string
- nameservers = []string{}
for _, server := range c.config.DNSServer {
nameservers = append(nameservers, server.String())
}
+ } else if len(cniNameServers) > 0 {
+ nameservers = append(nameservers, cniNameServers...)
+ } else {
+ // Make a new resolv.conf
+ nameservers = resolvconf.GetNameservers(resolv.Content)
+ // slirp4netns has a built in DNS server.
+ if c.config.NetMode.IsSlirp4netns() {
+ nameservers = append([]string{"10.0.2.3"}, nameservers...)
+ }
+
}
search := resolvconf.GetSearchDomains(resolv.Content)