Skip to content

cache: add prefix/glob watch support to LinearCache for LEDS#1411

Open
wdauchy wants to merge 1 commit intoenvoyproxy:mainfrom
DataDog:wdauchy/linear-cache-prefix-watches
Open

cache: add prefix/glob watch support to LinearCache for LEDS#1411
wdauchy wants to merge 1 commit intoenvoyproxy:mainfrom
DataDog:wdauchy/linear-cache-prefix-watches

Conversation

@wdauchy
Copy link
Contributor

@wdauchy wdauchy commented Feb 20, 2026

Envoy's LEDS (Locality Endpoint Discovery Service) uses delta xDS with
glob collection subscriptions. Clients subscribe to resource names ending
in /* (e.g. ns_svc_8080/us-east-1a/*) via resource_names_subscribe
in DeltaDiscoveryRequest, and expect to receive all individual resources
whose name starts with that prefix.

Currently LinearCache only supports exact-name watches (resourceWatches)
and full wildcard (wildcardWatches). A subscription to collection/* is
stored as a literal key in resourceWatches and never matches individual
resources under that prefix.

This PR adds a prefixWatches map to LinearCache that handles glob
subscriptions:

  • trackWatch: when a subscribed resource name ends with /*, the
    watch is registered in prefixWatches[prefix] instead of
    resourceWatches[name]
  • notifyAll: iterates prefixWatches for each modified resource and
    triggers matching prefix watches
  • computeResourceChange: expands prefix subscriptions to all matching
    resources in the cache, detecting new, updated, and deleted resources
    under the prefix
  • computeResponse: expands prefix globs in the full-state non-wildcard
    branch
  • Watch cancellation: cleans up prefixWatches entries

Existing exact-name and wildcard behavior is unchanged.

Envoy's LEDS uses delta xDS with glob collection subscriptions where
clients subscribe to resource names ending in /* (e.g.
ns_svc_8080/us-east-1a/*) and expect to receive all individual resources
whose name starts with that prefix.

Currently LinearCache only supports exact-name watches and full wildcard
watches. A subscription to collection/* is stored as a literal key in
resourceWatches and never matches individual resources under that prefix.

Add a new prefixWatches map to LinearCache that is keyed by the prefix
(with trailing * stripped, keeping the separator). When a subscribed
resource name ends with /*, the watch is registered in prefixWatches
instead of resourceWatches. notifyAll iterates prefixWatches for each
modified resource and triggers matching prefix watches.
computeResourceChange expands prefix subscriptions to all matching
resources in the cache, detecting new, updated, and deleted resources
under the prefix.

Signed-off-by: William Dauchy <[email protected]>
Co-authored-by: Cursor <[email protected]>
@wdauchy wdauchy force-pushed the wdauchy/linear-cache-prefix-watches branch from aefeae0 to 441aa0e Compare February 20, 2026 09:44
@wdauchy wdauchy marked this pull request as ready for review February 20, 2026 09:46
Copy link
Contributor Author

@wdauchy wdauchy left a comment

Choose a reason for hiding this comment

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

fyi I started to merge this on Datadog production to see how far we can go with it

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.

1 participant