-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
cdsbalancer: switch cluster watch to generic xDS client API #6600
Conversation
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.
I think it's a good direction. Mark mentioned that since it's not reused it makes sense for this logic to be part of the cds balancer, especially since the graph like structure can be handled from a traversal owned by cds balancer.
@@ -657,8 +657,10 @@ func (s) TestAggregatedClusterSuccess_IgnoreDups(t *testing.T) { | |||
// Tests the scenario where the aggregate cluster graph has a node that has |
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.
this file can be renamed now :)
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.
Thought about it, but resisted the urge. Will probably do it after I this PR is approved, as the last step before merging.
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.
Alright sg.
Thanks for the review @zasweq |
@@ -657,8 +657,10 @@ func (s) TestAggregatedClusterSuccess_IgnoreDups(t *testing.T) { | |||
// Tests the scenario where the aggregate cluster graph has a node that has |
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.
Alright sg.
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.
LGTM. Some minor nits. Great change overall, just scales up the generation of DMs to recurse through list. Fun one to review :).
|
||
// Handles a good Cluster update from the xDS client. Kicks off the discovery | ||
// mechanism generation process from the top-level cluster and if the cluster | ||
// graph is resolved, generated child policy config and pushes it down. |
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: generates*
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.
b.logger.Warningf("Failed to generate discovery mechanisms: %v", err) | ||
b.onClusterError(b.lbCfg.ClusterName, err) |
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.
Line 450 and 451 send the same error string down as the logging string. I think the prefix "Failed to generate discovery mechanisms" adds valuable information here.
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.
Realized that onClusterError
also logs the error. So, got rid of the log statement here, and in other places where I was logging and passing the error to onClusterError
.
if ok { | ||
continue | ||
} | ||
|
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: nix newline.
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.
// Generates discovery mechanisms corresponding to the clusters in the aggregate | ||
// cluster graph. If a new cluster is encountered when traversing the aggregate | ||
// cluster graph, a watcher is created for it. |
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.
Optional: this doesn't necessarily apply only to aggregate clusters (root cluster can be a leaf, or it can recurse and hit a leaf). I'm fine as is though.
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.
Modified the comment a bit to indicate that this is a recursive function and that the base case for the recursion is a leaf cluster.
dms, ok, err = b.generateDMsForCluster(child, depth+1, dms, clustersSeen) | ||
if err != nil || !ok { | ||
missingCluster = true | ||
|
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.
Nix newline please.
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.
@bitcoinfinancier : Just get out of here. |
Thanks for the detailed review.
I have a few more coming up to switch LDS and RDS :) |
This is a significant simplication of the existing implementation of the CDS LB policy:
clusterHandler
,clusterNode
types with an extremely simple, dumbed down type calledclusterWatcher
that simply forwards updates from the xDS client to the parent LB policyclusterWatchers
, and tries to recursively traverse the cluster graph every time one of the underlying clusters receives an updateAnd as part of all this, replaced the call to
xdsclient.WatchCluster()
with the helper function for the generic xDS API,xdsresource.WatchCluster()
.In a follow-up PR, I will delete the
WatchCluster
method from thexdsclient.XDSClient
interface. I wanted to keep that separate to keep the focus of this PR on the changes to the CDS LB policy.#resource-agnostic-xdsclient-api
RELEASE NOTES: none