-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Fixed IPv4 podCIDR check in case spec.PodCIDR is IPv6 #1672
Conversation
Signed-off-by: Roberto Bonafiglia <[email protected]>
3ce665a
to
70c6f43
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 just checked on 1.24 and podCIDRs == 0 is something that should never happen. It might be because of the old version of Hyperkube we are using, I'd recommend to first update that version and then see if this issue still exists
subnet/kube/kube.go
Outdated
|
||
for _, podCidr := range n.Spec.PodCIDRs { | ||
_, parseCidr, err := net.ParseCIDR(podCidr) | ||
if len(n.Spec.PodCIDRs) == 0 { |
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 about adding a switch:
switch len(n.Spec.PodCIDRs) {
case 0:
// do stuff with n.Spec.PodCIDR
case len(n.Spec.PodCIDRs) < 3:
// do stuff with n.Spec.PodCIDRs
default:
// fail!
That way we are protected of weird cases
subnet/kube/kube.go
Outdated
_, cidr, err := net.ParseCIDR(n.Spec.PodCIDR) | ||
if err != nil { | ||
return l, err | ||
cidr := new(net.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.
I think it is cleaner to define it as it was in line 296
subnet/kube/kube.go
Outdated
if err != nil { | ||
return l, err | ||
cidr := new(net.IPNet) | ||
if len(n.Spec.PodCIDRs) == 0 { |
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 here with the switch
return l, err | ||
cidr := new(net.IPNet) | ||
if len(n.Spec.PodCIDRs) == 0 { | ||
_, cidr, err = net.ParseCIDR(n.Spec.PodCIDR) |
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.
Don't you need to check if this is ipv6 or 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.
No because if IPv4 is enabled and no IPv4 CIDR is specified on the pod subnet Flannel should throw an error before the subnet manager starts.
return l, err | ||
} | ||
} else { | ||
log.Infof("Creating the node lease for IPv4. This is the n.Spec.PodCIDRs: %v", n.Spec.PodCIDRs) |
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 log will only be correct if len =1, right?
Signed-off-by: Roberto Bonafiglia <[email protected]>
70c6f43
to
c2d1dab
Compare
Description
When using kubeadm if the podSubnet is dualstack and specified as IPv6,IPv4 spec.PodCIDR of the node will be the IPv6 and Flannel will fail to check the IPv4 CIDR. (#1629).
This PR will remove the check of spec.PodCIDR to always check spec.PodCIDRs for both IPv4 and IPv6.
Todos
Release Note