@@ -117,17 +117,6 @@ type snapshotCache struct {
117117 mu sync.RWMutex
118118}
119119
120- // missingRequestResource is returned when the request is specifically dropped due to the resources in the request not matching the snapshot content.
121- // This error is not returned to the user.
122- // TODO(valerian-roche): remove this check which is very likely no longer needed
123- type missingRequestResource struct {
124- resources []string
125- }
126-
127- func (e missingRequestResource ) Error () string {
128- return fmt .Sprintf ("missing resources in request: %v" , e .resources )
129- }
130-
131120// NewSnapshotCache initializes a simple cache.
132121//
133122// ADS flag forces a delay in responding to streaming requests until all
@@ -296,10 +285,7 @@ func (cache *snapshotCache) respondSOTWWatches(ctx context.Context, info *status
296285 }
297286
298287 cache .log .Debugf ("consider open watch %d %s %v with new version %q" , id , watch .Request .GetTypeUrl (), watch .Request .GetResourceNames (), version )
299- resp , err := createResponse (snapshot , watch , cache .ads )
300- if errors .As (err , & missingRequestResource {}) {
301- return nil
302- }
288+ resp , err := createResponse (snapshot , watch )
303289 if err != nil {
304290 return err
305291 }
@@ -445,13 +431,7 @@ func (cache *snapshotCache) CreateWatch(request *Request, sub Subscription, valu
445431 return createWatch (watch ), nil
446432 }
447433
448- resp , err := createResponse (snapshot , watch , cache .ads )
449- // Specific legacy case. We explicitly drop the request (and therefore do not reply or track the watch) while keeping the stream opened.
450- // TODO(valerian-roche): this is likely unneeded now, to be cleaned
451- if errors .As (err , & missingRequestResource {}) {
452- cache .log .Warnf ("ADS mode: not responding to request %s %v: %v" , request .GetTypeUrl (), request .GetResourceNames (), err )
453- return func () {}, nil
454- }
434+ resp , err := createResponse (snapshot , watch )
455435 if err != nil {
456436 return func () {}, fmt .Errorf ("failed to create response: %w" , err )
457437 }
@@ -485,33 +465,14 @@ func (cache *snapshotCache) cancelWatch(nodeID string, watchID int64) func() {
485465 }
486466}
487467
488- // difference returns the names present in resources but not in names.
489- func difference [T any ](resources map [string ]types.ResourceWithTTL , names map [string ]T ) []string {
490- var diff []string
491- for resourceName := range resources {
492- if _ , exists := names [resourceName ]; ! exists {
493- diff = append (diff , resourceName )
494- }
495- }
496- return diff
497- }
498-
499468// createResponse evaluates the provided watch against the given snapshot to build the response to return.
500469// It may return a nil response to indicate the watch is up-to-date for the given snapshot.
501470// It is currently inefficient as not evaluating known resources intrisic versions, but only the snapshot one.
502471// Further work may be performed to optimize this.
503- func createResponse (snapshot ResourceSnapshot , watch ResponseWatch , ads bool ) (* RawResponse , error ) {
472+ func createResponse (snapshot ResourceSnapshot , watch ResponseWatch ) (* RawResponse , error ) {
504473 typeURL := watch .Request .TypeUrl
505474 resources := snapshot .GetResourcesAndTTL (typeURL )
506475
507- // for ADS, the request names must match the snapshot names
508- // if they do not, then the watch is never responded, and it is expected that envoy makes another request
509- if ! watch .subscription .IsWildcard () && ads {
510- if missing := difference (resources , watch .subscription .SubscribedResources ()); len (missing ) > 0 {
511- return nil , missingRequestResource {missing }
512- }
513- }
514-
515476 // This implementation can seem more complex than needed, as it does not blindly rely on the request version.
516477 // This allows for a more generic implemenentation when considering wildcard + subscribed, or partial replies.
517478 // In other context a lot could be simplified as
0 commit comments