-
Notifications
You must be signed in to change notification settings - Fork 1k
[Default Read/Write Timeout 3/N] Bake per-service exemption tiers and apply the rollout gate #7329
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
Open
zoewangg
wants to merge
1
commit into
feature/master/2026-enable-default-read-timeout
Choose a base branch
from
zoewang/enable-default-read-timeout-exemption
base: feature/master/2026-enable-default-read-timeout
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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
117 changes: 117 additions & 0 deletions
117
...on/awssdk/codegen/customization/processors/DefaultReadWriteTimeoutExemptionProcessor.java
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 |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| /* | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"). | ||
| * You may not use this file except in compliance with the License. | ||
| * A copy of the License is located at | ||
| * | ||
| * http://aws.amazon.com/apache2.0 | ||
| * | ||
| * or in the "license" file accompanying this file. This file is distributed | ||
| * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
| * express or implied. See the License for the specific language governing | ||
| * permissions and limitations under the License. | ||
| */ | ||
|
|
||
| package software.amazon.awssdk.codegen.customization.processors; | ||
|
|
||
| import java.io.IOException; | ||
| import java.io.InputStream; | ||
| import java.util.Collections; | ||
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
| import java.util.stream.Collectors; | ||
| import software.amazon.awssdk.annotations.SdkTestInternalApi; | ||
| import software.amazon.awssdk.codegen.customization.CodegenCustomizationProcessor; | ||
| import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel; | ||
| import software.amazon.awssdk.codegen.model.service.ServiceModel; | ||
| import software.amazon.awssdk.protocols.jsoncore.JsonNode; | ||
| import software.amazon.awssdk.protocols.jsoncore.JsonNodeParser; | ||
| import software.amazon.awssdk.utils.Validate; | ||
|
|
||
| /** | ||
| * Bakes the per-service default read/write inactivity timeout tier into the generated service HTTP config. The tiers come from a | ||
| * checked-in copy of the shared exemption artifact ({@code default-read-write-timeout-exemptions.json}), keyed by the service's | ||
| * sdkId ({@link software.amazon.awssdk.codegen.model.intermediate.Metadata#getServiceId()}). | ||
| * | ||
| * <p>An artifact value of {@code -1} marks a fully-exempt service (no default timeout applies); a positive value is the applied | ||
| * timeout in milliseconds. A service absent from the artifact has nothing baked, and {@code aws-core} supplies the flat default | ||
| * when the rollout gate is on. The rollout gate itself is applied later, in {@code aws-core}; this processor only bakes the | ||
| * per-service tier, which is the same regardless of whether the gate is on. | ||
| */ | ||
| public class DefaultReadWriteTimeoutExemptionProcessor implements CodegenCustomizationProcessor { | ||
|
|
||
| private static final String EXEMPTIONS_RESOURCE = "software/amazon/awssdk/codegen/default-read-write-timeout-exemptions.json"; | ||
|
|
||
| private static final Map<String, Long> SERVICE_ID_TO_TIMEOUT_MILLIS = loadExemptions(); | ||
|
|
||
| private final Map<String, Long> serviceIdToTimeoutMillis; | ||
|
|
||
| public DefaultReadWriteTimeoutExemptionProcessor() { | ||
| this(SERVICE_ID_TO_TIMEOUT_MILLIS); | ||
| } | ||
|
|
||
| @SdkTestInternalApi | ||
| DefaultReadWriteTimeoutExemptionProcessor(Map<String, Long> serviceIdToTimeoutMillis) { | ||
| this.serviceIdToTimeoutMillis = serviceIdToTimeoutMillis; | ||
| } | ||
|
|
||
| @Override | ||
| public void preprocess(ServiceModel serviceModel) { | ||
| // no-op | ||
| } | ||
|
|
||
| @Override | ||
| public void postprocess(IntermediateModel intermediateModel) { | ||
| String serviceId = intermediateModel.getMetadata().getServiceId(); | ||
| Long timeoutMillis = serviceIdToTimeoutMillis.get(serviceId); | ||
| if (timeoutMillis != null) { | ||
| intermediateModel.getMetadata().setDefaultReadWriteTimeoutMillis(timeoutMillis); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Fails if any artifact key does not match one of {@code knownServiceIds}. Matching is exact (case-sensitive), so a stale | ||
| * key (no such service) or a mis-cased key both surface here: either would otherwise silently leave the intended service | ||
| * unlisted and wrongly apply the flat default instead of its exempt/partial tier. | ||
| * | ||
| * <p>Codegen processes one service per run, so this whole-artifact cross-check cannot run inside {@link #postprocess} (a | ||
| * single run never sees every serviceId). It is invoked at build time by the coverage test against the full set of service | ||
| * sdkIds. | ||
| */ | ||
| void validateArtifactKeys(Set<String> knownServiceIds) { | ||
| List<String> unknownKeys = serviceIdToTimeoutMillis.keySet().stream() | ||
| .filter(key -> !knownServiceIds.contains(key)) | ||
| .sorted() | ||
| .collect(Collectors.toList()); | ||
| if (!unknownKeys.isEmpty()) { | ||
| throw new IllegalStateException( | ||
| "Read/write timeout exemption artifact " + EXEMPTIONS_RESOURCE + " contains key(s) matching no service sdkId " | ||
| + "(a stale or mis-cased key silently leaves that service unlisted): " + unknownKeys); | ||
| } | ||
| } | ||
|
|
||
| private static Map<String, Long> loadExemptions() { | ||
| Map<String, Long> exemptions = new HashMap<>(); | ||
| try (InputStream stream = DefaultReadWriteTimeoutExemptionProcessor.class.getClassLoader() | ||
| .getResourceAsStream(EXEMPTIONS_RESOURCE)) { | ||
| Validate.notNull(stream, "Failed to load read/write timeout exemption artifact: %s", EXEMPTIONS_RESOURCE); | ||
| JsonNode root = JsonNodeParser.create().parse(stream); | ||
| root.asObject().forEach((serviceId, value) -> exemptions.put(serviceId, parseTimeoutMillis(serviceId, value))); | ||
| } catch (IOException e) { | ||
| throw new RuntimeException("Failed to read read/write timeout exemption artifact: " + EXEMPTIONS_RESOURCE, e); | ||
| } | ||
| return Collections.unmodifiableMap(exemptions); | ||
| } | ||
|
|
||
| private static long parseTimeoutMillis(String serviceId, JsonNode value) { | ||
| try { | ||
| return Long.parseLong(value.asNumber()); | ||
| } catch (RuntimeException e) { | ||
| throw new IllegalArgumentException( | ||
| "Invalid numeric value for key '" + serviceId + "' in " + EXEMPTIONS_RESOURCE + ": " + value, e); | ||
| } | ||
| } | ||
| } |
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
85 changes: 85 additions & 0 deletions
85
.../main/resources/software/amazon/awssdk/codegen/default-read-write-timeout-exemptions.json
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 |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| { | ||
| "Bedrock Runtime": -1, | ||
| "CloudSearch Domain": -1, | ||
| "codeartifact": -1, | ||
| "ConnectHealth": -1, | ||
| "EBS": -1, | ||
| "Glacier": -1, | ||
| "Lambda": -1, | ||
| "Lex Runtime Service": -1, | ||
| "Lex Runtime V2": -1, | ||
| "MediaStore Data": -1, | ||
| "Omics": -1, | ||
| "Polly": -1, | ||
| "QBusiness": -1, | ||
| "S3": -1, | ||
| "SageMaker Runtime HTTP2": -1, | ||
| "Transcribe Streaming": -1, | ||
| "b2bi": 900000, | ||
| "Bedrock Agent Runtime": 900000, | ||
| "Bedrock AgentCore": 900000, | ||
| "Bedrock Data Automation Runtime": 900000, | ||
| "Data Pipeline": 900000, | ||
| "DataExchange": 900000, | ||
| "ECS": 900000, | ||
| "Glue": 900000, | ||
| "Kinesis": 900000, | ||
| "Kinesis Analytics V2": 900000, | ||
| "Kinesis Video Archived Media": 900000, | ||
| "Kinesis Video Media": 900000, | ||
| "Kinesis Video Signaling": 900000, | ||
| "Kinesis Video WebRTC Storage": 900000, | ||
| "Neptune Graph": 900000, | ||
| "neptunedata": 900000, | ||
| "Nova Act": 900000, | ||
| "QApps": 900000, | ||
| "QConnect": 900000, | ||
| "QuickSight": 900000, | ||
| "SageMaker Runtime": 900000, | ||
| "SagemakerJobRuntime": 900000, | ||
| "SFN": 900000, | ||
| "SQS": 900000, | ||
| "SWF": 900000, | ||
| "Timestream Query": 900000, | ||
| "Wisdom": 900000, | ||
| "API Gateway": 900000, | ||
| "ApiGatewayV2": 900000, | ||
| "AppIntegrations": 900000, | ||
| "AppStream": 900000, | ||
| "Athena": 900000, | ||
| "Auto Scaling": 900000, | ||
| "Batch": 900000, | ||
| "Bedrock": 900000, | ||
| "Bedrock Agent": 900000, | ||
| "Bedrock AgentCore Control": 900000, | ||
| "CloudFormation": 900000, | ||
| "CloudWatch": 900000, | ||
| "CodeBuild": 900000, | ||
| "CodeCatalyst": 900000, | ||
| "CodeDeploy": 900000, | ||
| "Config Service": 900000, | ||
| "Connect": 900000, | ||
| "DataBrew": 900000, | ||
| "DataZone": 900000, | ||
| "Device Farm": 900000, | ||
| "EC2": 900000, | ||
| "Elastic Load Balancing v2": 900000, | ||
| "EMR Serverless": 900000, | ||
| "GameLift": 900000, | ||
| "GameLiftStreams": 900000, | ||
| "IoT": 900000, | ||
| "IoT Data Plane": 900000, | ||
| "IoT Jobs Data Plane": 900000, | ||
| "IoTSecureTunneling": 900000, | ||
| "Lex Model Building Service": 900000, | ||
| "Lex Models V2": 900000, | ||
| "mgn": 900000, | ||
| "RDS": 900000, | ||
| "RDS Data": 900000, | ||
| "RTBFabric": 900000, | ||
| "SageMaker": 900000, | ||
| "SSM": 900000, | ||
| "Storage Gateway": 900000, | ||
| "WorkSpaces": 900000, | ||
| "WorkSpaces Web": 900000 | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Just curious: do we intend to remove this processor and the json artifact at the end of the rolling out?