-
Notifications
You must be signed in to change notification settings - Fork 39.3k
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
buildPortsToEndpointsMap should use flattened value type #76737
Conversation
Hi @tedyu. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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 NOT APPROVED This pull-request has been approved by: tedyu If they are not already assigned, you can assign the PR to them by writing 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 |
ping @brendandburns @vishh @freehan for review |
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.
thanks for the PR
/remove-kind bug
/kind cleanup
/priority backlog
/ok-to-test
ping @thockin @smarterclayton for review |
@freehan |
ping @danwinship @dcbw for review |
ping @danwinship @dcbw |
ping @dcbw for review |
@@ -245,16 +245,19 @@ func (lb *LoadBalancerRR) updateAffinityMap(svcPort proxy.ServicePortName, newEn | |||
|
|||
// buildPortsToEndpointsMap builds a map of portname -> all ip:ports for that | |||
// portname. Expode Endpoints.Subsets[*] into this structure. | |||
func buildPortsToEndpointsMap(endpoints *v1.Endpoints) map[string][]hostPortPair { | |||
portsToEndpoints := map[string][]hostPortPair{} | |||
func buildPortsToEndpointsMap(endpoints *v1.Endpoints) map[string][]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.
This really needs a test to prove that it didn't change. Also, I'm not sure why we would want to weaken the type?
ping @dcbw for review |
portsToEndpoints[port.Name] = append(portsToEndpoints[port.Name], hostPortPair{addr.IP, int(port.Port)}) | ||
// Ignore the protocol field - we'll get that from the Service objects. | ||
hpp := &hostPortPair{addr.IP, int(port.Port)} | ||
if isValidEndpoint(hpp) { |
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.
You should just make isValidEndpoint
take an IP and port. And then I believe the entire hostPortPair type would be unused. Also, flattenValidEndpoints
would be unused (other than the test case in roundrobin_test.go
which is pointless now since nothing in the real code is using that function). So it could also be removed. And as Clayton said before, there ought to be a unit test of buildPortsToEndpointsMap
.
Also, pkg/proxy/winuserspace/
uses exactly the same code and should get exactly the same fix
@danwinship |
What type of PR is this?
/kind bug
What this PR does / why we need it:
Currently buildPortsToEndpointsMap uses []hostPortPair as value type.
Looking at the calls to this func:
We always flatten the value before using it.
Which issue(s) this PR fixes:
Fixes #76718