Skip to content

Commit

Permalink
[XdsClient] fix edge case found by fuzzer
Browse files Browse the repository at this point in the history
  • Loading branch information
markdroth committed Feb 13, 2025
1 parent 822f9b1 commit 6f52966
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/core/xds/xds_client/xds_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,12 @@ void XdsClient::XdsChannel::UnsubscribeLocked(const XdsResourceType* type,
if (!call->HasSubscribedResources()) {
ads_call_.reset();
}
} else {
// If there is currently no ADS call because we're in retry backoff,
// then we immediately trigger deletion of unsubscribed cache entries.
// This may orphan the XdsChannel, which would stop the retry
// timer, since we would no longer need to restart the ADS call.
xds_client_->MaybeRemoveUnsubscribedCacheEntriesForTypeLocked(this, type);
}
}
}
Expand Down
52 changes: 52 additions & 0 deletions test/core/xds/xds_client_fuzzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -606,4 +606,56 @@ TEST(XdsClientFuzzer, IgnoresConnectionFailuresWithOkStatus) {
)pb"));
}

TEST(XdsClientFuzzer, UnsubscribeWhileAdsCallInBackoff) {
Fuzz(ParseTestProto(R"pb(
bootstrap: "{\"xds_servers\": [{\"server_uri\":\"xds.example.com:443\", \"channel_creds\":[{\"type\": \"fake\"}]}]}"
actions {
start_watch {
resource_type { listener {} }
resource_name: "server.example.com"
}
}
actions { send_status_to_client { stream_id { ads {} } } }
actions {
stop_watch {
resource_type { listener {} }
resource_name: "server.example.com"
}
}
actions {
send_message_to_client {
stream_id { ads {} }
response {
version_info: "1"
nonce: "A"
type_url: "type.googleapis.com/envoy.config.listener.v3.Listener"
resources {
[type.googleapis.com/envoy.config.listener.v3.Listener] {
name: "server.example.com"
api_listener {
api_listener {
[type.googleapis.com/envoy.extensions.filters.network
.http_connection_manager.v3.HttpConnectionManager] {
http_filters {
name: "router"
typed_config {
[type.googleapis.com/
envoy.extensions.filters.http.router.v3.Router] {}
}
}
rds {
route_config_name: "route_config"
config_source { self {} }
}
}
}
}
}
}
}
}
}
)pb"));
}

} // namespace grpc_core

0 comments on commit 6f52966

Please sign in to comment.