Fix pod IP deletion leak and namespace filtering issues#2116
Fix pod IP deletion leak and namespace filtering issues#2116aanchal22 wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Fixes a critical issue causing metrics collection failures Pod IPs were leaking in the eBPF filtermap due to metadata mismatch between ADD and DELETE operations. Metadata flags (pod/namespace) were re-evaluated at DELETE time instead of using values from ADD time, causing mismatches in: - IP reuse (tracked → untracked namespace) - Namespace filter changes after pod add - Annotation changes between add and delete **Solution:** Track which metadata was used during ADD and use the same metadata during DELETE, regardless of state changes. Namespace exclude filtering was broken, causing no metrics collection or eBPF map exhaustion Problems: - appendExcludeList() was empty (not implemented) - updateNamespaceLists() used sequential ifs instead of if/else - nsOfInterest() had incorrect default behavior - No protection against spurious DELETE events **Solution:** Implement namespace filtering. - Add metadataTrackingInfo struct to track metadata per IP - Record pod/namespace metadata after successful AddIPs - Use tracked metadata (not current flags) during DeleteIPs - Implement appendExcludeList() with proper initial setup - Fix updateNamespaceLists() if/else logic - Fix nsOfInterest() default to return true when no filtering - Add DELETE event protection (check cache before deleting) - Add GetAllNamespaces() to cache interface - Add warning logs for deleteIP failures - Eliminates memory leak (refcount reaches zero) - Fixes namespace exclude filtering - Handles IP reuse correctly - No breaking changes - Minimal overhead (~24 bytes per tracked IP) Signed off by: Aanchal Khandelwal (akhandelwal@adobe.com)
|
A few gaps I noticed from my investigation that the two PRs don't cover:
|
Fix: Pod IP Deletion Leak and Namespace Filtering (#2085)
Pod IPs were leaking in the eBPF filtermap because metadata flags (pod/namespace) were re-evaluated at DELETE time instead of using values recorded at ADD time. This caused mismatches during IP reuse,
namespace filter changes, and annotation changes.
Additionally, namespace exclude filtering was non-functional:
appendExcludeList()was empty (not implemented)updateNamespaceLists()used sequentialifinstead ofif/else ifnsOfInterest()had incorrect default behavior (returned false instead of true)Changes:
metadataTrackingInfostruct to track which metadata was used during ADDappendExcludeList()with proper initial setup viaGetAllNamespaces()updateNamespaceLists()if/else logic andnsOfInterest()defaultRelated Issue
Fixes #2085
Checklist
git commit -S -s ...).Testing Completed
go buildpassesAdditional Notes