Skip to content

fix ip statistics in subnet status #2769

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

Merged
merged 1 commit into from
May 9, 2023

Conversation

zhangzujian
Copy link
Member

@zhangzujian zhangzujian commented May 8, 2023

What type of this PR

  • Bug fixes

Which issue(s) this PR fixes:

Fixes incorrect ip statistics in subnet status:

  v4availableIPrange:      10.16.0.2-10.16.0.3,10.16.0.5,10.16.0.7-10.16.0.16,10.16.0.18-10.16.0.20,10.16.0.23-10.16.255.254
  v4availableIPs:          65529
  v4usingIPrange:          10.16.0.4,10.16.0.6,10.16.0.17,10.16.0.21-10.16.0.22
  v4usingIPs:              4

During deleting a pod, kube-ovn-controller deletes the IP CR first and then releases the IP address. There is a chance that subnet status update is triggered by the IP CR deletion before the IP address is released.

This patch fixes the ip statistics by releasing the IP address before deleting the IP CR.

WHAT

🤖 Generated by Copilot at 6d17481

This pull request improves the IP address management for pods by avoiding duplicate or stale allocations. It modifies the pod.go file to release the pod's IP address only once and before assigning a new one.

🤖 Generated by Copilot at 6d17481

Oh we are the coders of the pod.go file
And we work on the logic of the IP address style
We release the old one before we assign the new
To prevent the conflicts and the leaks that ensue

HOW

🤖 Generated by Copilot at 6d17481

  • Release the IP address of a pod if it is marked for deletion, before allocating a new one, to avoid IP address conflicts and leaks in handleAddUpdatePod (link)
  • Remove the redundant call to release the IP address of a pod in handleDeletePod, since it is already done in handleAddUpdatePod (link)

@zhangzujian zhangzujian added bug Something isn't working need backport subnet labels May 8, 2023
@github-actions
Copy link
Contributor

github-actions bot commented May 8, 2023

  • The order of the newly added code in handleDeletePod function should be reviewed. It is recommended to release the IP address before getting the pod networks.
  • The error handling mechanism in getPodKubeovnNets function should be improved. Currently, if an error occurs, it only logs the error and continues execution. This may lead to unexpected behavior and should be handled properly.
  • The naming convention of variables can be improved for better readability. For example, podNets can be renamed to podNetworks.
  • The syncVirtualPortsQueue.Add(podNet.Subnet.Name) line can be moved outside the for loop to improve performance. This will avoid adding the same subnet name multiple times to the queue.
  • It is recommended to add comments to the code to explain the purpose of each function and variable. This will make it easier for other developers to understand the code and maintain it in the future.

@zhangzujian zhangzujian marked this pull request as ready for review May 8, 2023 09:55
@zhangzujian zhangzujian requested a review from oilbeater May 8, 2023 09:55
@zhangzujian zhangzujian merged commit 62d8122 into kubeovn:master May 9, 2023
@zhangzujian zhangzujian deleted the fix-subnet-status branch May 9, 2023 02:22
zhangzujian added a commit that referenced this pull request May 9, 2023
zhangzujian added a commit that referenced this pull request May 9, 2023
zhangzujian added a commit that referenced this pull request May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working need backport subnet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants