Skip to content

Commit 39ba488

Browse files
authored
Merge pull request kubernetes#83069 from fcgravalos/remove_trailing_dots_from_searches
remove trailing dots from the parsed searches from host resolv.conf
2 parents 0c6ce58 + c959b5e commit 39ba488

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

pkg/kubelet/network/dns/dns.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,11 @@ func parseResolvConf(reader io.Reader) (nameservers []string, searches []string,
230230
}
231231
}
232232
if fields[0] == "search" {
233-
searches = fields[1:]
233+
// Normalise search fields so the same domain with and without trailing dot will only count once, to avoid hitting search validation limits.
234+
searches = []string{}
235+
for _, s := range fields[1:] {
236+
searches = append(searches, strings.TrimSuffix(s, "."))
237+
}
234238
}
235239
if fields[0] == "options" {
236240
options = fields[1:]

pkg/kubelet/network/dns/dns_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ func TestParseResolvConf(t *testing.T) {
7474
{"search ", []string{}, []string{}, []string{}, false}, // search empty
7575
{"search foo", []string{}, []string{"foo"}, []string{}, false},
7676
{"search foo bar", []string{}, []string{"foo", "bar"}, []string{}, false},
77+
{"search foo. bar", []string{}, []string{"foo", "bar"}, []string{}, false},
7778
{"search foo bar bat\n", []string{}, []string{"foo", "bar", "bat"}, []string{}, false},
7879
{"search foo\nsearch bar", []string{}, []string{"bar"}, []string{}, false},
7980
{"nameserver 1.2.3.4\nsearch foo bar", []string{"1.2.3.4"}, []string{"foo", "bar"}, []string{}, false},

0 commit comments

Comments
 (0)