mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 10:20:51 +00:00
Merge pull request #112157 from dghubble/master
Avoid propagating "search ." into containers /etc/resolv.conf
This commit is contained in:
commit
ca09ed0fe2
@ -25,7 +25,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
||||||
utilvalidation "k8s.io/apimachinery/pkg/util/validation"
|
utilvalidation "k8s.io/apimachinery/pkg/util/validation"
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||||
@ -268,9 +268,8 @@ func parseResolvConf(reader io.Reader) (nameservers []string, searches []string,
|
|||||||
searches = []string{}
|
searches = []string{}
|
||||||
for _, s := range fields[1:] {
|
for _, s := range fields[1:] {
|
||||||
if s != "." {
|
if s != "." {
|
||||||
s = strings.TrimSuffix(s, ".")
|
searches = append(searches, strings.TrimSuffix(s, "."))
|
||||||
}
|
}
|
||||||
searches = append(searches, s)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if fields[0] == "options" {
|
if fields[0] == "options" {
|
||||||
|
@ -78,7 +78,10 @@ func TestParseResolvConf(t *testing.T) {
|
|||||||
{"nameserver 1.2.3.4\nnameserver 5.6.7.8", []string{"1.2.3.4", "5.6.7.8"}, []string{}, []string{}, false},
|
{"nameserver 1.2.3.4\nnameserver 5.6.7.8", []string{"1.2.3.4", "5.6.7.8"}, []string{}, []string{}, false},
|
||||||
{"nameserver 1.2.3.4 #comment", []string{"1.2.3.4"}, []string{}, []string{}, false},
|
{"nameserver 1.2.3.4 #comment", []string{"1.2.3.4"}, []string{}, []string{}, false},
|
||||||
{"search ", []string{}, []string{}, []string{}, false}, // search empty
|
{"search ", []string{}, []string{}, []string{}, false}, // search empty
|
||||||
{"search .", []string{}, []string{"."}, []string{}, false},
|
{"search .", []string{}, []string{}, []string{}, false}, // ignore lone dot
|
||||||
|
{"search . foo", []string{}, []string{"foo"}, []string{}, false},
|
||||||
|
{"search foo .", []string{}, []string{"foo"}, []string{}, false},
|
||||||
|
{"search foo . bar", []string{}, []string{"foo", "bar"}, []string{}, false},
|
||||||
{"search foo", []string{}, []string{"foo"}, []string{}, false},
|
{"search foo", []string{}, []string{"foo"}, []string{}, false},
|
||||||
{"search foo bar", []string{}, []string{"foo", "bar"}, []string{}, false},
|
{"search foo bar", []string{}, []string{"foo", "bar"}, []string{}, false},
|
||||||
{"search foo. bar", []string{}, []string{"foo", "bar"}, []string{}, false},
|
{"search foo. bar", []string{}, []string{"foo", "bar"}, []string{}, false},
|
||||||
|
Loading…
Reference in New Issue
Block a user