mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Fix testing if an interface is the loopback
It's not guaranteed that the loopback interface only has the loopback IP, in our environments our loopback interface is also assigned a 169 address as well.
This commit is contained in:
parent
01e7b3040a
commit
70923dd9db
@ -547,12 +547,15 @@ func getLocalIP() ([]v1.NodeAddress, error) {
|
||||
return nil, err
|
||||
}
|
||||
for _, i := range ifaces {
|
||||
if i.Flags&net.FlagLoopback != 0 {
|
||||
continue
|
||||
}
|
||||
localAddrs, err := i.Addrs()
|
||||
if err != nil {
|
||||
klog.Warningf("Failed to extract addresses for NodeAddresses - %v", err)
|
||||
} else {
|
||||
for _, addr := range localAddrs {
|
||||
if ipnet, ok := addr.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
|
||||
if ipnet, ok := addr.(*net.IPNet); ok {
|
||||
if ipnet.IP.To4() != nil {
|
||||
// Filter external IP by MAC address OUIs from vCenter and from ESX
|
||||
vmMACAddr := strings.ToLower(i.HardwareAddr.String())
|
||||
|
Loading…
Reference in New Issue
Block a user