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

networking: match multiple VIPs in sidecar outbound listener #51967

Merged

Conversation

jewertow
Copy link
Member

@jewertow jewertow commented Jul 9, 2024

Please provide a description of this PR:

Fixes #51747

What did I change:

  1. GetAllAddressesForProxy and GetExtraAddressesForProxy always return all addresses for the proxy's IP family. Previously these functions were returning all addresses only when ISTIO_DUAL_STACK was enabled.
  2. buildSidecarOutboundListener used these functions to configure CIDR matching. These functions always returned the default address, so outbound listeners couldn't match all the addresses. Now, all CIDRs are configured for the supported IP family.
  3. convertServices created internal service instance for each [host, address] pair. Now, it creates an instance for each [host, address list] pair.

Example:
When the following SE is applied:

apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
  name: dns
spec:
  hosts:
  - "fake.service.local"
  addresses:
  - 10.123.16.192/28
  - 10.123.16.208/28
  - 10.123.16.224/28
  location: MESH_EXTERNAL
  resolution: NONE
  ports:
  - number: 9092
    name: tcp
    protocol: TCP

and I check listeners for port 9092:

istioctl pc l deploy/sleep --port 9092

I get the following results:

  1. Istio 1.21:
ADDRESSES PORT MATCH                  DESTINATION
0.0.0.0   9092 ALL                    PassthroughCluster
0.0.0.0   9092 Addr: 10.123.16.192/28 Cluster: outbound|9092||fake.service.local
0.0.0.0   9092 Addr: 10.123.16.208/28 Cluster: outbound|9092||fake.service.local
0.0.0.0   9092 Addr: 10.123.16.224/28 Cluster: outbound|9092||fake.service.local
  1. Istio 1.22:
ADDRESSES PORT MATCH                  DESTINATION
0.0.0.0   9092 ALL                    PassthroughCluster
0.0.0.0   9092 Addr: 10.123.16.192/28 Cluster: outbound|9092||fake.service.local
  1. This branch:
ADDRESSES PORT MATCH                                                    DESTINATION
0.0.0.0   9092 ALL                                                      PassthroughCluster
0.0.0.0   9092 Addr: 10.123.16.192/28,10.123.16.208/28,10.123.16.224/28 Cluster: outbound|9092||fake.service.local

@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 the do-not-merge/work-in-progress Block merging of a PR because it isn't ready yet. label Jul 9, 2024
@istio-testing istio-testing added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jul 9, 2024
@jewertow
Copy link
Member Author

jewertow commented Jul 9, 2024

/test all

@istio-testing istio-testing added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 9, 2024
@jewertow jewertow changed the title networking: match multiple addresses in sidecar outbound listener networking: match multiple VIPs in sidecar outbound listener Jul 9, 2024
@jewertow jewertow marked this pull request as ready for review July 9, 2024 15:15
@jewertow jewertow requested review from a team as code owners July 9, 2024 15:15
@istio-testing istio-testing removed the do-not-merge/work-in-progress Block merging of a PR because it isn't ready yet. label Jul 9, 2024
@jewertow jewertow requested a review from howardjohn July 10, 2024 08:11
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.

Is this a breaking change

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.

Dual stack usage percentage is less compared with pure ipv4

@jewertow
Copy link
Member Author

Is this a breaking change

Dual stack usage percentage is less compared with pure ipv4

@hzxuzhonghu I am not sure if I understand what you mean, but this change does not enable dual-stack by default. GetAllAddressesForProxy will always return all addresses for the proxy's IP family, i.e. if a proxy is IPv4, then GetAllAddressesForProxy will return all IPv4 addresses. Similarly for IPv6. All addresses, IPv4 and IPv6, will be returned only if DUAL_STACK is enabled.

