Skip to content

xds: Don't cache rdsName in XdsDepManager #12137

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

Merged
merged 1 commit into from
Jun 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 13 additions & 21 deletions xds/src/main/java/io/grpc/xds/XdsDependencyManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,6 @@ private interface RdsUpdateSupplier {

private class LdsWatcher extends XdsWatcherBase<XdsListenerResource.LdsUpdate>
implements RdsUpdateSupplier {
String rdsName;

private LdsWatcher(String resourceName) {
super(XdsListenerResource.getInstance(), resourceName);
Expand All @@ -581,43 +580,36 @@ public void onChanged(XdsListenerResource.LdsUpdate update) {

HttpConnectionManager httpConnectionManager = update.httpConnectionManager();
List<VirtualHost> virtualHosts;
String rdsName;
if (httpConnectionManager == null) {
// TCP listener. Unsupported config
virtualHosts = Collections.emptyList(); // Not null, to not delegate to RDS
rdsName = null;
} else {
virtualHosts = httpConnectionManager.virtualHosts();
rdsName = httpConnectionManager.rdsName();
}

if (virtualHosts != null) {
// No RDS watcher since we are getting RDS updates via LDS
updateRoutes(virtualHosts);
this.rdsName = null;
} else {
this.rdsName = rdsName;
}

String rdsName = getRdsName(update);
if (rdsName != null) {
addRdsWatcher(rdsName);
}

setData(update);
maybePublishConfig();
}

@Override
public void onResourceDoesNotExist(String resourceName) {
if (cancelled) {
return;
private String getRdsName(XdsListenerResource.LdsUpdate update) {
HttpConnectionManager httpConnectionManager = update.httpConnectionManager();
if (httpConnectionManager == null) {
// TCP listener. Unsupported config
return null;
}

checkArgument(resourceName().equals(resourceName), "Resource name does not match");
setDataAsStatus(Status.UNAVAILABLE.withDescription(
toContextString() + " does not exist" + nodeInfo()));
rdsName = null;
maybePublishConfig();
return httpConnectionManager.rdsName();
}

private RdsWatcher getRdsWatcher(WatcherTracer tracer) {
private RdsWatcher getRdsWatcher(XdsListenerResource.LdsUpdate update, WatcherTracer tracer) {
String rdsName = getRdsName(update);
if (rdsName == null) {
return null;
}
Expand All @@ -636,7 +628,7 @@ public RdsUpdateSupplier getRouteSource(WatcherTracer tracer) {
if (virtualHosts != null) {
return this;
}
RdsWatcher rdsWatcher = getRdsWatcher(tracer);
RdsWatcher rdsWatcher = getRdsWatcher(getData().getValue(), tracer);
assert rdsWatcher != null;
return rdsWatcher;
}
Expand Down