Skip to content
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

Fix service entry merge #50711

Merged
merged 9 commits into from May 1, 2024
Merged

Conversation

howardjohn
Copy link
Member

@howardjohn howardjohn commented Apr 26, 2024

Throwing in my attempt at fixing #50478.
Note this pairs well with #50690 to fix the EDS issue (#50688). With both PRs, all known issues are fixed.

There are a few approaches here:

Approach 1

Up to 1.19.8 the created clusters are one per port without LB between ports:

outbound|80||news.google.com::172.217.22.110:80
outbound|8080||news.google.com::172.217.22.110:8080

This behavior is, IMO, what a user expects. While the port names are colliding, user probably doesn't really care -- they care about the number. This also is the behavior if the port names did not collide.

This was the behavior in 1.19 and what I implemented here.

Approach 2

Cross product the ports:

outbound|80||news.google.com::172.217.22.110:80
outbound|80||news.google.com::172.217.22.110:8080
outbound|8080||news.google.com::172.217.22.110:80
outbound|8080||news.google.com::172.217.22.110:8080

I don't see a good reason to ever want this approach

Approach 3

Merge down to a single service port, but with an endpoint per port. Implemented in #50691

outbound|80||news.google.com::172.217.22.110:80
outbound|80||news.google.com::172.217.22.110:8080

The difference from 1 and 3 comes down to how we intepret them. In a Service, they key could logically be considered the name OR the number; because they must be distinct, there is never any difference between those. We happen to use name throughout Istio, but that is an internal detail.

This PR takes the opposite approach and makes the number effectively the key.

Note: I 100% agree the approach here is incredibly hacky. If we want to go down this route, I will try to make it suck less and add tests.

@howardjohn howardjohn added the release-notes-none Indicates a PR that does not require release notes. label Apr 26, 2024
@istio-testing
Copy link
Collaborator

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@istio-testing istio-testing added do-not-merge/work-in-progress Block merging of a PR because it isn't ready yet. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 26, 2024
@howardjohn howardjohn marked this pull request as ready for review April 29, 2024 22:26
@howardjohn howardjohn requested review from a team as code owners April 29, 2024 22:26
@istio-testing istio-testing added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed do-not-merge/work-in-progress Block merging of a PR because it isn't ready yet. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 29, 2024
@howardjohn howardjohn added cherrypick/release-1.20 Set this label on a PR to auto-merge it to the release-1.20 branch cherrypick/release-1.21 Set this label on a PR to auto-merge it to the release-1.21 branch cherrypick/release-1.22 Set this label on a PR to auto-merge it to the release-1.22 branch labels Apr 29, 2024
Copy link
Contributor

@keithmattix keithmattix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much cleaner than the previous implementation IMO. LGTM