@jewertow jewertow force-pushed the match-multiple-ips-in-sidecar-listener branch 2 times, most recently from f7a5e0b to 0b41890 Compare July 15, 2024 11:18
Signed-off-by: Jacek Ewertowski <[email protected]>
Signed-off-by: Jacek Ewertowski <[email protected]>
Signed-off-by: Jacek Ewertowski <[email protected]>
Signed-off-by: Jacek Ewertowski <[email protected]>
Signed-off-by: Jacek Ewertowski <[email protected]>
Signed-off-by: Jacek Ewertowski <[email protected]>
Signed-off-by: Jacek Ewertowski <[email protected]>
@jewertow
Copy link
Member Author

I wonder though if having only a GetAllAddresses and update existing code to use it

Actually, that was my initial approach, but I ended up in settings addresses[0] and addresses[1:], etc., and then I thought that someone added these functions for a reason, and maybe I shouldn't change it.

Anyway, if you also think that we should use only single function to get addresses, I could do it in a near future, and now I would like to focus on making it work for HTTP as well. At the end I will submit a PR that will unify usage of these functions. What do you think?

@leosarra
Copy link
Contributor

Actually, that was my initial approach, but I ended up in settings addresses[0] and addresses[1:], etc., and then I thought that someone added these functions for a reason, and maybe I shouldn't change it.

I'm pretty sure that the original reasoning regarding that separation was made by Steve in order to keep single-stack and DS code as separated as possible. Now that the getAllAddresses became relevant for other usecases it would make sense to revisit that decision.
I agree, it does not make sense to refactor it as part of this PR. Either of us can tackle it in the future 😊

@howardjohn
Copy link
Member

LGTM, seems like the current concerns are just refactorings around DS handling in the future?

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.

I'm a general 1; I think this is a needed change that reduces the complexity of our dualstack support. I also agree with a lot of the other cleanup comments, but this is a good first step

pilot/pkg/model/service.go Show resolved Hide resolved
pilot/pkg/model/service.go Outdated Show resolved Hide resolved
}
if node.SupportsIPv6() && len(ipv6Addresses) > 0 {
return ipv6Addresses
}
}
if a := s.GetAddressForProxy(node); a != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I'd recommend renaming this function at some point (fast followup?); it's getting difficult to know what each one does

Signed-off-by: Jacek Ewertowski <[email protected]>
addresses := s.ClusterVIPs.GetAddressesFor(node.Metadata.ClusterID)
if (features.EnableDualStack || features.EnableAmbient) && len(addresses) > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

donot we need to check whether pod support dual stack?

Copy link
Member

Choose a reason for hiding this comment

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

Like a multi cluster mesh, one cluster support only ipv4, the other support dual stack

Copy link
Member Author

Choose a reason for hiding this comment

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

No, this function returns addresses relevant for the cluster of the requesting proxy.

Btw. this is irrelevant in this PR, as I didn't change anything related to dual-stack.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, none of your bussiness. Just see this and indeed it is a bug

Copy link
Contributor

@bleggett bleggett Jul 18, 2024

Choose a reason for hiding this comment

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

In general, we shouldn't be making decisions based on EnableDualStack and should treat it as a deprecated field - it's almost never the correct signal to check, yes.

@jewertow
Copy link
Member Author

jewertow commented Jul 17, 2024

@hzxuzhonghu as you requested changes, could you clarify what do you expect to be changed? You didn't point any issue, just raised your concerns, so this is confusing. And now it only waits for your approval.

addresses := s.ClusterVIPs.GetAddressesFor(node.Metadata.ClusterID)
if (features.EnableDualStack || features.EnableAmbient) && len(addresses) > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

Yes, none of your bussiness. Just see this and indeed it is a bug

@istio-testing istio-testing merged commit 2a36b02 into istio:master Jul 17, 2024
28 checks passed
@jewertow jewertow added the cherrypick/release-1.23 Set this label on a PR to auto-merge it to the release-1.23 branch label Jul 18, 2024
@istio-testing
Copy link
Collaborator

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

@istio-testing
Copy link
Collaborator

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

