Skip to content

Commit

Permalink
fix: filter down nameservers for docker-based cluster create
Browse files Browse the repository at this point in the history
Filter the default list down to IPv4/IPv6 depending on the network
configuration. The problem is that the full list contains IPv6 resolvers
and these won't work on IPv4-only network (which is default for
`talosctl cluster create`).

This is not a problem for QEMU, as QEMU filters down the list for
built-in DHCP server already splitting it for DHCP4/DHCP6.

Signed-off-by: Andrey Smirnov <[email protected]>
  • Loading branch information
smira committed Jan 12, 2022
1 parent 194eaa6 commit 59437d6
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions pkg/provision/providers/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,26 @@ func (p *provisioner) Close() error {

// GenOptions provides a list of additional config generate options.
func (p *provisioner) GenOptions(networkReq provision.NetworkRequest) []generate.GenOption {
nameservers := make([]string, len(networkReq.Nameservers))
for i := range nameservers {
nameservers[i] = networkReq.Nameservers[i].String()
nameservers := make([]string, 0, len(networkReq.Nameservers))

hasV4 := false
hasV6 := false

for _, subnet := range networkReq.CIDRs {
if subnet.IP.To4() == nil {
hasV6 = true
} else {
hasV4 = true
}
}

// filter nameservers by IPv4/IPv6
for i := range networkReq.Nameservers {
if networkReq.Nameservers[i].To4() == nil && hasV6 {
nameservers = append(nameservers, networkReq.Nameservers[i].String())
} else if networkReq.Nameservers[i].To4() != nil && hasV4 {
nameservers = append(nameservers, networkReq.Nameservers[i].String())
}
}

return []generate.GenOption{
Expand Down

0 comments on commit 59437d6

Please sign in to comment.