From ec1bc4d6a87e67a597c0a1e2af9de204dba31562 Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Mon, 24 Oct 2016 10:57:40 -0400 Subject: [PATCH] Handle PodSandboxConfig.DNSConfig.Options DNSConfig can pass "options" settings in now, so add them to the resolv.conf that we're generating, too. Signed-off-by: Nalin Dahyabhai --- server/sandbox.go | 3 ++- server/utils.go | 13 +++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/server/sandbox.go b/server/sandbox.go index 0eafe97f..a398e29a 100644 --- a/server/sandbox.go +++ b/server/sandbox.go @@ -162,8 +162,9 @@ func (s *Server) RunPodSandbox(ctx context.Context, req *pb.RunPodSandboxRequest // set DNS options dnsServers := req.GetConfig().GetDnsConfig().GetServers() dnsSearches := req.GetConfig().GetDnsConfig().GetSearches() + dnsOptions := req.GetConfig().GetDnsConfig().GetOptions() resolvPath := fmt.Sprintf("%s/resolv.conf", podSandboxDir) - err = parseDNSOptions(dnsServers, dnsSearches, resolvPath) + err = parseDNSOptions(dnsServers, dnsSearches, dnsOptions, resolvPath) if err != nil { err1 := removeFile(resolvPath) if err1 != nil { diff --git a/server/utils.go b/server/utils.go index a19a6f7e..190f66f9 100644 --- a/server/utils.go +++ b/server/utils.go @@ -74,10 +74,11 @@ func removeFile(path string) error { return nil } -func parseDNSOptions(servers, searches []string, path string) error { +func parseDNSOptions(servers, searches, options []string, path string) error { nServers := len(servers) nSearches := len(searches) - if nServers == 0 && nSearches == 0 { + nOptions := len(options) + if nServers == 0 && nSearches == 0 && nOptions == 0 { return copyFile("/etc/resolv.conf", path) } @@ -107,5 +108,13 @@ func parseDNSOptions(servers, searches []string, path string) error { } } + if nOptions > 0 { + data := fmt.Sprintf("options %s\n", strings.Join(options, " ")) + _, err = f.Write([]byte(data)) + if err != nil { + return err + } + } + return nil }