From 151dcfac28b78e42b8fbb79f194a9561eb3bab3f Mon Sep 17 00:00:00 2001 From: Gunju Kim Date: Fri, 13 Aug 2021 15:05:15 +0900 Subject: [PATCH 1/2] Allow expanded DNS configuration Signed-off-by: Gunju Kim --- pkg/sandbox/fixtures/expanded_resolv.conf | 4 ++++ pkg/sandbox/infra.go | 10 ---------- pkg/sandbox/infra_test.go | 13 ++++++++++--- 3 files changed, 14 insertions(+), 13 deletions(-) create mode 100644 pkg/sandbox/fixtures/expanded_resolv.conf diff --git a/pkg/sandbox/fixtures/expanded_resolv.conf b/pkg/sandbox/fixtures/expanded_resolv.conf new file mode 100644 index 00000000000..36433f7105e --- /dev/null +++ b/pkg/sandbox/fixtures/expanded_resolv.conf @@ -0,0 +1,4 @@ +search 1.com 2.com 3.com 4.com 5.com 6.com 7.com +nameserver cri-o.io +nameserver github.com +options timeout:5 attempts:3 diff --git a/pkg/sandbox/infra.go b/pkg/sandbox/infra.go index 17dee7f0cf1..94716be0ad5 100644 --- a/pkg/sandbox/infra.go +++ b/pkg/sandbox/infra.go @@ -17,12 +17,6 @@ import ( "golang.org/x/sys/unix" ) -const ( - // 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 -) - func (s *sandbox) InitInfraContainer(serverConfig *libconfig.Config, podContainer *storage.ContainerInfo) error { var err error s.infra, err = container.New() @@ -129,10 +123,6 @@ func ParseDNSOptions(servers, searches, options []string, path string) (retErr e return copyFile("/etc/resolv.conf", path) } - if nSearches > maxDNSSearches { - return fmt.Errorf("DNSOption.Searches has more than %d domains", maxDNSSearches) - } - f, err := os.Create(path) if err != nil { return err diff --git a/pkg/sandbox/infra_test.go b/pkg/sandbox/infra_test.go index bf7e98444a4..071f966ff3f 100644 --- a/pkg/sandbox/infra_test.go +++ b/pkg/sandbox/infra_test.go @@ -12,9 +12,10 @@ import ( ) const ( - defaultDNSPath = "/etc/resolv.conf" - testDNSPath = "fixtures/resolv_test.conf" - dnsPath = "fixtures/resolv.conf" + defaultDNSPath = "/etc/resolv.conf" + testDNSPath = "fixtures/resolv_test.conf" + dnsPath = "fixtures/resolv.conf" + expandedDNSPath = "fixtures/expanded_resolv.conf" ) var _ = Describe("Sandbox", func() { @@ -36,6 +37,12 @@ var _ = Describe("Sandbox", func() { []string{"timeout:5", "attempts:3"}, testDNSPath, dnsPath, }, + { + []string{"cri-o.io", "github.com"}, + []string{"1.com", "2.com", "3.com", "4.com", "5.com", "6.com", "7.com"}, + []string{"timeout:5", "attempts:3"}, + testDNSPath, expandedDNSPath, + }, } for _, c := range testCases { From 06f0944171427381738d43e7a4a5b5fffb3403f9 Mon Sep 17 00:00:00 2001 From: Gunju Kim Date: Wed, 18 Aug 2021 10:10:42 +0900 Subject: [PATCH 2/2] Always remove the output file of ParseDNSOptions Signed-off-by: Gunju Kim --- pkg/sandbox/infra_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/sandbox/infra_test.go b/pkg/sandbox/infra_test.go index 071f966ff3f..164643060b7 100644 --- a/pkg/sandbox/infra_test.go +++ b/pkg/sandbox/infra_test.go @@ -46,8 +46,9 @@ var _ = Describe("Sandbox", func() { } for _, c := range testCases { - Expect(sandbox.ParseDNSOptions(c.Servers, c.Searches, c.Options, c.Path)).To(BeNil()) + err := sandbox.ParseDNSOptions(c.Servers, c.Searches, c.Options, c.Path) defer os.Remove(c.Path) + Expect(err).To(BeNil()) expect, _ := ioutil.ReadFile(c.Want) // nolint: errcheck result, _ := ioutil.ReadFile(c.Path) // nolint: errcheck