Skip to content

Commit fb70f93

Browse files
committed
fix: memory leak in IPAM caused by leftover map keys (#2566)
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)
1 parent f4f990b commit fb70f93

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

pkg/ipam/subnet.go

+3
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ func (subnet *Subnet) pushPodNic(podName, nicName string) {
159159

160160
func (subnet *Subnet) popPodNic(podName, nicName string) {
161161
subnet.PodToNicList[podName] = util.RemoveString(subnet.PodToNicList[podName], nicName)
162+
if subnet.PodToNicList[podName] == nil {
163+
delete(subnet.PodToNicList, podName)
164+
}
162165
}
163166

164167
func (subnet *Subnet) GetRandomAddress(podName, nicName string, mac string, skippedAddrs []string, checkConflict bool) (IP, IP, string, error) {

0 commit comments

Comments
 (0)