Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the pod info with persistent IP in the map is deleted incorrectly #374

Merged
merged 6 commits into from
Dec 1, 2022

Conversation

dxsup
Copy link
Member

@dxsup dxsup commented Nov 29, 2022

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?

=== RUN   TestUpdateAndDelayDelete
--- PASS: TestUpdateAndDelayDelete (1.00s)
=== RUN   TestUpdateAndDelayDeleteWhenOnlyPodIpChanged
--- PASS: TestUpdateAndDelayDeleteWhenOnlyPodIpChanged (1.00s)
=== RUN   TestUpdateAndDelayDeleteWhenOnlyPortChanged
--- PASS: TestUpdateAndDelayDeleteWhenOnlyPortChanged (1.00s)
=== RUN   TestDelayDeleteThenAddWithSameIP
--- PASS: TestDelayDeleteThenAddWithSameIP (0.20s)

Daxin Wang added 4 commits November 29, 2022 10:58
Signed-off-by: Daxin Wang <daxinwang@harmonycloud.cn>
Signed-off-by: Daxin Wang <daxinwang@harmonycloud.cn>
Signed-off-by: Daxin Wang <daxinwang@harmonycloud.cn>
Signed-off-by: Daxin Wang <daxinwang@harmonycloud.cn>
@dxsup dxsup requested a review from NeJan2020 November 29, 2022 09:19
NeJan2020
NeJan2020 previously approved these changes Dec 1, 2022
Signed-off-by: Daxin Wang <daxinwang@harmonycloud.cn>
NeJan2020
NeJan2020 previously approved these changes Dec 1, 2022
Signed-off-by: Daxin Wang <daxinwang@harmonycloud.cn>
@dxsup dxsup force-pushed the fix/delete-persistent-pod-ip branch from 9aa4c90 to 3446896 Compare December 1, 2022 09:49
@dxsup dxsup merged commit cb0516b into KindlingProject:main Dec 1, 2022
@dxsup dxsup deleted the fix/delete-persistent-pod-ip branch December 1, 2022 11:38
NeJan2020 pushed a commit to NeJan2020/kindling that referenced this pull request May 4, 2023
…KindlingProject#374)

Signed-off-by: Daxin Wang <daxinwang@harmonycloud.cn>
Signed-off-by: niejiangang <niejiangang@harmonycloud.cn>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants