-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
xds: Add xDS node ID in few control plane errors #11519
Conversation
@@ -288,11 +290,16 @@ private void addAncestors(Set<String> ancestors, ClusterState clusterState, | |||
} | |||
|
|||
private void handleClusterDiscoveryError(Status error) { | |||
String description = error.getDescription() == null ? "" : error.getDescription() + " "; | |||
Status errorWithNodeId = Status.fromCode(error.getCode()) |
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.
Just use error.withDescription()
. That will replace the existing description without modifying the other parts. (So you don't need to fiddle with code and cause)
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 thought of using error.augmentDescription
but didn't realize this method existed. Thanks for pointing it out, updated to use error.withDescription
instead.
@@ -288,11 +290,16 @@ private void addAncestors(Set<String> ancestors, ClusterState clusterState, | |||
} | |||
|
|||
private void handleClusterDiscoveryError(Status error) { | |||
String description = error.getDescription() == null ? "" : error.getDescription() + " "; |
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 will have two spaces before " xDS node ID" if getDescription() != null.
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.
When description == null, then there will be a one space indent before "xDS node ID", so I'd leave the extra space here and remove it from the string building.
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.
As Larry suggested, removed extra space from string building in L294.
@@ -815,10 +815,12 @@ private void cleanUpRoutes(String error) { | |||
// the config selector handles the error message itself. Once the LB API allows providing | |||
// failure information for addresses yet still providing a service config, the config seector | |||
// could be avoided. | |||
String errorWithNodeId = | |||
error + "xDS node ID: " + xdsClient.getBootstrapInfo().node().getId(); |
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 will run together with error
. There's not even a space separating them.
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 use ", " to separate them.
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
@@ -876,7 +878,8 @@ public void onResourceDoesNotExist(final String resourceName) { | |||
if (RouteDiscoveryState.this != routeDiscoveryState) { | |||
return; | |||
} | |||
String error = "RDS resource does not exist: " + resourceName; | |||
String error = "RDS resource does not exist: " + resourceName + " xDS node ID: " |
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 will have two node IDs included, one here and one in cleanUpRoutes()
.
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.
Removed xDS node ID from here.
@@ -206,8 +206,9 @@ private void handleClusterDiscovered() { | |||
} | |||
loopStatus = Status.UNAVAILABLE.withDescription(String.format( | |||
"CDS error: circular aggregate clusters directly under %s for " | |||
+ "root cluster %s, named %s", | |||
clusterState.name, root.name, namesCausingLoops)); | |||
+ "root cluster %s, named %s xDS node ID: %s", |
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.
Add a comma between named and XDS node ID
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
@@ -225,8 +226,9 @@ private void handleClusterDiscovered() { | |||
childLb = null; | |||
} | |||
Status unavailable = | |||
Status.UNAVAILABLE.withDescription("CDS error: found 0 leaf (logical DNS or EDS) " | |||
+ "clusters for root cluster " + root.name); | |||
Status.UNAVAILABLE.withDescription( |
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.
As long as you're updating it, it would be nice to switch to String.format() instead of concatenation
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.
Make sense. Updated to use String.format()
.
@@ -288,11 +290,16 @@ private void addAncestors(Set<String> ancestors, ClusterState clusterState, | |||
} | |||
|
|||
private void handleClusterDiscoveryError(Status error) { | |||
String description = error.getDescription() == null ? "" : error.getDescription() + " "; |
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.
When description == null, then there will be a one space indent before "xDS node ID", so I'd leave the extra space here and remove it from the string building.
@@ -815,10 +815,12 @@ private void cleanUpRoutes(String error) { | |||
// the config selector handles the error message itself. Once the LB API allows providing | |||
// failure information for addresses yet still providing a service config, the config seector | |||
// could be avoided. | |||
String errorWithNodeId = | |||
error + "xDS node ID: " + xdsClient.getBootstrapInfo().node().getId(); |
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 use ", " to separate them.
@@ -507,7 +525,7 @@ public void aggregateCluster_withLoops() { | |||
Status unavailable = Status.UNAVAILABLE.withDescription( | |||
"CDS error: circular aggregate clusters directly under cluster-02.googleapis.com for root" | |||
+ " cluster cluster-foo.googleapis.com, named [cluster-01.googleapis.com," | |||
+ " cluster-02.googleapis.com]"); | |||
+ " cluster-02.googleapis.com]" + ", xDS node ID: " + NODE_ID); |
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.
Combine the two string literals on the same line together. Ditto bellow.
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
This PR adds xDS node ID in control plane errors to enable cross-referencing with control plane logs when debugging (b/364405814).
CC @fengli79