Applying: networking: match multiple addresses in sidecar outbound listener
Using index info to reconstruct a base tree...
M	pilot/pkg/model/service.go
M	pilot/pkg/networking/core/listener.go
Falling back to patching base and 3-way merge...
Auto-merging pilot/pkg/networking/core/listener.go
Auto-merging pilot/pkg/model/service.go
CONFLICT (content): Merge conflict in pilot/pkg/model/service.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 networking: match multiple addresses in sidecar outbound listener
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: #52184

@istio-testing
Copy link
Collaborator

In response to a cherrypick label: new pull request could not be created: failed to create pull request against istio/istio#release-1.23 from head istio-testing:cherry-pick-51967-to-release-1.23: status code 422 not one of [201], body: {"message":"Validation Failed","errors":[{"resource":"PullRequest","code":"custom","message":"A pull request already exists for istio-testing:cherry-pick-51967-to-release-1.23."}],"documentation_url":"https://docs.github.com/rest/pulls/pulls#create-a-pull-request","status":"422"}

jewertow added a commit to jewertow/upstream-istio that referenced this pull request Jul 23, 2024
…1967)

* networking: match multiple addresses in sidecar outbound listener

Signed-off-by: Jacek Ewertowski <[email protected]>

* Add unit tests for GetAllAddressesForProxy

Signed-off-by: Jacek Ewertowski <[email protected]>

* Refactor buildSidecarOutboundListener

Signed-off-by: Jacek Ewertowski <[email protected]>

* Add an integration test

Signed-off-by: Jacek Ewertowski <[email protected]>

* Add a release note

Signed-off-by: Jacek Ewertowski <[email protected]>

* Refactor GetAllAddressesForProxy

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix linter error

Signed-off-by: Jacek Ewertowski <[email protected]>

* Revert removal svcExtraListenAddresses variable

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix unit tests

Signed-off-by: Jacek Ewertowski <[email protected]>

* Refactoring

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix TestEDSOverlapping

Signed-off-by: Jacek Ewertowski <[email protected]>

* Skip testServiceEntryWithMultipleVIPs in ambient mode

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix TestEDSUnhealthyEndpoints

Signed-off-by: Jacek Ewertowski <[email protected]>

* Add test case for ServiceEntry with resolution NONE and multiple VIPs

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix lint error

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix linter errors

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix lint error

Signed-off-by: Jacek Ewertowski <[email protected]>

* Generate service with all ports

Signed-off-by: Jacek Ewertowski <[email protected]>

* do not create service instance for each hostname/address pair

Signed-off-by: Jacek Ewertowski <[email protected]>

* Refactor GetExtraAddressesForProxy and revert removal of its usage from buildSidecarOutboundListener

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix listenerBindings.Extra()

Signed-off-by: Jacek Ewertowski <[email protected]>

* Handle IPv6 prefix length

Signed-off-by: Jacek Ewertowski <[email protected]>

* Check address' family only if a proxy supports given family

Signed-off-by: Jacek Ewertowski <[email protected]>

* Update a comment

Signed-off-by: Jacek Ewertowski <[email protected]>

* Refactor getAllAddressesForProxy

Signed-off-by: Jacek Ewertowski <[email protected]>

---------

