-
Notifications
You must be signed in to change notification settings - Fork 386
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
Support multiple IPPools for secondary network IPAM #3606
Conversation
55d5c11
to
c3cd66f
Compare
Codecov Report
@@ Coverage Diff @@
## main #3606 +/- ##
===========================================
- Coverage 64.27% 50.33% -13.95%
===========================================
Files 278 248 -30
Lines 27929 35644 +7715
===========================================
- Hits 17952 17942 -10
- Misses 8062 15905 +7843
+ Partials 1915 1797 -118
Flags with carried forward coverage won't be shown. Click here to find out more.
|
c3cd66f
to
2c35aeb
Compare
b980589
to
e9fab29
Compare
7b325e4
to
9d8d6f3
Compare
/test-all |
/test-flexible-ipam-e2e |
ce7c150
to
70e6157
Compare
|
||
index := -1 | ||
for i, allocator := range allocators { | ||
if allocator.Has(ip) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This returns true if IP is in given range, regardless if it is allocated - I think this can cause confusion while reading this code. Perhaps we should rename it to avoid confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the right name in your mind? But anyway it is not relevant to this PR, and I prefer not to change it in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, its just a thought not relevant for the PR. Perhaps belongs
would be a more fitting name.
/test-all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
pkg/ipam/poolallocator/allocator.go
Outdated
func (a *IPPoolAllocator) HasContainer(containerID, ifName string) (bool, error) { | ||
|
||
// HasContainer checks whether an IP was associated with specified container. It returns error if the IPPool CR fails to be retrieved. | ||
func (a *IPPoolAllocator) HasContainer(containerID, ifName string) (net.IP, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we call the method something like "GetIPByContainer" given the change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to keep the name, as we have other HasXXX(), though I know this func now returns an IP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But HasPod method indeed returns whether it "Has" the Pod
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Changed to GetContainerIP().
pkg/ipam/poolallocator/allocator.go
Outdated
@@ -540,11 +567,9 @@ func (a *IPPoolAllocator) ReleaseContainer(containerID, ifName string) error { | |||
return err | |||
} | |||
|
|||
// HasResource checks whether an IP was associated with specified pod. It returns error if the resource is crd fails to be retrieved. | |||
// HasResource checks whether an IP was associated with specified pod. It returns error if the IPPool CR fails to be retrieved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not introduced by this PR, but could be corrected with the change. s/HasResource/HasPod/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Let me change it.
With the change, multiple IPPools can be specified in the CNI IPAM config, and then antrea-agent will try allocating one IP in each IPPool for the secondary network interface. An example CNI config: { "cniVersion": "0.3.0", "type": "macvlan", "master": "enp0s9", "mode": "bridge", "ipam": { "type": "antrea-ipam", "ippool": ["ippool-v4", "ipppol-v6"] } } Signed-off-by: Jianjun Shen <shenj@vmware.com>
70e6157
to
b4edd18
Compare
/test-all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
With this change, multiple IPPools can be specified in the CNI IPAM
config, and then antrea-agent will try allocating one IP in each IPPool
for the secondary network interface.
Signed-off-by: Jianjun Shen shenj@vmware.com