xds: Add xDS node ID in few control plane errors (#11519) · grpc/grpc-java@f3cf7c3
@@ -58,7 +58,9 @@
5858import io.grpc.xds.LeastRequestLoadBalancer.LeastRequestConfig;
5959import io.grpc.xds.RingHashLoadBalancer.RingHashConfig;
6060import io.grpc.xds.XdsClusterResource.CdsUpdate;
61+import io.grpc.xds.client.Bootstrapper.BootstrapInfo;
6162import io.grpc.xds.client.Bootstrapper.ServerInfo;
63+import io.grpc.xds.client.EnvoyProtoData;
6264import io.grpc.xds.client.XdsClient;
6365import io.grpc.xds.client.XdsResourceType;
6466import io.grpc.xds.internal.security.CommonTlsContextTestsUtil;
@@ -94,6 +96,16 @@ public class CdsLoadBalancer2Test {
9496private static final String DNS_HOST_NAME = "backend-service-dns.googleapis.com:443";
9597private static final ServerInfo LRS_SERVER_INFO =
9698ServerInfo.create("lrs.googleapis.com", InsecureChannelCredentials.create());
99+private static final String SERVER_URI = "trafficdirector.googleapis.com";
100+private static final String NODE_ID =
101+"projects/42/networks/default/nodes/5c85b298-6f5b-4722-b74a-f7d1f0ccf5ad";
102+private static final EnvoyProtoData.Node BOOTSTRAP_NODE =
103+EnvoyProtoData.Node.newBuilder().setId(NODE_ID).build();
104+private static final BootstrapInfo BOOTSTRAP_INFO = BootstrapInfo.builder()
105+ .servers(ImmutableList.of(
106+ServerInfo.create(SERVER_URI, InsecureChannelCredentials.create())))
107+ .node(BOOTSTRAP_NODE)
108+ .build();
97109private final UpstreamTlsContext upstreamTlsContext =
98110CommonTlsContextTestsUtil.buildUpstreamTlsContext("google_cloud_private_spiffe", true);
99111private final OutlierDetection outlierDetection = OutlierDetection.create(
@@ -211,7 +223,8 @@ public void nonAggregateCluster_resourceNotExist_returnErrorPicker() {
211223verify(helper).updateBalancingState(
212224eq(ConnectivityState.TRANSIENT_FAILURE), pickerCaptor.capture());
213225Status unavailable = Status.UNAVAILABLE.withDescription(
214-"CDS error: found 0 leaf (logical DNS or EDS) clusters for root cluster " + CLUSTER);
226+"CDS error: found 0 leaf (logical DNS or EDS) clusters for root cluster " + CLUSTER
227+ + " xDS node ID: " + NODE_ID);
215228assertPicker(pickerCaptor.getValue(), unavailable, null);
216229assertThat(childBalancers).isEmpty();
217230 }
@@ -254,7 +267,8 @@ public void nonAggregateCluster_resourceRevoked() {
254267xdsClient.deliverResourceNotExist(CLUSTER);
255268assertThat(childBalancer.shutdown).isTrue();
256269Status unavailable = Status.UNAVAILABLE.withDescription(
257-"CDS error: found 0 leaf (logical DNS or EDS) clusters for root cluster " + CLUSTER);
270+"CDS error: found 0 leaf (logical DNS or EDS) clusters for root cluster " + CLUSTER
271+ + " xDS node ID: " + NODE_ID);
258272verify(helper).updateBalancingState(
259273eq(ConnectivityState.TRANSIENT_FAILURE), pickerCaptor.capture());
260274assertPicker(pickerCaptor.getValue(), unavailable, null);
@@ -331,7 +345,8 @@ public void aggregateCluster_noNonAggregateClusterExits_returnErrorPicker() {
331345verify(helper).updateBalancingState(
332346eq(ConnectivityState.TRANSIENT_FAILURE), pickerCaptor.capture());
333347Status unavailable = Status.UNAVAILABLE.withDescription(
334-"CDS error: found 0 leaf (logical DNS or EDS) clusters for root cluster " + CLUSTER);
348+"CDS error: found 0 leaf (logical DNS or EDS) clusters for root cluster " + CLUSTER
349+ + " xDS node ID: " + NODE_ID);
335350assertPicker(pickerCaptor.getValue(), unavailable, null);
336351assertThat(childBalancers).isEmpty();
337352 }
@@ -379,7 +394,8 @@ public void aggregateCluster_descendantClustersRevoked() {
379394verify(helper).updateBalancingState(
380395eq(ConnectivityState.TRANSIENT_FAILURE), pickerCaptor.capture());
381396Status unavailable = Status.UNAVAILABLE.withDescription(
382-"CDS error: found 0 leaf (logical DNS or EDS) clusters for root cluster " + CLUSTER);
397+"CDS error: found 0 leaf (logical DNS or EDS) clusters for root cluster " + CLUSTER
398+ + " xDS node ID: " + NODE_ID);
383399assertPicker(pickerCaptor.getValue(), unavailable, null);
384400assertThat(childBalancer.shutdown).isTrue();
385401assertThat(childBalancers).isEmpty();
@@ -418,7 +434,8 @@ public void aggregateCluster_rootClusterRevoked() {
418434verify(helper).updateBalancingState(
419435eq(ConnectivityState.TRANSIENT_FAILURE), pickerCaptor.capture());
420436Status unavailable = Status.UNAVAILABLE.withDescription(
421-"CDS error: found 0 leaf (logical DNS or EDS) clusters for root cluster " + CLUSTER);
437+"CDS error: found 0 leaf (logical DNS or EDS) clusters for root cluster " + CLUSTER
438+ + " xDS node ID: " + NODE_ID);
422439assertPicker(pickerCaptor.getValue(), unavailable, null);
423440assertThat(childBalancer.shutdown).isTrue();
424441assertThat(childBalancers).isEmpty();
@@ -466,7 +483,8 @@ public void aggregateCluster_intermediateClusterChanges() {
466483verify(helper).updateBalancingState(
467484eq(ConnectivityState.TRANSIENT_FAILURE), pickerCaptor.capture());
468485Status unavailable = Status.UNAVAILABLE.withDescription(
469-"CDS error: found 0 leaf (logical DNS or EDS) clusters for root cluster " + CLUSTER);
486+"CDS error: found 0 leaf (logical DNS or EDS) clusters for root cluster " + CLUSTER
487+ + " xDS node ID: " + NODE_ID);
470488assertPicker(pickerCaptor.getValue(), unavailable, null);
471489assertThat(childBalancer.shutdown).isTrue();
472490assertThat(childBalancers).isEmpty();
@@ -507,7 +525,7 @@ public void aggregateCluster_withLoops() {
507525Status unavailable = Status.UNAVAILABLE.withDescription(
508526"CDS error: circular aggregate clusters directly under cluster-02.googleapis.com for root"
509527 + " cluster cluster-foo.googleapis.com, named [cluster-01.googleapis.com,"
510- + " cluster-02.googleapis.com]");
528+ + " cluster-02.googleapis.com], xDS node ID: " + NODE_ID);
511529assertPicker(pickerCaptor.getValue(), unavailable, null);
512530 }
513531@@ -549,7 +567,7 @@ public void aggregateCluster_withLoops_afterEds() {
549567Status unavailable = Status.UNAVAILABLE.withDescription(
550568"CDS error: circular aggregate clusters directly under cluster-02.googleapis.com for root"
551569 + " cluster cluster-foo.googleapis.com, named [cluster-01.googleapis.com,"
552- + " cluster-02.googleapis.com]");
570+ + " cluster-02.googleapis.com], xDS node ID: " + NODE_ID);
553571assertPicker(pickerCaptor.getValue(), unavailable, null);
554572 }
555573@@ -617,7 +635,7 @@ public void aggregateCluster_discoveryErrorBeforeChildLbCreated_returnErrorPicke
617635eq(ConnectivityState.TRANSIENT_FAILURE), pickerCaptor.capture());
618636Status expectedError = Status.UNAVAILABLE.withDescription(
619637"Unable to load CDS cluster-foo.googleapis.com. xDS server returned: "
620- + "RESOURCE_EXHAUSTED: OOM");
638+ + "RESOURCE_EXHAUSTED: OOM xDS node ID: " + NODE_ID);
621639assertPicker(pickerCaptor.getValue(), expectedError, null);
622640assertThat(childBalancers).isEmpty();
623641 }
@@ -647,7 +665,8 @@ public void aggregateCluster_discoveryErrorAfterChildLbCreated_propagateToChildL
647665648666@Test
649667public void handleNameResolutionErrorFromUpstream_beforeChildLbCreated_returnErrorPicker() {
650-Status upstreamError = Status.UNAVAILABLE.withDescription("unreachable");
668+Status upstreamError = Status.UNAVAILABLE.withDescription(
669+"unreachable xDS node ID: " + NODE_ID);
651670loadBalancer.handleNameResolutionError(upstreamError);
652671verify(helper).updateBalancingState(
653672eq(ConnectivityState.TRANSIENT_FAILURE), pickerCaptor.capture());
@@ -821,6 +840,11 @@ public <T extends ResourceUpdate> void cancelXdsResourceWatch(XdsResourceType<T>
821840 }
822841 }
823842843+@Override
844+public BootstrapInfo getBootstrapInfo() {
845+return BOOTSTRAP_INFO;
846+ }
847+824848private void deliverCdsUpdate(String clusterName, CdsUpdate update) {
825849if (watchers.containsKey(clusterName)) {
826850List<ResourceWatcher<CdsUpdate>> resourceWatchers =