@@ -94,15 +94,26 @@ func (es *EndpointShards) Keys() []ShardKey {

// CopyEndpoints takes a snapshot of all endpoints. As input, it takes a map of port name to number, to allow it to group
// the results by service port number. This is a bit weird, but lets us efficiently construct the format the caller needs.
func (es *EndpointShards) CopyEndpoints(portMap map[string]int) map[int][]*IstioEndpoint {
func (es *EndpointShards) CopyEndpoints(portMap map[string]int, ports sets.Set[int]) map[int][]*IstioEndpoint {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we initialize the ports sets from portMap in this function

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that makes sense. I was thinking it was faster to do it this way, but it shouldn't be

Copy link
Member

@ymesika ymesika left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG, thanks

@zirain zirain requested review from hzxuzhonghu and zirain May 1, 2024 01:03
Copy link
Member

@hzxuzhonghu hzxuzhonghu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tks

@istio-testing istio-testing merged commit 91868f7 into istio:master May 1, 2024
28 checks passed
@istio-testing
Copy link
Collaborator

In response to a cherrypick label: new pull request created: #50773

@istio-testing
Copy link
Collaborator

In response to a cherrypick label: #50711 failed to apply on top of branch "release-1.20":

Applying: Fix service entry merge
Applying: Add test
Applying: add release notes
Applying: better test
Applying: working except stable ordering
Using index info to reconstruct a base tree...
M	pilot/pkg/serviceregistry/serviceentry/conversion.go
M	pilot/pkg/xds/cds_test.go
Falling back to patching base and 3-way merge...
Auto-merging pilot/pkg/xds/cds_test.go
Auto-merging pilot/pkg/serviceregistry/serviceentry/conversion.go
Applying: sort
Applying: Refactor
Using index info to reconstruct a base tree...
M	pilot/pkg/model/endpointshards.go
M	pilot/pkg/model/push_context.go
M	pilot/pkg/model/service.go
M	pilot/pkg/serviceregistry/serviceentry/conversion.go
Falling back to patching base and 3-way merge...
Auto-merging pilot/pkg/serviceregistry/serviceentry/conversion.go
Auto-merging pilot/pkg/model/service.go
Auto-merging pilot/pkg/model/push_context.go
Auto-merging pilot/pkg/model/endpointshards.go
Applying: fix tests
Using index info to reconstruct a base tree...
M	pilot/pkg/model/endpointshards.go
M	pilot/pkg/model/push_context.go
M	pilot/pkg/model/service.go
M	pilot/pkg/serviceregistry/serviceentry/conversion.go
Falling back to patching base and 3-way merge...
Auto-merging pilot/pkg/serviceregistry/serviceentry/conversion.go
Auto-merging pilot/pkg/model/service.go
Auto-merging pilot/pkg/model/push_context.go
CONFLICT (content): Merge conflict in pilot/pkg/model/push_context.go
Auto-merging pilot/pkg/model/endpointshards.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0008 fix tests
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

@istio-testing
Copy link
Collaborator

In response to a cherrypick label: new issue created for failed cherrypick: #50774

@istio-testing
Copy link
Collaborator

In response to a cherrypick label: #50711 failed to apply on top of branch "release-1.21":

Applying: Fix service entry merge
Applying: Add test
Applying: add release notes
Applying: better test
Applying: working except stable ordering
Using index info to reconstruct a base tree...
M	pilot/pkg/serviceregistry/serviceentry/conversion.go
Falling back to patching base and 3-way merge...
Auto-merging pilot/pkg/serviceregistry/serviceentry/conversion.go
Applying: sort
Applying: Refactor
Using index info to reconstruct a base tree...
M	pilot/pkg/model/endpointshards.go
M	pilot/pkg/model/push_context.go
M	pilot/pkg/model/service.go
M	pilot/pkg/serviceregistry/serviceentry/conversion.go
Falling back to patching base and 3-way merge...
Auto-merging pilot/pkg/serviceregistry/serviceentry/conversion.go
Auto-merging pilot/pkg/model/service.go
Auto-merging pilot/pkg/model/push_context.go
Auto-merging pilot/pkg/model/endpointshards.go
Applying: fix tests
Using index info to reconstruct a base tree...
M	pilot/pkg/model/endpointshards.go
M	pilot/pkg/model/push_context.go
M	pilot/pkg/model/service.go
M	pilot/pkg/serviceregistry/serviceentry/conversion.go
Falling back to patching base and 3-way merge...
Auto-merging pilot/pkg/serviceregistry/serviceentry/conversion.go
Auto-merging pilot/pkg/model/service.go
Auto-merging pilot/pkg/model/push_context.go
CONFLICT (content): Merge conflict in pilot/pkg/model/push_context.go
Auto-merging pilot/pkg/model/endpointshards.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0008 fix tests
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

@istio-testing
Copy link
Collaborator

In response to a cherrypick label: new issue created for failed cherrypick: #50775

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherrypick/release-1.20 Set this label on a PR to auto-merge it to the release-1.20 branch cherrypick/release-1.21 Set this label on a PR to auto-merge it to the release-1.21 branch cherrypick/release-1.22 Set this label on a PR to auto-merge it to the release-1.22 branch release-notes-none Indicates a PR that does not require release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants