Skip to content

Conversation

@zhiyanfoo
Copy link
Contributor

@zhiyanfoo zhiyanfoo commented Oct 23, 2025

This PR add two new public facing xds options DeactivateLegacyWildcard and DeactivateLegacyWildcardForTypes.

This will allow users to disable legacy wildcard mode. This allows us to avoid returning all resources when envoy makes a VHDS request with an empty subscription list. It'll also allows us to ensure that we never return all resources to grpc-xds clients.

@zhiyanfoo zhiyanfoo changed the title legacy wildcard options to deactivate legacy wildcard Oct 23, 2025
}

func TestSotwSubscriptionsWithDeactivatedLegacyWildcardForTypes(t *testing.T) {
t.Run("deactivate for specific type", func(t *testing.T) {

Choose a reason for hiding this comment

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

Can you also add explicitly subscribing to wildcard in this test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed this test because it's already covered by the logic of the multiple types test. I added explict wildcard test to all of them, and added delta versions of the test.

@zhiyanfoo zhiyanfoo force-pushed the zfs/legacy-wildcard branch from 58fd17a to f280781 Compare October 24, 2025 18:33

// newSubscription initializes a subscription state.
func newSubscription(wildcard bool, initialResourceVersions map[string]string) Subscription {
func newSubscription(emptyRequest bool, initialResourceVersions map[string]string, opts config.Opts, typeURL string) Subscription {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think passing Opts here is needed. Directly passing if legacy is deactivated is sufficient

}

// LegacyWildcardDeactivated returns whether legacy wildcard mode is deactivated for all resource types
func (o Opts) LegacyWildcardDeactivated() bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would remove those two methods and replace them with IsLegacyWildcardActive(typeURL)
This would allow extending/evolving the option interface without impacting code in the rest of the modules

// As soon as a resource or an explicit subscription to wildcard is provided,
// this flag will be set to false
// allowLegacyWildcard indicates that an empty request should be treated as a wildcard request.
// If in the stream at some point subscribes explicitly a resource or a explicitly makes wildcard
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment to rewrite. The sentence is inconsistent

@zhiyanfoo zhiyanfoo force-pushed the zfs/legacy-wildcard branch 2 times, most recently from fd6324b to 06e64e6 Compare October 27, 2025 18:45

func NewSotwSubscription(subscribed []string) Subscription {
sub := newSubscription(len(subscribed) == 0, nil)
func NewSotwSubscription(subscribed []string, opts config.Opts, typeURL string) Subscription {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this passed in this interface? This is still leaking parameters here that have no value on the subscription

valerian-roche
valerian-roche previously approved these changes Oct 27, 2025
Copy link
Contributor

@valerian-roche valerian-roche left a comment

Choose a reason for hiding this comment

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

Lgtm. Please sign the DCO to be able to merge

// When deactivated, empty requests are treated as a request with no subscriptions to any resource.
// This is recommended for when you are using the go-control-plane to serve grpc-xds clients.
// These clients never want to treat an empty request as a wildcard subscription.
func DeactivateLegacyWildcard() XDSOption {
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: can you map them in sotw and delta to allow cleaner import as reported at line 46

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants