-
Notifications
You must be signed in to change notification settings - Fork 338
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
udn, allocator: Add masquerade IPs #4458
Conversation
de5936b
to
af14b5b
Compare
Changes unknown |
50ad17e
to
7b64fd7
Compare
2afbcdc
to
e554a75
Compare
e554a75
to
597edb5
Compare
597edb5
to
0c99b2c
Compare
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 think first 4 commits are missing UTs + we should add docs for these https://ovn-kubernetes.io/getting-started/configuration/#gateway-config once we finalize them
reviewed half way till commit6 thanks for the split makes it easy.
98bf1c0
to
f8495e9
Compare
@tssurya adding events here is worth it ? |
f8495e9
to
43c57c4
Compare
10e25f0
to
472f5b8
Compare
if !subnetCIDR.Contains(masqueradeIP) { | ||
return nil, fmt.Errorf("failed calculating user defined network %s masquerade IPs: IP %s is not within subnet %s", idName, masqueradeIP, subnetCIDR) | ||
} |
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 think I'd move this outside the loop and call it twice. Like that it would allow us to specify which of the two IPs (Shared or Local) fallse outside the subnet.
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.
Since this is call per Network we will not hurt performance too much, I will do that.
472f5b8
to
4ecc3c9
Compare
// added to the subnet (169.254.169.0) with AddIPOffset to convert the offset to the | ||
// masquerade IPs 169.254.169.13 and 169.254.169.14 | ||
numberOfIPs := 2 | ||
previousNetworkID := networkID - 1 |
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.
and just to be sure the networkIDs are serially getting allocated correct? can there be a gap value or something where a number never got allocated? meaning networkID is valid given we will pass it from netInfo, using networkID-1 as the previous network's ID is that a guaranteed scenario always?
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.
and just to be sure the networkIDs are serially getting allocated correct?
We don't care if they are serial or not, we just care about the stuff starting from our network-id.
can there be a gap value or something where a number never got allocated?
Even if there is a gap it does not affect the fact that we are going to start from the networkID
meaning networkID is valid given we will pass it from netInfo, using networkID-1 as the previous network's ID is that a guaranteed scenario always?
We know for sure that our networks start from 1 so the lower limit of network-1 is going to be 0 so all is good.
4ecc3c9
to
9484d61
Compare
9484d61
to
43b1487
Compare
// Let's illustrate the expected IPs for networkID 1 and 2 | ||
// with userDefinedNetworkMasqueradeIPBase=10 and subnet=169.254.169.0/16 | ||
// networkID=1 | ||
// Shared: 169.254.169.11 |
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.
nit: this sticked as shared/local
firstIPOffset := secondIPOffset - 1 | ||
|
||
masqueradeIPs := &MasqueradeIPs{} | ||
masqueradeIPs.GatewayRouter, err = ipGenerator.GenerateIP(firstIPOffset) |
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.
looks really nice now!
43b1487
to
fb7df6c
Compare
f370c4c
to
e165b0e
Compare
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 lgtm
Waiting for LGTM from @dceara and/or @pperiyasamy
Thanks @qinqon for a nice API, LGTM from me. |
|
||
// For networkID=2 and base=10 this will be 14 | ||
secondIPOffset := userDefinedNetworkMasqueradeIPBase + networkID*numberOfIPs | ||
|
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.
Nit: numberOfIPs
seems a bit superfluous. We assume anyway that it's always 2. Why not just call:
ipGenerator.GenerateIP(userDefinedNetworkMasqueradeIPBase + networkID * numberOfIPs -1)
and:
ipGenerator.GenerateIP(userDefinedNetworkMasqueradeIPBase + networkID * numberOfIPs)
e165b0e
to
8364358
Compare
Add a function to calculate the masquerade IPs for shared and local gw for user defined networks. Signed-off-by: Enrique Llorente <[email protected]>
8364358
to
c8e2e27
Compare
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, thanks!
What this PR does and why is it needed
Add a function to calculate the
masquerade IPs for shared and local gw for user defined networks.
Depends-on:
ipgenerator
to its own pkg #4503How to verify it
There are some unit test tesing masquerade IPs generation
Details to documentation updates
NONE
Description for the changelog
Add user defined network masquerade IPs generator
Does this PR introduce a user-facing change?
NONE