Fix comments and add check in case of IPv6 only node

Signed-off-by: Roberto Bonafiglia <roberto.bonafiglia@suse.com>
pull/5962/head
Roberto Bonafiglia 2 years ago committed by Roberto Bonafiglia
parent d90ba30353
commit abdf0c7319

@ -38,7 +38,7 @@ func getIPFromInterface(ifaceName string) (string, error) {
if err != nil { if err != nil {
return "", errors.Wrapf(err, "unable to parse CIDR for interface %s", iface.Name) return "", errors.Wrapf(err, "unable to parse CIDR for interface %s", iface.Name)
} }
// skipping if not ipv4 // if not IPv4 adding it on IPv6 list
if ip.To4() == nil { if ip.To4() == nil {
if ip.IsGlobalUnicast() { if ip.IsGlobalUnicast() {
globalUnicastsIPv6 = append(globalUnicastsIPv6, ip.String()) globalUnicastsIPv6 = append(globalUnicastsIPv6, ip.String())

@ -142,9 +142,12 @@ func GetHostnameAndIPs(name string, nodeIPs cli.StringSlice) (string, []net.IP,
return "", nil, err return "", nil, err
} }
ips = append(ips, hostIP) ips = append(ips, hostIP)
hostIPv6, err := apinet.ResolveBindAddress(net.IPv6loopback) // If IPv6 it's an IPv6 only node
if err == nil && !hostIPv6.Equal(hostIP) { if hostIP.To4() != nil {
ips = append(ips, hostIPv6) hostIPv6, err := apinet.ResolveBindAddress(net.IPv6loopback)
if err == nil && !hostIPv6.Equal(hostIP) {
ips = append(ips, hostIPv6)
}
} }
} else { } else {
var err error var err error

Loading…
Cancel
Save