Merge pull request #109441 from Miciah/kubelet-parseResolvConf-handle-search-dot

kubelet: parseResolvConf: Handle "search ."
This commit is contained in:
Kubernetes Prow Robot 2022-05-04 01:27:42 -07:00 committed by GitHub
commit d9fa563550
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -267,7 +267,10 @@ func parseResolvConf(reader io.Reader) (nameservers []string, searches []string,
// Normalise search fields so the same domain with and without trailing dot will only count once, to avoid hitting search validation limits.
searches = []string{}
for _, s := range fields[1:] {
searches = append(searches, strings.TrimSuffix(s, "."))
if s != "." {
s = strings.TrimSuffix(s, ".")
}
searches = append(searches, s)
}
}
if fields[0] == "options" {

View File

@ -78,6 +78,7 @@ 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 #comment", []string{"1.2.3.4"}, []string{}, []string{}, false},
{"search ", []string{}, []string{}, []string{}, false}, // search empty
{"search .", []string{}, []string{"."}, []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},