-
Notifications
You must be signed in to change notification settings - Fork 4.6k
xds: Add cluster endpoint watchers to depndency manager #8744
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
base: master
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is 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
🚀 New features to boost your workflow:
|
|
|
||
| // 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: s/clusterFromRouteConfig/clustersFromRouteConfig
There was a problem hiding this comment.
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{}.
There was a problem hiding this comment.
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.
| listenerWatcher *listenerWatcher | ||
| currentListenerUpdate *xdsresource.ListenerUpdate | ||
| routeConfigWatcher *routeConfigWatcher | ||
| rdsResourceName string | ||
| currentRouteConfig *xdsresource.RouteConfigUpdate | ||
| currentVirtualHost *xdsresource.VirtualHost |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| } | ||
| } | ||
|
|
||
| type endpointWatcher struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/endpointWatcher/endpointsWatcher/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| // We want to stop using this cluster as we received a resource error so | ||
| // remove the last update. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
| // 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{}{} | ||
| } | ||
| } |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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