Fix the pod info with persistent IP in the map is deleted incorrectly #374
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.
Description
We have implemented a mechanism to delete the pod metadata with a delay. We assumed the pod IP couldn't be reused in a short time, but in fact, IP addresses can be persistent in Kubernetes. If a pod is deleted and then a pod with the same IP is created, the delayed deletion will remove this new pod metadata from the cache map, in which case we can't find the pod information when processing data.
Since the UID of pods can identify a unique pod, I added it as a field of the
K8sPodInfo
struct. When the delayed deletion mechanism runs, only the pods with the same UID as the deletion requests are removed. This makes sure only those pods whose UIDs are not overwritten by new pods are deleted.How Has This Been Tested?