Skip to content

Commit

Permalink
fix: memory leak in IPAM caused by leftover map keys (#2566)
Browse files Browse the repository at this point in the history
When all nics are popped from the list the map key still exist which will lead memory leak each time a pod is deleted.

(cherry picked from commit 3f7997b)
  • Loading branch information
oilbeater committed Mar 29, 2023
1 parent 1cea97b commit b366ee8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/ipam/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ func (subnet *Subnet) pushPodNic(podName, nicName string) {

func (subnet *Subnet) popPodNic(podName, nicName string) {
subnet.PodToNicList[podName] = util.RemoveString(subnet.PodToNicList[podName], nicName)
if subnet.PodToNicList[podName] == nil {
delete(subnet.PodToNicList, podName)
}
}

func (subnet *Subnet) GetRandomAddress(podName, nicName string, skippedAddrs []string) (IP, IP, string, error) {
Expand Down

0 comments on commit b366ee8

Please sign in to comment.