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
Svc REST: clean up defaultOnRead to be consistent #104986
Svc REST: clean up defaultOnRead to be consistent #104986
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. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: 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 |
if len(service.Spec.IPFamilies) == 1 { | ||
service.Spec.IPFamilyPolicy = &singleStack | ||
} else if len(service.Spec.IPFamilies) == 2 { | ||
// It shouldn't be possible to get here, but just in case. | ||
service.Spec.IPFamilyPolicy = &requireDualStack | ||
} |
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 is this done inside the for loop?
I mean, it was this way before, but it can be set once we build the service.Spec.IPFamilies
array, no?
it depends on len(service.Spec.ClusterIPs)
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.
good catch!!
} else { | ||
// Headless + selector - default to single. |
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 this stops following cluster configuration? it will be incoherent with the generated endpoints.
And now that I see this, we are not using the IPFamilyPolicy field in the endpointslice controller :/
kubernetes/pkg/controller/endpointslice/utils.go
Lines 359 to 363 in 623f9f3
// headless | |
// for now we assume two families. This should have minimal side effect | |
// if the service is headless with no selector, then this will remain the case | |
// if the service is headless with selector then chances are pods are still using single family | |
// since kubelet will need to restart in order to start patching pod status with multiple ips |
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.
If this is a service that doesn't have ipFamilies set, it MUST have been created while the cluster was in single-stack mode. We decided that ipFamilyPolicy was authoritative, and the user never set that.
If we make it follow the cluster, then such a service will auto-upgrade and we decided we never wanted that, right?
This is the main bug in this PR, I think.
service.Spec.IPFamilies[idx] = api.IPv4Protocol | ||
} | ||
if len(service.Spec.IPFamilies) == 1 { | ||
service.Spec.IPFamilyPolicy = &singleStack |
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 if this was already set?
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 don't know how IPFamilyPolicy would be set but ipFamilies would not?
204af75
to
7639ab1
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 pushed with all fixes except the "has policy, but not ipfamilies" ones. We could code those but I don't see how they can ever trigger?
} else { | ||
// Headless + selector - default to single. |
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.
If this is a service that doesn't have ipFamilies set, it MUST have been created while the cluster was in single-stack mode. We decided that ipFamilyPolicy was authoritative, and the user never set that.
If we make it follow the cluster, then such a service will auto-upgrade and we decided we never wanted that, right?
This is the main bug in this PR, I think.
service.Spec.IPFamilies[idx] = api.IPv4Protocol | ||
} | ||
if len(service.Spec.IPFamilies) == 1 { | ||
service.Spec.IPFamilyPolicy = &singleStack |
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 don't know how IPFamilyPolicy would be set but ipFamilies would not?
if len(service.Spec.IPFamilies) == 1 { | ||
service.Spec.IPFamilyPolicy = &singleStack | ||
} else if len(service.Spec.IPFamilies) == 2 { | ||
// It shouldn't be possible to get here, but just in case. | ||
service.Spec.IPFamilyPolicy = &requireDualStack | ||
} |
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.
good catch!!
input: svctest.MakeService("foo", svctest.SetClusterIP("10.0.0.1")), | ||
expect: svctest.MakeService("foo", svctest.SetClusterIPs("10.0.0.1"), | ||
svctest.SetIPFamilyPolicy(api.IPFamilyPolicySingleStack), | ||
svctest.SetIPFamilies(api.IPv4Protocol)), |
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 is a copy paste error, right? it is the same test that the below test "no change v4"
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 one sets clusterIP
(singlular) but not plural.
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.
wow, so subtle, I swear I starred at the tests for 5 mins before commenting 🙃
name: "missing clusterIPs v6", | ||
input: svctest.MakeService("foo", svctest.SetClusterIP("2000::1")), | ||
expect: svctest.MakeService("foo", svctest.SetClusterIPs("2000::1"), | ||
svctest.SetIPFamilyPolicy(api.IPFamilyPolicySingleStack), | ||
svctest.SetIPFamilies(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.
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 answer
Headless+selectorless -> RequireDualStack Headless+selector -> SingleStack Add test cases to cover this and ExternalName and dual-stack init (which I think can never trigger, but best to be safe).
7639ab1
to
52f54ce
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.
Rebased and squashed, too.
input: svctest.MakeService("foo", svctest.SetClusterIP("10.0.0.1")), | ||
expect: svctest.MakeService("foo", svctest.SetClusterIPs("10.0.0.1"), | ||
svctest.SetIPFamilyPolicy(api.IPFamilyPolicySingleStack), | ||
svctest.SetIPFamilies(api.IPv4Protocol)), |
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 one sets clusterIP
(singlular) but not plural.
name: "missing clusterIPs v6", | ||
input: svctest.MakeService("foo", svctest.SetClusterIP("2000::1")), | ||
expect: svctest.MakeService("foo", svctest.SetClusterIPs("2000::1"), | ||
svctest.SetIPFamilyPolicy(api.IPFamilyPolicySingleStack), | ||
svctest.SetIPFamilies(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.
same answer
/lgtm |
Headless+selectorless -> RequireDualStack
Headless+selector -> SingleStack
Add test cases to cover this and ExternalName and dual-stack init (which
I think can never trigger, but best to be safe).
/kind bug