Merge pull request #188 from nalind/dns
Handle PodSandboxConfig.DNSConfig.Options
This commit is contained in:
commit
97655c3e7b
2 changed files with 13 additions and 3 deletions
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue