From 299cef4e996fbaced5408883b63a794133112e49 Mon Sep 17 00:00:00 2001 From: Andrey Bobelev Date: Tue, 28 Oct 2025 11:19:14 +0200 Subject: [PATCH] fix: free ips from usedIps ipset on DeleteNode --- hscontrol/db/ip.go | 9 +++++++++ hscontrol/state/state.go | 2 ++ 2 files changed, 11 insertions(+) diff --git a/hscontrol/db/ip.go b/hscontrol/db/ip.go index 244bb3db..972d8e72 100644 --- a/hscontrol/db/ip.go +++ b/hscontrol/db/ip.go @@ -341,3 +341,12 @@ func (db *HSDatabase) BackfillNodeIPs(i *IPAllocator) ([]string, error) { return ret, err } + +func (i *IPAllocator) FreeIPs(ips []netip.Addr) { + i.mu.Lock() + defer i.mu.Unlock() + + for _, ip := range ips { + i.usedIPs.Remove(ip) + } +} diff --git a/hscontrol/state/state.go b/hscontrol/state/state.go index 297004fc..6ef11f54 100644 --- a/hscontrol/state/state.go +++ b/hscontrol/state/state.go @@ -429,6 +429,8 @@ func (s *State) DeleteNode(node types.NodeView) (change.ChangeSet, error) { return change.EmptySet, err } + s.ipAlloc.FreeIPs(node.IPs()) + c := change.NodeRemoved(node.ID()) // Check if policy manager needs updating after node deletion