Skip to content

Don't allow mixing "multiple-egress-IP HA" with "auto-allocated-egress-IP HA" #20971

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion pkg/network/common/egressip.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,19 @@ func (eit *EgressIPTracker) findEgressIPAllocation(ip net.IP, allocation map[str
}

func (eit *EgressIPTracker) makeEmptyAllocation() (map[string][]string, map[string]bool) {
return make(map[string][]string), make(map[string]bool)
allocation := make(map[string][]string)
alreadyAllocated := make(map[string]bool)

// We don't want to auto-allocate/reallocate IPs for NetNamespaces using
// multiple-egress-IP HA, so those should be considered "already allocated"
// even before we start.
for egressIP, eip := range eit.egressIPs {
if eip.assignedNodeIP != "" && len(eip.namespaces[0].requestedIPs) > 1 {
alreadyAllocated[egressIP] = true
}
}

return allocation, alreadyAllocated
}

func (eit *EgressIPTracker) allocateExistingEgressIPs(allocation map[string][]string, alreadyAllocated map[string]bool) bool {
Expand Down
23 changes: 23 additions & 0 deletions pkg/network/common/egressip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,29 @@ func TestEgressCIDRAllocation(t *testing.T) {
if err != nil {
t.Fatalf("%v", err)
}

// You can't mix multiple-egress-IP HA with auto-allocated-egress-IP HA
updateNetNamespaceEgress(eit, &networkapi.NetNamespace{
NetID: 45,
EgressIPs: []string{"172.17.0.102", "172.17.0.302"},
})
err = w.assertChanges(
"update egress CIDRs",
)
if err != nil {
t.Fatalf("%v", err)
}

allocation = eit.ReallocateEgressIPs()
updateAllocations(eit, allocation)
err = w.assertChanges(
"release 172.17.0.102 on 172.17.0.4",
"namespace 45 dropped",
"update egress CIDRs",
)
if err != nil {
t.Fatalf("%v", err)
}
}

func TestEgressNodeRenumbering(t *testing.T) {
Expand Down