Skip to content

Commit 6327cfd

Browse files
committed
WIP
1 parent 1424fc1 commit 6327cfd

File tree

6 files changed

+36
-5
lines changed

6 files changed

+36
-5
lines changed

src/core/xds/grpc/xds_server_grpc.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ namespace {
3636
constexpr absl::string_view kServerFeatureIgnoreResourceDeletion =
3737
"ignore_resource_deletion";
3838

39+
constexpr absl::string_view kServerFeatureResourceTimerIsTransientFailure =
40+
"resource_timer_is_transient_error";
41+
3942
constexpr absl::string_view kServerFeatureTrustedXdsServer =
4043
"trusted_xds_server";
4144

@@ -46,6 +49,12 @@ bool GrpcXdsServer::IgnoreResourceDeletion() const {
4649
kServerFeatureIgnoreResourceDeletion)) != server_features_.end();
4750
}
4851

52+
bool GrpcXdsServer::ResourceTimerIsTransientFailure() const {
53+
return server_features_.find(std::string(
54+
kServerFeatureResourceTimerIsTransientFailure)) !=
55+
server_features_.end();
56+
}
57+
4958
bool GrpcXdsServer::TrustedXdsServer() const {
5059
return server_features_.find(std::string(kServerFeatureTrustedXdsServer)) !=
5160
server_features_.end();
@@ -126,6 +135,8 @@ void GrpcXdsServer::JsonPostLoad(const Json& json, const JsonArgs& args,
126135
for (const Json& feature_json : array) {
127136
if (feature_json.type() == Json::Type::kString &&
128137
(feature_json.string() == kServerFeatureIgnoreResourceDeletion ||
138+
feature_json.string() ==
139+
kServerFeatureResourceTimerIsTransientFailure ||
129140
feature_json.string() == kServerFeatureTrustedXdsServer)) {
130141
server_features_.insert(feature_json.string());
131142
}

src/core/xds/grpc/xds_server_grpc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class GrpcXdsServer final : public XdsBootstrap::XdsServer {
3535
const std::string& server_uri() const override { return server_uri_; }
3636

3737
bool IgnoreResourceDeletion() const override;
38+
bool ResourceTimerIsTransientFailure() const override;
3839

3940
bool TrustedXdsServer() const;
4041

src/core/xds/xds_client/xds_bootstrap.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ class XdsBootstrap {
4646
virtual ~XdsServer() = default;
4747

4848
virtual const std::string& server_uri() const = 0;
49+
4950
virtual bool IgnoreResourceDeletion() const = 0;
51+
virtual bool ResourceTimerIsTransientFailure() const = 0;
5052

5153
virtual bool Equals(const XdsServer& other) const = 0;
5254

src/core/xds/xds_client/xds_client.cc

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,15 @@ class XdsClient::XdsChannel::AdsCall final
208208
if (state.HasResource()) return;
209209
// Start timer.
210210
ads_call_ = std::move(ads_call);
211+
Duration timeout = ads_call_->xds_client()->request_timeout_;
212+
if (timeout == Duration::Zero()) {
213+
timeout =
214+
ads_call_->xds_channel()->server_.ResourceTimerIsTransientFailure()
215+
? Duration::Seconds(30)
216+
: Duration::Seconds(15);
217+
}
211218
timer_handle_ = ads_call_->xds_client()->engine()->RunAfter(
212-
ads_call_->xds_client()->request_timeout_,
213-
[self = Ref(DEBUG_LOCATION, "timer")]() {
219+
timeout, [self = Ref(DEBUG_LOCATION, "timer")]() {
214220
ApplicationCallbackExecCtx callback_exec_ctx;
215221
ExecCtx exec_ctx;
216222
self->OnTimer();
@@ -237,9 +243,15 @@ class XdsClient::XdsChannel::AdsCall final
237243
<< "} from xds server";
238244
resource_seen_ = true;
239245
state.SetDoesNotExist();
246+
absl::Status status =
247+
ads_call_->xds_channel()->server_
248+
.ResourceTimerIsTransientFailure()
249+
? absl::UnavailableError(absl::StrCat(
250+
"xDS server ", ads_call_->xds_channel()->server_uri(),
251+
" not responding"))
252+
: absl::NotFoundError("does not exist");
240253
ads_call_->xds_client()->NotifyWatchersOnResourceChanged(
241-
absl::NotFoundError("does not exist"), state.watchers(),
242-
ReadDelayHandle::NoWait());
254+
std::move(status), state.watchers(), ReadDelayHandle::NoWait());
243255
}
244256
}
245257
ads_call_->xds_client()->work_serializer_.DrainQueue();

src/core/xds/xds_client/xds_client.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ class XdsClient : public DualRefCounted<XdsClient> {
8989
std::shared_ptr<grpc_event_engine::experimental::EventEngine> engine,
9090
std::unique_ptr<XdsMetricsReporter> metrics_reporter,
9191
std::string user_agent_name, std::string user_agent_version,
92-
Duration resource_request_timeout = Duration::Seconds(15));
92+
// This parameter overrides the timer duration for testing
93+
// purposes only -- do not use in production.
94+
Duration resource_request_timeout = Duration::Zero());
9395
~XdsClient() override;
9496

9597
// Start and cancel watch for a resource.

test/core/xds/xds_client_test.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ class XdsClientTest : public ::testing::Test {
137137
bool IgnoreResourceDeletion() const override {
138138
return ignore_resource_deletion_;
139139
}
140+
bool ResourceTimerIsTransientFailure() const override {
141+
return false; // FIXME
142+
}
140143
bool Equals(const XdsServer& other) const override {
141144
const auto& o = static_cast<const FakeXdsServer&>(other);
142145
return server_uri_ == o.server_uri_ &&

0 commit comments

Comments
 (0)