-
Notifications
You must be signed in to change notification settings - Fork 4k
xds: add "resource_timer_is_transient_failure" server feature #12063
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
shivaspeaks
merged 9 commits into
grpc:master
from
shivaspeaks:server_feature_resource_timer
Jul 15, 2025
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d142abb
add resource_timer_is_transient_failure server feature
shivaspeaks 72aba57
merge from master
shivaspeaks 13bc715
Merge branch 'master' into server_feature_resource_timer
shivaspeaks 9bf979f
Merge branch 'master' of https://github.com/grpc/grpc-java into serve…
shivaspeaks 99785ae
add resource_timer_is_transient_failure server feature
shivaspeaks 6bd7a23
Merge branch 'master' of https://github.com/grpc/grpc-java into serve…
shivaspeaks aa18a55
Merge branch 'server_feature_resource_timer' of https://github.com/sh…
shivaspeaks 90c8a28
add unit tests
shivaspeaks 3d72bcb
fix typo
shivaspeaks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
|
|
||
| import static com.google.common.base.Preconditions.checkArgument; | ||
| import static com.google.common.base.Preconditions.checkNotNull; | ||
| import static io.grpc.xds.client.BootstrapperImpl.XdsDataErrorHandlingEnabled; | ||
| import static io.grpc.xds.client.XdsResourceType.ParsedResource; | ||
| import static io.grpc.xds.client.XdsResourceType.ValidatedResourceUpdate; | ||
|
|
||
|
|
@@ -67,6 +68,7 @@ | |
| // Longest time to wait, since the subscription to some resource, for concluding its absence. | ||
| @VisibleForTesting | ||
| public static final int INITIAL_RESOURCE_FETCH_TIMEOUT_SEC = 15; | ||
| public static final int EXTENDED_RESOURCE_FETCH_TIMEOUT_SEC = 30; | ||
|
|
||
| private final SynchronizationContext syncContext = new SynchronizationContext( | ||
| new Thread.UncaughtExceptionHandler() { | ||
|
|
@@ -738,6 +740,9 @@ | |
| // When client becomes ready, it triggers a restartTimer for all relevant subscribers. | ||
| return; | ||
| } | ||
| ServerInfo serverInfo = activeCpc.getServerInfo(); | ||
| int timeoutSec = XdsDataErrorHandlingEnabled && serverInfo.resourceTimerIsTransientError() | ||
| ? EXTENDED_RESOURCE_FETCH_TIMEOUT_SEC : INITIAL_RESOURCE_FETCH_TIMEOUT_SEC; | ||
|
|
||
| class ResourceNotFound implements Runnable { | ||
| @Override | ||
|
|
@@ -761,8 +766,7 @@ | |
| respTimer.cancel(); | ||
| } | ||
| respTimer = syncContext.schedule( | ||
| new ResourceNotFound(), INITIAL_RESOURCE_FETCH_TIMEOUT_SEC, TimeUnit.SECONDS, | ||
| timeService); | ||
| new ResourceNotFound(), timeoutSec, TimeUnit.SECONDS, timeService); | ||
| } | ||
|
|
||
| void stopTimer() { | ||
|
|
@@ -840,6 +844,8 @@ | |
| // Ignore deletion of State of the World resources when this feature is on, | ||
| // and the resource is reusable. | ||
| boolean ignoreResourceDeletionEnabled = serverInfo.ignoreResourceDeletion(); | ||
| boolean resourceTimerIsTransientError = | ||
| XdsDataErrorHandlingEnabled && serverInfo.resourceTimerIsTransientError(); | ||
| if (ignoreResourceDeletionEnabled && type.isFullStateOfTheWorld() && data != null) { | ||
| if (!resourceDeletionIgnored) { | ||
| logger.log(XdsLogLevel.FORCE_WARNING, | ||
|
|
@@ -854,14 +860,20 @@ | |
| if (!absent) { | ||
| data = null; | ||
| absent = true; | ||
| metadata = ResourceMetadata.newResourceMetadataDoesNotExist(); | ||
| metadata = resourceTimerIsTransientError ? ResourceMetadata.newResourceMetadataTimeout() : | ||
| ResourceMetadata.newResourceMetadataDoesNotExist(); | ||
| for (ResourceWatcher<T> watcher : watchers.keySet()) { | ||
| if (processingTracker != null) { | ||
| processingTracker.startTask(); | ||
| } | ||
| watchers.get(watcher).execute(() -> { | ||
| try { | ||
| watcher.onResourceDoesNotExist(resource); | ||
| if (resourceTimerIsTransientError) { | ||
| watcher.onError(Status.UNAVAILABLE.withDescription( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unit test for watcher.onError and the timeoutSec value when resource timer is transient error. |
||
| "Timed out waiting for resource " + resource + " from xDS server")); | ||
| } else { | ||
| watcher.onResourceDoesNotExist(resource); | ||
| } | ||
| } finally { | ||
| if (processingTracker != null) { | ||
| processingTracker.onComplete(); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used by CSDS, and looks like it crashes if you don't update it:
grpc-java/xds/src/main/java/io/grpc/xds/CsdsService.java
Lines 240 to 255 in 5a8326f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So in the case of TIMEOUT, CSDS service should return either
ClientResourceStatus.REQUESTEDorClientResourceStatus.DOES_NOT_EXIST. What do you think?DOES_NOT_EXISTfits better.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is clearly not something for us to arbitrarily decide during implementation. That's defined by the gRFC. They map 1:1 with the CSDS enum values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. I see now: envoyproxy/envoy@2aaa544. We need to do envoy proto sync to grpc java to have these.