mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
resolv.conf nameserver line has only one entry
This commit is contained in:
parent
120fd322bd
commit
166a0e440d
@ -229,8 +229,8 @@ func (kl *Kubelet) parseResolvConf(reader io.Reader) (nameservers []string, sear
|
|||||||
if len(fields) == 0 {
|
if len(fields) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if fields[0] == "nameserver" {
|
if fields[0] == "nameserver" && len(fields) >= 2 {
|
||||||
nameservers = append(nameservers, fields[1:]...)
|
nameservers = append(nameservers, fields[1])
|
||||||
}
|
}
|
||||||
if fields[0] == "search" {
|
if fields[0] == "search" {
|
||||||
searches = fields[1:]
|
searches = fields[1:]
|
||||||
|
@ -91,6 +91,7 @@ func TestParseResolvConf(t *testing.T) {
|
|||||||
{"nameserver\t1.2.3.4", []string{"1.2.3.4"}, []string{}},
|
{"nameserver\t1.2.3.4", []string{"1.2.3.4"}, []string{}},
|
||||||
{"nameserver \t 1.2.3.4", []string{"1.2.3.4"}, []string{}},
|
{"nameserver \t 1.2.3.4", []string{"1.2.3.4"}, []string{}},
|
||||||
{"nameserver 1.2.3.4\nnameserver 5.6.7.8", []string{"1.2.3.4", "5.6.7.8"}, []string{}},
|
{"nameserver 1.2.3.4\nnameserver 5.6.7.8", []string{"1.2.3.4", "5.6.7.8"}, []string{}},
|
||||||
|
{"nameserver 1.2.3.4 #comment", []string{"1.2.3.4"}, []string{}},
|
||||||
{"search foo", []string{}, []string{"foo"}},
|
{"search foo", []string{}, []string{"foo"}},
|
||||||
{"search foo bar", []string{}, []string{"foo", "bar"}},
|
{"search foo bar", []string{}, []string{"foo", "bar"}},
|
||||||
{"search foo bar bat\n", []string{}, []string{"foo", "bar", "bat"}},
|
{"search foo bar bat\n", []string{}, []string{"foo", "bar", "bat"}},
|
||||||
|
Loading…
Reference in New Issue
Block a user