diff --git a/pkg/agent/config/config.go b/pkg/agent/config/config.go index 817a70514e..b0a2c8e0da 100644 --- a/pkg/agent/config/config.go +++ b/pkg/agent/config/config.go @@ -408,20 +408,18 @@ func get(ctx context.Context, envInfo *cmds.Agent, proxy proxy.Proxy) (*config.N // Pass ipv4, ipv6 or both depending on nodeIPs mode var vpnIPs []net.IP - dualNode, err := utilsnet.IsDualStackIPs(nodeIPs) - if err != nil { - return nil, errors.Wrapf(err, "failed to validate node-ip: %v", nodeIPs) - } - if dualNode && vpnInfo.IPv4Address != nil && vpnInfo.IPv6Address != nil { - vpnIPs = append(vpnIPs, vpnInfo.IPv4Address, vpnInfo.IPv6Address) - } else { - if utilsnet.IsIPv4(nodeIPs[0]) && vpnInfo.IPv4Address != nil { - vpnIPs = append(vpnIPs, vpnInfo.IPv4Address) - } else if utilsnet.IsIPv6(nodeIPs[0]) && vpnInfo.IPv6Address != nil { + if utilsnet.IsIPv4(nodeIPs[0]) && vpnInfo.IPv4Address != nil { + vpnIPs = append(vpnIPs, vpnInfo.IPv4Address) + if vpnInfo.IPv6Address != nil { vpnIPs = append(vpnIPs, vpnInfo.IPv6Address) - } else { - return nil, errors.Errorf("address family mismatch when assigning VPN addresses to node: node=%v, VPN ipv4=%v ipv6=%v", nodeIPs, vpnInfo.IPv4Address, vpnInfo.IPv6Address) } + } else if utilsnet.IsIPv6(nodeIPs[0]) && vpnInfo.IPv6Address != nil { + vpnIPs = append(vpnIPs, vpnInfo.IPv6Address) + if vpnInfo.IPv4Address != nil { + vpnIPs = append(vpnIPs, vpnInfo.IPv4Address) + } + } else { + return nil, errors.Errorf("address family mismatch when assigning VPN addresses to node: node=%v, VPN ipv4=%v ipv6=%v", nodeIPs, vpnInfo.IPv4Address, vpnInfo.IPv6Address) } // Overwrite nodeip and flannel interface and throw a warning if user explicitly set those parameters diff --git a/pkg/cli/server/server.go b/pkg/cli/server/server.go index 4fa77d4b2d..e0ab7d5110 100644 --- a/pkg/cli/server/server.go +++ b/pkg/cli/server/server.go @@ -248,14 +248,8 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont return err } - logrus.Debugf("Processing vpn node-ip based on the detected nodeIPs: %v", nodeIPs) - dualNode, err := utilsnet.IsDualStackIPs(nodeIPs) - if err != nil { - return errors.Wrapf(err, "failed to validate node-ip: %v", nodeIPs) - } - // If we are in ipv6-only mode, we should pass the ipv6 address. Otherwise, ipv4 - if !dualNode && utilsnet.IsIPv6(nodeIPs[0]) { + if utilsnet.IsIPv6(nodeIPs[0]) { if vpnInfo.IPv6Address != nil { logrus.Infof("Changed advertise-address to %v due to VPN", vpnInfo.IPv6Address) if serverConfig.ControlConfig.AdvertiseIP != "" {