Signed-off-by: Jacek Ewertowski <[email protected]>
istio-testing pushed a commit that referenced this pull request Jul 23, 2024
…stener (#52249)

* networking: match multiple VIPs in sidecar outbound listener (#51967)

* networking: match multiple addresses in sidecar outbound listener

Signed-off-by: Jacek Ewertowski <[email protected]>

* Add unit tests for GetAllAddressesForProxy

Signed-off-by: Jacek Ewertowski <[email protected]>

* Refactor buildSidecarOutboundListener

Signed-off-by: Jacek Ewertowski <[email protected]>

* Add an integration test

Signed-off-by: Jacek Ewertowski <[email protected]>

* Add a release note

Signed-off-by: Jacek Ewertowski <[email protected]>

* Refactor GetAllAddressesForProxy

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix linter error

Signed-off-by: Jacek Ewertowski <[email protected]>

* Revert removal svcExtraListenAddresses variable

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix unit tests

Signed-off-by: Jacek Ewertowski <[email protected]>

* Refactoring

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix TestEDSOverlapping

Signed-off-by: Jacek Ewertowski <[email protected]>

* Skip testServiceEntryWithMultipleVIPs in ambient mode

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix TestEDSUnhealthyEndpoints

Signed-off-by: Jacek Ewertowski <[email protected]>

* Add test case for ServiceEntry with resolution NONE and multiple VIPs

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix lint error

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix linter errors

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix lint error

Signed-off-by: Jacek Ewertowski <[email protected]>

* Generate service with all ports

Signed-off-by: Jacek Ewertowski <[email protected]>

* do not create service instance for each hostname/address pair

Signed-off-by: Jacek Ewertowski <[email protected]>

* Refactor GetExtraAddressesForProxy and revert removal of its usage from buildSidecarOutboundListener

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix listenerBindings.Extra()

Signed-off-by: Jacek Ewertowski <[email protected]>

* Handle IPv6 prefix length

Signed-off-by: Jacek Ewertowski <[email protected]>

* Check address' family only if a proxy supports given family

Signed-off-by: Jacek Ewertowski <[email protected]>

* Update a comment

Signed-off-by: Jacek Ewertowski <[email protected]>

* Refactor getAllAddressesForProxy

Signed-off-by: Jacek Ewertowski <[email protected]>

---------

Signed-off-by: Jacek Ewertowski <[email protected]>

* Revert unintentional change of a comment

Signed-off-by: Jacek Ewertowski <[email protected]>

---------

Signed-off-by: Jacek Ewertowski <[email protected]>
jewertow added a commit to jewertow/upstream-istio that referenced this pull request Jul 23, 2024
…1967)

* networking: match multiple addresses in sidecar outbound listener

Signed-off-by: Jacek Ewertowski <[email protected]>

* Add unit tests for GetAllAddressesForProxy

Signed-off-by: Jacek Ewertowski <[email protected]>

* Refactor buildSidecarOutboundListener

Signed-off-by: Jacek Ewertowski <[email protected]>

* Add an integration test

Signed-off-by: Jacek Ewertowski <[email protected]>

* Add a release note

Signed-off-by: Jacek Ewertowski <[email protected]>

* Refactor GetAllAddressesForProxy

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix linter error

Signed-off-by: Jacek Ewertowski <[email protected]>

* Revert removal svcExtraListenAddresses variable

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix unit tests

Signed-off-by: Jacek Ewertowski <[email protected]>

* Refactoring

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix TestEDSOverlapping

Signed-off-by: Jacek Ewertowski <[email protected]>

* Skip testServiceEntryWithMultipleVIPs in ambient mode

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix TestEDSUnhealthyEndpoints

Signed-off-by: Jacek Ewertowski <[email protected]>

* Add test case for ServiceEntry with resolution NONE and multiple VIPs

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix lint error

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix linter errors

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix lint error

Signed-off-by: Jacek Ewertowski <[email protected]>

* Generate service with all ports

Signed-off-by: Jacek Ewertowski <[email protected]>

* do not create service instance for each hostname/address pair

Signed-off-by: Jacek Ewertowski <[email protected]>

* Refactor GetExtraAddressesForProxy and revert removal of its usage from buildSidecarOutboundListener

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix listenerBindings.Extra()

Signed-off-by: Jacek Ewertowski <[email protected]>

* Handle IPv6 prefix length

Signed-off-by: Jacek Ewertowski <[email protected]>

* Check address' family only if a proxy supports given family

Signed-off-by: Jacek Ewertowski <[email protected]>

* Update a comment

Signed-off-by: Jacek Ewertowski <[email protected]>

* Refactor getAllAddressesForProxy

Signed-off-by: Jacek Ewertowski <[email protected]>

---------

Signed-off-by: Jacek Ewertowski <[email protected]>
istio-testing pushed a commit that referenced this pull request Jul 26, 2024
…stener (#52283)

* networking: match multiple VIPs in sidecar outbound listener (#51967)

* networking: match multiple addresses in sidecar outbound listener

Signed-off-by: Jacek Ewertowski <[email protected]>

* Add unit tests for GetAllAddressesForProxy

Signed-off-by: Jacek Ewertowski <[email protected]>

* Refactor buildSidecarOutboundListener

Signed-off-by: Jacek Ewertowski <[email protected]>

* Add an integration test

Signed-off-by: Jacek Ewertowski <[email protected]>

* Add a release note

Signed-off-by: Jacek Ewertowski <[email protected]>

* Refactor GetAllAddressesForProxy

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix linter error

Signed-off-by: Jacek Ewertowski <[email protected]>

* Revert removal svcExtraListenAddresses variable

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix unit tests

Signed-off-by: Jacek Ewertowski <[email protected]>

* Refactoring

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix TestEDSOverlapping

Signed-off-by: Jacek Ewertowski <[email protected]>

* Skip testServiceEntryWithMultipleVIPs in ambient mode

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix TestEDSUnhealthyEndpoints

Signed-off-by: Jacek Ewertowski <[email protected]>

* Add test case for ServiceEntry with resolution NONE and multiple VIPs

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix lint error

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix linter errors

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix lint error

Signed-off-by: Jacek Ewertowski <[email protected]>

* Generate service with all ports

Signed-off-by: Jacek Ewertowski <[email protected]>

* do not create service instance for each hostname/address pair

Signed-off-by: Jacek Ewertowski <[email protected]>

* Refactor GetExtraAddressesForProxy and revert removal of its usage from buildSidecarOutboundListener

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix listenerBindings.Extra()

Signed-off-by: Jacek Ewertowski <[email protected]>

* Handle IPv6 prefix length

Signed-off-by: Jacek Ewertowski <[email protected]>

* Check address' family only if a proxy supports given family

Signed-off-by: Jacek Ewertowski <[email protected]>

* Update a comment

Signed-off-by: Jacek Ewertowski <[email protected]>

* Refactor getAllAddressesForProxy

Signed-off-by: Jacek Ewertowski <[email protected]>

---------

Signed-off-by: Jacek Ewertowski <[email protected]>

* Apply missing changes from #51939

Signed-off-by: Jacek Ewertowski <[email protected]>

* networking: fix DNS auto-allocation (#52147)

* Fix returning auto-allocated address

Signed-off-by: Jacek Ewertowski <[email protected]>

* Add an integration test

Signed-off-by: Jacek Ewertowski <[email protected]>

* Add missing build tag and license to dns_auto_allocation_test.go

Signed-off-by: Jacek Ewertowski <[email protected]>

* Fix unit tests

Signed-off-by: Jacek Ewertowski <[email protected]>

* Add workload selector to ProxyConfig

Signed-off-by: Jacek Ewertowski <[email protected]>

* Trigger injection if ProxyConfig was not propagated

Signed-off-by: Jacek Ewertowski <[email protected]>

---------

Signed-off-by: Jacek Ewertowski <[email protected]>

* Remove leftovers from conflict resolution

Signed-off-by: Jacek Ewertowski <[email protected]>

---------

Signed-off-by: Jacek Ewertowski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/dual-stack area/networking cherrypick/release-1.22 Set this label on a PR to auto-merge it to the release-1.22 branch cherrypick/release-1.23 Set this label on a PR to auto-merge it to the release-1.23 branch 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.

Listeners missing for service entries with TCP ports and multiple addresses [1.22]
8 participants