Skip to content

Commit d374b26

Browse files
committed
xds: Disable LOGICAL_DNS in XdsDepMan until used
ClusterResolverLb is still doing DNS itself, so disable it in XdsDepMan until that migration has finished. EDS is fine in XdsDepman, because XdsClient will share the result with ClusterResolverLb.
1 parent f99b2aa commit d374b26

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

xds/src/main/java/io/grpc/xds/XdsDependencyManager.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ private enum TrackedWatcherTypeEnum {
8282
private static final Locality LOGICAL_DNS_CLUSTER_LOCALITY = Locality.create("", "", "");
8383

8484
private static final int MAX_CLUSTER_RECURSION_DEPTH = 16; // Specified by gRFC A37
85+
86+
static boolean enableLogicalDns = false;
87+
8588
private final String listenerName;
8689
private final XdsClient xdsClient;
8790
private final SynchronizationContext syncContext;
@@ -363,9 +366,14 @@ private static void addConfigForCluster(
363366
}
364367
break;
365368
case LOGICAL_DNS:
366-
TrackedWatcher<List<EquivalentAddressGroup>> dnsWatcher =
367-
tracer.getWatcher(DNS_TYPE, cdsUpdate.dnsHostName());
368-
child = new EndpointConfig(dnsToEdsUpdate(dnsWatcher.getData(), cdsUpdate.dnsHostName()));
369+
if (enableLogicalDns) {
370+
TrackedWatcher<List<EquivalentAddressGroup>> dnsWatcher =
371+
tracer.getWatcher(DNS_TYPE, cdsUpdate.dnsHostName());
372+
child = new EndpointConfig(dnsToEdsUpdate(dnsWatcher.getData(), cdsUpdate.dnsHostName()));
373+
} else {
374+
child = new EndpointConfig(StatusOr.fromStatus(
375+
Status.INTERNAL.withDescription("Logical DNS in dependency manager unsupported")));
376+
}
369377
break;
370378
default:
371379
child = new EndpointConfig(StatusOr.fromStatus(Status.UNAVAILABLE.withDescription(
@@ -806,7 +814,9 @@ public void subscribeToChildren(XdsClusterResource.CdsUpdate update) {
806814
addEdsWatcher(getEdsServiceName());
807815
break;
808816
case LOGICAL_DNS:
809-
addDnsWatcher(update.dnsHostName());
817+
if (enableLogicalDns) {
818+
addDnsWatcher(update.dnsHostName());
819+
}
810820
break;
811821
case AGGREGATE:
812822
update.prioritizedClusterNames()

xds/src/test/java/io/grpc/xds/XdsDependencyManagerTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ public class XdsDependencyManagerTest {
152152

153153
private XdsDependencyManager xdsDependencyManager = new XdsDependencyManager(
154154
xdsClient, syncContext, serverName, serverName, nameResolverArgs);
155+
private boolean savedEnableLogicalDns;
155156

156157
@Before
157158
public void setUp() throws Exception {
@@ -168,6 +169,8 @@ public void setUp() throws Exception {
168169
testWatcher = new TestWatcher();
169170
xdsConfigWatcher = mock(TestWatcher.class, delegatesTo(testWatcher));
170171
defaultXdsConfig = XdsTestUtils.getDefaultXdsConfig(serverName);
172+
173+
savedEnableLogicalDns = XdsDependencyManager.enableLogicalDns;
171174
}
172175

173176
@After
@@ -180,6 +183,8 @@ public void tearDown() throws InterruptedException {
180183
assertThat(adsEnded.get()).isTrue();
181184
assertThat(lrsEnded.get()).isTrue();
182185
assertThat(fakeClock.getPendingTasks()).isEmpty();
186+
187+
XdsDependencyManager.enableLogicalDns = savedEnableLogicalDns;
183188
}
184189

185190
@Test
@@ -749,6 +754,7 @@ public void testChangeAggCluster() {
749754

750755
@Test
751756
public void testLogicalDns_success() {
757+
XdsDependencyManager.enableLogicalDns = true;
752758
FakeSocketAddress fakeAddress = new FakeSocketAddress();
753759
nameResolverRegistry.register(new FakeNameResolverProvider(
754760
"dns:///dns.example.com:1111", fakeAddress));
@@ -789,6 +795,7 @@ public void testLogicalDns_success() {
789795

790796
@Test
791797
public void testLogicalDns_noDnsNr() {
798+
XdsDependencyManager.enableLogicalDns = true;
792799
Cluster cluster = Cluster.newBuilder()
793800
.setName(CLUSTER_NAME)
794801
.setType(Cluster.DiscoveryType.LOGICAL_DNS)

0 commit comments

Comments
 (0)