Fix opflexSnatLocalInfos cache deletion logic for pod #1478
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue: When multiple SNAT policies are continuously created and deleted, the snatlocalinfos CRs sometimes fail to be created for few nodes.
Root Cause: The opflexSnatLocalInfos for a pod was being deleted within the updateEpFiles function if no SNAT policy was selected for the pod. This function is triggered by both snatpolicy and snatglobalinfos events. In some cases, when a SNAT policy is deleted and recreated, the sequence of create and delete events for snatpolicy and snatglobalinfos can become unordered. This results in the deletion event of the previous SNAT policy occurring after the updation event of the snatglobalinfos for current policy, causing the current cache entry to be deleted after it is created. Consequently, the opflexSnatLocalInfos is not created due to a mismatch between opflexSnatLocalInfos and opflexSnatGlobalInfos.
Fix: The deletion of opflexSnatLocalInfos for a pod has been moved to function deleteSnatLocalInfo, which is triggered only by snatpolicy events and not by snatglobalinfos events.