Skip to content

Commit

Permalink
Merge pull request containerd#5878 from gjkim42/allow-expanded-dns-co…
Browse files Browse the repository at this point in the history
…nfig

Allow expanded DNS configuration
  • Loading branch information
estesp authored Aug 14, 2021
2 parents d0be7b9 + 1224060 commit 024804b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
3 changes: 0 additions & 3 deletions pkg/cri/server/helpers_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ const (
defaultShmSize = int64(1024 * 1024 * 64)
// relativeRootfsPath is the rootfs path relative to bundle path.
relativeRootfsPath = "rootfs"
// According to http://man7.org/linux/man-pages/man5/resolv.conf.5.html:
// "The search list is currently limited to six domains with a total of 256 characters."
maxDNSSearches = 6
// devShm is the default path of /dev/shm.
devShm = "/dev/shm"
// etcHosts is the default path of /etc/hosts file.
Expand Down
4 changes: 0 additions & 4 deletions pkg/cri/server/sandbox_run_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,6 @@ func (c *criService) setupSandboxFiles(id string, config *runtime.PodSandboxConf
func parseDNSOptions(servers, searches, options []string) (string, error) {
resolvContent := ""

if len(searches) > maxDNSSearches {
return "", errors.Errorf("DNSOption.Searches has more than %d domains", maxDNSSearches)
}

if len(searches) > 0 {
resolvContent += fmt.Sprintf("search %s\n", strings.Join(searches, " "))
}
Expand Down
10 changes: 8 additions & 2 deletions pkg/cri/server/sandbox_run_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,8 @@ nameserver server.google.com
options timeout:1
`,
},
"should return error if dns search exceeds limit(6)": {
"expanded dns config should return correct content on modern libc (e.g. glibc 2.26 and above)": {
servers: []string{"8.8.8.8", "server.google.com"},
searches: []string{
"server0.google.com",
"server1.google.com",
Expand All @@ -404,7 +405,12 @@ options timeout:1
"server5.google.com",
"server6.google.com",
},
expectErr: true,
options: []string{"timeout:1"},
expectedContent: `search server0.google.com server1.google.com server2.google.com server3.google.com server4.google.com server5.google.com server6.google.com
nameserver 8.8.8.8
nameserver server.google.com
options timeout:1
`,
},
} {
t.Logf("TestCase %q", desc)
Expand Down

0 comments on commit 024804b

Please sign in to comment.