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
Two small bugs in dual-stack init #99555
Two small bugs in dual-stack init #99555
Conversation
@thockin: This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@@ -3892,7 +3892,7 @@ func TestDefaultingValidation(t *testing.T) { | |||
}, | |||
}, | |||
expectedIPFamilyPolicy: &preferDualStack, | |||
expectedIPFamilies: []api.IPFamily{api.IPv4Protocol}, | |||
expectedIPFamilies: []api.IPFamily{api.IPv4Protocol, api.IPv6Protocol}, |
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 if you "prefer" (not "require") and the cluster is single stack we have 2 ip families?
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.
Headless, selector-less semantics.
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.
Basically, this is a corner case we can't comprehend from Service alone. It could already be holding dual-stack endpoints (I know some users were doing this). So we acknowledge that and admit that this Service could have both. "require" vs "prefer" was what we specced - it felt more explicit.
|
||
// Special-case: headless+selectorless | ||
if len(service.Spec.ClusterIPs) > 0 && service.Spec.ClusterIPs[0] == api.ClusterIPNone && len(service.Spec.Selector) == 0 { | ||
// If the use said nothing about policy and we can't infer it, they get dual-stack |
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.
is this not against the least surprise principle?
previous behaviour was the same as before dualstack
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.
a case could be made that it has zero effect on user. As a matter of fact users already use that to create dual stack endpoints for non dualstack clusters today (before dual stack became a thing on kubernetes)
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.
Yeah, we don't enforce that they can't create Endpoints of any family. At this case we just need to pick a value for the policy. RequireDual was what we wrote in the KEP.
nit: Please add release notes. Behavior is changing on single stack clusters. re second part of the PR ( kubernetes/pkg/apis/core/v1/defaults.go Lines 139 to 142 in e4e9c31
|
15e9642
to
e27168d
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.
Stray comments removed.
|
||
// Special-case: headless+selectorless | ||
if len(service.Spec.ClusterIPs) > 0 && service.Spec.ClusterIPs[0] == api.ClusterIPNone && len(service.Spec.Selector) == 0 { | ||
// If the use said nothing about policy and we can't infer it, they get dual-stack |
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.
Yeah, we don't enforce that they can't create Endpoints of any family. At this case we just need to pick a value for the policy. RequireDual was what we wrote in the KEP.
@@ -3892,7 +3892,7 @@ func TestDefaultingValidation(t *testing.T) { | |||
}, | |||
}, | |||
expectedIPFamilyPolicy: &preferDualStack, | |||
expectedIPFamilies: []api.IPFamily{api.IPv4Protocol}, | |||
expectedIPFamilies: []api.IPFamily{api.IPv4Protocol, api.IPv6Protocol}, |
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.
Basically, this is a corner case we can't comprehend from Service alone. It could already be holding dual-stack endpoints (I know some users were doing this). So we acknowledge that and admit that this Service could have both. "require" vs "prefer" was what we specced - it felt more explicit.
That leaves a hole in the REST tests I am adding in the larger rework effort. Maybe it makes sense to just do it all here and remove that defaulting? |
e27168d
to
b21cf1a
Compare
I added a second commit which removes the code in defaults.go - it is all handled in REST anyway. |
/test pull-kubernetes-dependencies |
LGTM |
/retest |
/lgtm |
Imporved testing turned these up: 1) Headless+Selectorless, on a single-stack cluster, policy=PreferDual Prior to this commit, the result was a single IPFamiliy (because we checked that the 2nd allocator was present). This changes that case to populate both families (we don't care if the allocator exists), which is the same as RequireDual. 2) ClusterIP, user specifies 2 families but no IPs Prior to this commit, the policy was inferred to be SingleStack. This changes that case to correctly default to RequireDual when 2 families are present but no IPs.
These same values are set in the REST stack and it's easier to maintain that code all in one place. defaults.go is best for static values.
It looks like the go 1.15 is being used in the test? When I run these locally they pass.. |
b21cf1a
to
84856c7
Compare
Rebased |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: khenidak, thockin The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/test pull-kubernetes-e2e-kind-ipv6 |
Working on the REST overhaul, adding testing turned these up:
Prior to this commit, the result was a single IPFamiliy (because we
checked that the 2nd allocator was present). This changes that case to
populate both families (we don't care if the allocator exists), which is
the same as RequireDual.
Prior to this commit, the policy was inferred to be SingleStack. This
changes that case to correctly default to RequireDual when 2 families
are present but no IPs.