Skip to content

Conversation

@eshitachandwani
Copy link
Member

This is part of A74 implementation which add CDS/EDS/DNS watchers to the dependency manager. It also adds a temporary flag that is disabled by default so that it is not used in the current RPC paths , but enabled in the dependency manager tests.

RELEASE NOTES: None

@eshitachandwani eshitachandwani added this to the 1.78 Release milestone Dec 4, 2025
@codecov
Copy link

codecov bot commented Dec 4, 2025

Codecov Report

❌ Patch coverage is 77.00348% with 66 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.32%. Comparing base (4c27cc8) to head (4b86074).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
internal/xds/xdsdepmgr/xds_dependency_manager.go 80.41% 31 Missing and 16 partials ⚠️
internal/xds/xdsdepmgr/watch_service.go 59.57% 16 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8744      +/-   ##
==========================================
+ Coverage   83.28%   83.32%   +0.04%     
==========================================
  Files         418      418              
  Lines       32367    32663     +296     
==========================================
+ Hits        26958    27218     +260     
- Misses       4034     4061      +27     
- Partials     1375     1384       +9     
Files with missing lines Coverage Δ
internal/xds/xdsdepmgr/watch_service.go 69.33% <59.57%> (-16.39%) ⬇️
internal/xds/xdsdepmgr/xds_dependency_manager.go 81.89% <80.41%> (-3.01%) ⬇️

... and 30 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.


// EnableCDSEDSlooksups is a flag used to control whether the CDS/EDS watchers in
// the dependency manager should be used. It is made false by default.
var EnableCDSEDSlooksups = false
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to be exported?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, the CDSEDS part is really hard to read. Maybe something like enableClusterAndEndpointsWatch?

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed the name. And yes, it needs to be exported since we are turning it on in tests which we have in the package xdsdepmgr_test. It will anyway be removed when the next PR goes in.

var logger = grpclog.Component("xds")

// EnableCDSEDSlooksups is a flag used to control whether the CDS/EDS watchers in
// the dependency manager should be used. It is made false by default.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Skip the It is made false by default since it is evident that it it being set to false in the line below this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

rdsResourceName string
currentRouteConfig *xdsresource.RouteConfigUpdate
currentVirtualHost *xdsresource.VirtualHost
clusterFromRouteConfig map[string]struct{}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: s/clusterFromRouteConfig/clustersFromRouteConfig

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, if this is supposed to be a Set, the idiomatic Go way of defining a Set is to have a map with the value type being bool and not struct{}.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ohh... I always thought using struct{} as value was the idiomatic type, since it is more memory efficient, but changed.

Comment on lines 84 to 89
listenerWatcher *listenerWatcher
currentListenerUpdate *xdsresource.ListenerUpdate
routeConfigWatcher *routeConfigWatcher
rdsResourceName string
currentRouteConfig *xdsresource.RouteConfigUpdate
currentVirtualHost *xdsresource.VirtualHost
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Prior to the new fields for cds/eds watchers and updates, the fields were organized as follows:

  • xxxWatcher
  • xxxRelatedUpdate1
  • xxxRelatedUpdate2
  • yyyWatcher
  • yyyRelatedUpdate1
  • yyyRelatedUpdate2

The newly added ones are mixed up. Could we retain the same order for fields. Thanks.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm ... why did we decide to call this file watch_service.go? Maybe, in a follow-up, we should rename this to watchers.go as it now contains all watchers.

Copy link
Member Author

Choose a reason for hiding this comment

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

The file containing LDS RDS in the xds_resolver was called watch_service.go , so I just reused that. Will change it in a later PR

}

type clusterWatcher struct {
name string
Copy link
Contributor

Choose a reason for hiding this comment

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

Please rename this field to resourceName to match the listenerWatcher and the routeConfigWatcher.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

e.depMgr.onClusterAmbientError(e.name, err, onDone)
}

// clusterWatcherState groups the state associated with a clusterWatcher.
Copy link
Contributor

Choose a reason for hiding this comment

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

There are no comments on the listener and routeConfig watchers. Maybe, we can follow the same approach, since the watcher types are not very interesting.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

cancelWatch func() // Cancel func to cancel the watch.
// Most recent update received for this cluster.
lastUpdate *xdsresource.ClusterUpdate
err error
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this also be called lastErr? or something more descriptive?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

}
}

type endpointWatcher struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

s/endpointWatcher/endpointsWatcher/

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Comment on lines 535 to 536
// We want to stop using this cluster as we received a resource error so
// remove the last update.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Only onListenerResourceAmbientError and onRouteConfigResourceAmbientError currently have docstrings. A comment like this makes more sense to be part of the docstring (for all watchers). But as they will be repeated for all watchers, please keep it short and sweet.


// EnableCDSEDSlooksups is a flag used to control whether the CDS/EDS watchers in
// the dependency manager should be used. It is made false by default.
var EnableCDSEDSlooksups = false
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, the CDSEDS part is really hard to read. Maybe something like enableClusterAndEndpointsWatch?

Comment on lines 354 to 363
// Get the clusters to be watched from the routes in the virtual host. If
// the CLusterSpecifierField is set, we ignore it for now as the clusters
// will be determined dynamically for it.
newClusters := make(map[string]struct{})

for _, rt := range matchVH.Routes {
for _, cluster := range rt.WeightedClusters {
newClusters[cluster.Name] = struct{}{}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this move into the flag protected block as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, missed that. Thank you! Changed.

m.routeConfigWatcher.stop()
}
for name, cluster := range m.clusterWatchers {
go cluster.cancelWatch()
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are these cancels in a goroutine? If there is a valid reason, it needs to be documented. And, we need to ensure that we wait for those goroutines to complete before returning from Close.

Copy link
Member Author

Choose a reason for hiding this comment

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

It was just something I was trying out. Removing it.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants