-
Notifications
You must be signed in to change notification settings - Fork 161
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
New autodetection method KubernetesInternalIP added #1242
Conversation
Tagging for v3.22 |
@caseydavenport : Could you please prioritize it for v3.21 ? Our customer deployment needs this solution. |
630b3cf
to
dc1220a
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.
First pass - thanks for the PR! This is mostly looking good but I think we need to make a few structural changes to reduce the scale impact that a periodic node query on every node in the cluster can have. We'll also need unit tests for this in order to merge.
Let me know if you have any questions!
dc1220a
to
fcce869
Compare
pkg/lifecycle/startup/startup.go
Outdated
var config *rest.Config | ||
var k8sNode *v1.Node | ||
var err error | ||
if config, err = rest.InClusterConfig(); err != nil { |
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 code needs to work on non-kubernetes clusters as well - I'd suggest modeling after the logic above: https://github.com/projectcalico/node/pull/1242/files#diff-e481557bd1e2fed4cea80458ebb02e18797fdf49c42944f4a8d6c23cbfbec3f9R130
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.
modified as per suggestion
pkg/lifecycle/startup/startup.go
Outdated
@@ -772,6 +809,27 @@ func autoDetectCIDRBySkipInterface(ifaceRegexes []string, version int) *cnet.IPN | |||
return cidr | |||
} | |||
|
|||
// autoDetectUsingK8sInternalIP reads K8s Node InternalIP. | |||
func autoDetectUsingK8sInternalIP(version int, k8sNode *v1.Node) *cnet.IPNet { |
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 probably put this in the autodetection package along with the other methods.
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.
It would require moving the getLocalCIDR function with it, but I think that's OK
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.
modified as per suggestion
@hanamantagoudvk just checking in on this one - did you see my latest comments? |
fcce869
to
95fae8a
Compare
@caseydavenport : Sorry for the delay. Uploaded the new patchset. I am still not able to run UT cases in my setup. |
8928fb7
to
be54246
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 have nothing major against this change, tbh I like that it is coming, we did consider it for eBPF and then we went different way. So great! 👍 I will leave it to @caseydavenport to approve.
@@ -78,6 +100,32 @@ func makeNode(ipv4 string, ipv6 string) *libapi.Node { | |||
return n | |||
} | |||
|
|||
// makeK8sNode creates an v1.Node with some Addresses populated. | |||
func makeK8sNode(ipv4 string, ipv6 string) *v1.Node { |
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 function is used only with ipv4 ...
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.
same comment as below
ip6, ip6net, _ := net.ParseCIDR(ipv6) | ||
// Guard against nil here in case we pass in an empty string for IPv6. | ||
if ip6 != nil { | ||
ip6net.IP = ip6.IP | ||
} | ||
ip6Addr = ip6net.String() |
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.
why don't we do this for ipv4? TBH this is test code and we can assume that the test passes in valid addresses, nothing that changes dynamically. It would be more interesting to test different permutations, mix with other address types etc.
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 i want to add various combinations with IPv4
and IPv6
addresses, but not able to mock the GetInterfaces
method inside autoDetectUsingK8sInternalIP
. Due to that , configureIPsAndSubnets
always returns false
f7ff901
to
10b46d9
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 mostly don't understand why we're now passing DEFAULT_INTERFACES_TO_EXCLUDE as an argument through several layers of call stack, especially since it's not used in the new autodetection method. We should revert that.
Otherwise this is looking good.
pkg/lifecycle/startup/startup.go
Outdated
} | ||
|
||
configureAndCheckIPAddressSubnets(ctx, cli, node) | ||
configureAndCheckIPAddressSubnets(ctx, cli, node, k8sNode, DEFAULT_INTERFACES_TO_EXCLUDE) |
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 we should revert this change to pass DEFAULT_INTERFACES_TO_EXCLUDE all the way through the call stack of the autodetection functions. It seems to be an extra argument just to pass a constant value.
/sem-approve |
10b46d9
to
1158d9a
Compare
@hanamantagoudvk you've got an import cycle looks like:
|
@caseydavenport |
Should probably just move DEFAULT_INTERFACES_TO_EXCLUDE to the autodetection package then, right? |
1158d9a
to
4b9eb96
Compare
@caseydavenport |
@caseydavenport : Please review it and let me know if anything is pending ? I am not able to see the below errors in |
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 - Thanks for all of the hard work on this @hanamantagoudvk
@hanamantagoudvk just a static check failure it looks like:
|
4b9eb96
to
5df8bf5
Compare
@caseydavenport , what else is failing now ? |
I think they were test flakes, kicked off another build. |
This test appears to be failing consistently |
5df8bf5
to
2a36b23
Compare
@hanamantagoudvk thanks for sticking with this! Glad we got it merged. What was the last issue with that test? I couldn't tell because the commits were squashed. Also, are you planning to do documentation for this PR? If so I can help. Similarly, we probably want operator support for this feature as well - I can pick that up if you're strapped for time. |
@caseydavenport , basically ginkgo orders the testcases alphabetically. So the tests i added were run before the existing one and it was setting the Regarding documentation , yes i can do the documentation. Ya that operator support , you can pick that up. |
@caseydavenport , regarding documentation , i believe in calico website where different autodetection methods are listed , we need to this new one as well. Other than anywhere else we need to capture this one ? If i need to modify the calico website content , which repo i need to look at and modify it ? |
Description
New autodetection method KubernetesInternalIP / KubernetesInternalIP6 being introduced so that calico can always pick the node IP deterministically.
Fixes projectcalico/calico#4870
Fixes projectcalico/calico#5090