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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor IPAM #2896

Merged
merged 1 commit into from Jun 5, 2023
Merged

refactor IPAM #2896

merged 1 commit into from Jun 5, 2023

Conversation

zhangzujian
Copy link
Member

@zhangzujian zhangzujian commented Jun 3, 2023

What type of this PR

Examples of user facing changes:

  • Features
  • Bug fixes
  • Docs
  • Tests

Which issue(s) this PR fixes:

Fixes #(issue-number)

WHAT

馃 Generated by Copilot at 91f76ed

This pull request refactors the ipam package and its related code in the controller and test packages to use new types and methods for IP ranges and lists. This improves the performance, readability, and consistency of the code.

馃 Generated by Copilot at 91f76ed

Sing, O Muse, of the mighty deeds of the ipam package
That refines and restructures the logic of IP ranges
With the help of the net package, the skilled and cunning helper
And the new types and methods, the swift and graceful shapers

HOW

馃 Generated by Copilot at 91f76ed

  • Encapsulate the IPRange logic and operations in a separate file and type pkg/ipam/ip_range.go (link)
  • Encapsulate the IPRangeList logic and operations in a separate file and type pkg/ipam/ip_range_list.go (link)
  • Use the net package to parse and format IP addresses in pkg/ipam/ip.go (link)
  • Use the fmt package to format strings in pkg/ipam/ipam.go (link)
  • Use the new IPRangeList constructor to create IPRangeList objects from slices of strings, and avoid calling the same function twice in pkg/ipam/ipam.go (link, link)
  • Use the new IPRangeList method to format the IPRangeList as a string, and move the logging statement after the condition check in pkg/ipam/ipam.go (link)
  • Replace the use of map[string]ipam.IPRange with map[string]*ipam.IPRange, and use constructors to ensure the validity of the IPRange and IP values in pkg/controller/subnet.go (link)
  • Replace the use of ipam.IPRange with *ipam.IPRange as the value type of the mapIps and newMap variables, and pass the pointer to the filterRepeatIPRange function in pkg/controller/subnet.go (link, link)
  • Use methods to access the IPRange fields instead of direct access in pkg/controller/subnet.go (link)
  • Use the new IPRangeList and IPRange methods instead of direct access and len function in test/unittest/ipam/ipam.go (link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link)
  • Use the new IP constructor to create IP objects, and use the new IP methods to compare IP objects instead of strings in test/unittest/ipam/ipam.go (link, link, link, link, link, link)
  • Use the new IPRange constructor to create IPRange objects, and use the new IPRange method to check if an IP is in an IPRange instead of the IP method in test/unittest/ipam/ipam.go (link)
  • Use the consistent assertion style with To instead of ShouldNot in test/unittest/ipam/ipam.go (link, link, link, link)
  • Remove an empty line in test/unittest/ipam/ipam.go (link)

@zhangzujian zhangzujian added the performance Anything that can make Kube-OVN faster label Jun 3, 2023
@zhangzujian zhangzujian merged commit 2f52d92 into kubeovn:master Jun 5, 2023
56 of 57 checks passed
@zhangzujian zhangzujian deleted the ipam branch June 5, 2023 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Anything that can make Kube-OVN faster
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants