Skip to content

Commit

Permalink
fix(krnode): apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Tom Wieczorek <[email protected]>
  • Loading branch information
aauren and twz123 authored Sep 23, 2024
1 parent f6ff559 commit 883d2b4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/controllers/netpol/network_policy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ var (

// NetworkPolicyController struct to hold information required by NetworkPolicyController
type NetworkPolicyController struct {
krNode utils.NodeAware
krNode utils.NodeIPAndFamilyAware
serviceClusterIPRanges []net.IPNet
serviceExternalIPRanges []net.IPNet
serviceLoadBalancerIPRanges []net.IPNet
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/routing/network_routes_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ func (nrc *NetworkRoutingController) syncNodeIPSets(nodeIPAware utils.NodeIPAwar
}

var ipv4Addrs, ipv6Addrs [][]string
for _, nodeIPv4 := range nodeIPAware.GetNodeIPv6Addrs() {
for _, nodeIPv4 := range nodeIPAware.GetNodeIPv4Addrs() {
ipv4Addrs = append(ipv4Addrs, []string{nodeIPv4.String(), utils.OptionTimeout, "0"})
}
for _, nodeIPv6 := range nodeIPAware.GetNodeIPv6Addrs() {
Expand Down
8 changes: 4 additions & 4 deletions pkg/utils/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func (n *KRNode) GetNodeName() string {
// FindBestIPv6NodeAddress returns the best available IPv6 address for the node. If the primary IP is already an IPv6
// address, it will return that. Otherwise, it will return the first internal or external IPv6 address defined in the
// Kubernetes Node Object.
func (n KRNode) FindBestIPv6NodeAddress() net.IP {
func (n *KRNode) FindBestIPv6NodeAddress() net.IP {
if n.PrimaryIP != nil && n.PrimaryIP.To4() == nil && n.PrimaryIP.To16() != nil {
// the NRC's primary IP is already an IPv6 address, so we'll use that
return n.PrimaryIP
Expand All @@ -182,7 +182,7 @@ func (n KRNode) FindBestIPv6NodeAddress() net.IP {
// FindBestIPv4NodeAddress returns the best available IPv4 address for the node. If the primary IP is already an IPv4
// address, it will return that. Otherwise, it will return the first internal or external IPv4 address defined in the
// Kubernetes Node Object.
func (n KRNode) FindBestIPv4NodeAddress() net.IP {
func (n *KRNode) FindBestIPv4NodeAddress() net.IP {
if n.PrimaryIP != nil && n.PrimaryIP.To4() != nil {
// the NRC's primary IP is already an IPv6 address, so we'll use that
return n.PrimaryIP
Expand Down Expand Up @@ -224,7 +224,7 @@ func (n KRNode) GetNodeMTU() (int, error) {

// GetNodeIPAddrs returns all of the node's IP addresses (whether internal or external) as defined by the Kubernetes
// Node Object.
func (n KRNode) GetNodeIPAddrs() []net.IP {
func (n *KRNode) GetNodeIPAddrs() []net.IP {
var nodeIPs []net.IP
for _, ip := range n.NodeIPv4Addrs {
nodeIPs = append(nodeIPs, ip...)
Expand Down Expand Up @@ -358,7 +358,7 @@ func getAllNodeIPs(node *apiv1.Node) (map[apiv1.NodeAddressType][]net.IP, map[ap
addresses := node.Status.Addresses
addressesPerType := make(nodeAddressMap)
for _, address := range addresses {
addressesPerType.add(address)
addressesPerType[address.Type] = append(addressesPerType[address.Type], address)
}
if internalAddresses, ok := addressesPerType[apiv1.NodeInternalIP]; ok {
for _, address := range internalAddresses {
Expand Down

0 comments on commit 883d2b4

Please sign in to comment.