Skip to content

Commit

Permalink
fix(node): make ordering more specific
Browse files Browse the repository at this point in the history
We should be returning IP addresses in specific orders based upon what
type of IP they are.
  • Loading branch information
aauren committed Oct 21, 2024
1 parent 4d120fc commit b09395f
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions pkg/utils/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,16 @@ type NodeAware interface {
// GetNodeIPv4Addrs returns the node's IPv4 addresses as defined by the Kubernetes Node Object.
func (n *KRNode) GetNodeIPv4Addrs() []net.IP {
var nodeIPs []net.IP
for _, ip := range n.NodeIPv4Addrs {
nodeIPs = append(nodeIPs, ip...)
}
nodeIPs = append(nodeIPs, n.NodeIPv4Addrs[apiv1.NodeInternalIP]...)
nodeIPs = append(nodeIPs, n.NodeIPv4Addrs[apiv1.NodeExternalIP]...)
return nodeIPs
}

// GetNodeIPv6Addrs returns the node's IPv6 addresses as defined by the Kubernetes Node Object.
func (n *KRNode) GetNodeIPv6Addrs() []net.IP {
var nodeIPs []net.IP
for _, ip := range n.NodeIPv6Addrs {
nodeIPs = append(nodeIPs, ip...)
}
nodeIPs = append(nodeIPs, n.NodeIPv6Addrs[apiv1.NodeInternalIP]...)
nodeIPs = append(nodeIPs, n.NodeIPv6Addrs[apiv1.NodeExternalIP]...)
return nodeIPs
}

Expand Down Expand Up @@ -196,12 +194,10 @@ func (n *LocalKRNode) GetNodeMTU() (int, error) {
// Node Object.
func (n *KRNode) GetNodeIPAddrs() []net.IP {
var nodeIPs []net.IP
for _, ip := range n.NodeIPv4Addrs {
nodeIPs = append(nodeIPs, ip...)
}
for _, ip := range n.NodeIPv6Addrs {
nodeIPs = append(nodeIPs, ip...)
}
ipv4IPs := n.GetNodeIPv4Addrs()
nodeIPs = append(nodeIPs, ipv4IPs...)
ipv6IPs := n.GetNodeIPv6Addrs()
nodeIPs = append(nodeIPs, ipv6IPs...)
return nodeIPs
}

Expand Down

0 comments on commit b09395f

Please sign in to comment.