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 f4f990b commit fb70f93
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 @@ -159,6 +159,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, mac string, skippedAddrs []string, checkConflict bool) (IP, IP, string, error) {
Expand Down

0 comments on commit fb70f93

Please sign in to comment.