do not allocate MAC address when kube-ovn is called as an IPAM plugin #2816
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.
What type of this PR
Examples of user facing changes:
Which issue(s) this PR fixes:
Fixes #(issue-number)
WHAT
🤖 Generated by Copilot at 2503313
This pull request changes the type and handling of the mac address parameter in various functions and methods related to IP and MAC allocation, to use pointers to strings instead of strings. This allows for nil values to represent unassigned or unused mac addresses, and simplifies the logic and code readability. The pull request also refactors some code to handle different pod network providers more gracefully, and updates the test and benchmark code to match the new function signatures and arguments. The affected files are
pkg/controller/init.go
,pkg/controller/node.go
,pkg/controller/pod.go
,pkg/controller/vip.go
,pkg/controller/vpc_nat_gw_eip.go
,pkg/daemon/handler.go
,pkg/ipam/ipam.go
,pkg/ipam/subnet.go
,test/unittest/ipam_bench/ipam_test.go
, andtest/unittest/ipam/ipam.go
.🤖 Generated by Copilot at 2503313
HOW
🤖 Generated by Copilot at 2503313
GetStaticAddress
andGetRandomAddress
methods in theSubnet
struct from a string to a pointer to a string, to indicate whether a mac address was given or not, and handle the case where the pod network provider does not use mac addresses (link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link)UpdateIPCr
function in thehandler
andipam
packages, as it was no longer needed to update the IP CRD object (link,link,link,link,link,link)pod.go
andhandler.go
files, and set the pointer to nil if so, to handle the case where the pod network provider does not use mac addresses, such as the calico provider (link,link)pod.go
file, based on whether the pod network provider uses mac addresses or is ovn or not, to avoid unnecessary annotations for different providers (link)providerExists
function in thehandler.go
file to return a pointer to a Subnet object along with a boolean value, instead of just a boolean value, to avoid querying the subnet lister again in thehandleAdd
function, and to pass the subnet object to theUpdateIPCr
function (link,link,link)handleAdd
function in thehandler.go
file, to check if the subnet name was empty and use the pod subnet name instead, to handle the case where the pod network provider is not ovn and does not have a logical switch annotation (link)handleAdd
function in thehandler.go
file, as it was only needed to pass to theovs.Exec
function (link)GetStaticMac
method in theSubnet
struct in theipam
package, and return nil if so, to avoid generating a random mac address for providers that do not use mac addresses (link)GetStaticMac
method in theSubnet
struct from a string to a pointer to a string, to match the change in theGetStaticAddress
function signature (link,link,link,link)GetRandomAddress
andGetStaticAddress
methods in theSubnet
struct from a string to a pointer to anIP
struct, to unify the IP allocation logic for both IPv4 and IPv6 addresses, and to avoid parsing strings to IPs repeatedly (link,link,link,link,link,link,link,link)pod.go
file, to make the code more consistent and readable (link)