-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skip updating node status address if already set (#195)
If node status addresses field has already been set, we want to skip updating it again. This is to work around sporadic API issues that don't guarantee in the ordering between learned IPs based on source i.e DHCP assigned IP priority before loadbalancer ARP-ed IP. --------- Co-authored-by: Daniel Lipovetsky <daniel.lipovetsky@nutanix.com>
- Loading branch information
1 parent
514c3e8
commit d289163
Showing
2 changed files
with
110 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package provider | ||
|
||
import ( | ||
"testing" | ||
|
||
v1 "k8s.io/api/core/v1" | ||
) | ||
|
||
func TestIsNodeAddressesSet(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
node *v1.Node | ||
want bool | ||
}{ | ||
{ | ||
name: "found an internalIP and a hostname", | ||
node: &v1.Node{ | ||
Status: v1.NodeStatus{ | ||
Addresses: []v1.NodeAddress{ | ||
{ | ||
Type: v1.NodeHostName, | ||
Address: "example.com", | ||
}, | ||
{ | ||
Type: v1.NodeInternalIP, | ||
Address: "1.2.3.4", | ||
}, | ||
}, | ||
}, | ||
}, | ||
want: true, | ||
}, | ||
{ | ||
name: "found only internalIPs", | ||
node: &v1.Node{ | ||
Status: v1.NodeStatus{ | ||
Addresses: []v1.NodeAddress{ | ||
{ | ||
Type: v1.NodeInternalIP, | ||
Address: "1.2.3.4", | ||
}, | ||
{ | ||
Type: v1.NodeInternalIP, | ||
Address: "5.6.7.8", | ||
}, | ||
}, | ||
}, | ||
}, | ||
want: false, | ||
}, | ||
{ | ||
name: "found only a hostname", | ||
node: &v1.Node{ | ||
Status: v1.NodeStatus{ | ||
Addresses: []v1.NodeAddress{ | ||
{ | ||
Type: v1.NodeHostName, | ||
Address: "example.com", | ||
}, | ||
}, | ||
}, | ||
}, | ||
want: false, | ||
}, | ||
{ | ||
name: "found no addresses", | ||
node: &v1.Node{ | ||
Status: v1.NodeStatus{ | ||
Addresses: []v1.NodeAddress{}, | ||
}, | ||
}, | ||
want: false, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
n := &nutanixManager{} | ||
if got := n.isNodeAddressesSet(tt.node); got != tt.want { | ||
t.Errorf("nutanixManager.isNodeAddressesSet() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |