Skip to content

Commit f2e9994

Browse files
authored
Enable retries by default (#4454)
Fixes awslabs/aws-sdk-rust#1389 Fixes awslabs/aws-sdk-rust#1393 ## Problem When users create a client with `Config::builder().build()`, retries are disabled by default. This is confusing because our docs say retries are enabled by default, and `aws_config::load_from_env()` does enable them. Users expect retries to just work. ## Solution Enable `RetryConfig::standard()` and a 3.1s connection timeout by default for `BehaviorVersion::v2026_01_12()` and later. Older behavior versions keep the current behavior for backward compatibility. ## Changes - AWS SDK clients now have `RetryConfig::standard()` enabled by default (3 max attempts) when using `BehaviorVersion >= v2026_01_12()`. Previously, retries were disabled by default unless explicitly configured via `aws_config::load_from_env()` - All clients now have a 3.1s connection timeout by default when using BehaviorVersion >= v2026_01_12. This prevents indefinite hangs on connection attempts. ### Documentation Updates Needed The AWS Developer Guide at https://docs.aws.amazon.com/sdk-for-rust/latest/dg/retries.html needs to be updated to reflect this change. ## Checklist - [x] Code changes implemented - [x] Backward compatibility maintained via BehaviorVersion - [x] Generated documentation updated - [x] Tests pass
1 parent 5f8cf1e commit f2e9994

19 files changed

Lines changed: 528 additions & 110 deletions

File tree

aws/codegen-aws-sdk/src/main/kotlin/software/amazon/smithy/rustsdk/AwsFluentClientDecorator.kt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class AwsFluentClientDecorator : ClientCodegenDecorator {
6060
AwsPresignedFluentBuilderMethod(codegenContext),
6161
AwsFluentClientDocs(codegenContext),
6262
AwsFluentClientRetryPartition(codegenContext),
63+
AwsFluentClientEnableRetries(codegenContext),
6364
).letIf(codegenContext.serviceShape.id == ShapeId.from("com.amazonaws.s3#AmazonS3")) {
6465
it + S3ExpressFluentClientCustomization(codegenContext)
6566
},
@@ -199,3 +200,25 @@ private class AwsFluentClientRetryPartition(private val codegenContext: ClientCo
199200
}
200201
}
201202
}
203+
204+
/**
205+
* Enables retries by default for AWS SDK clients when awsSdkBuild is true.
206+
*
207+
* Only applies to real AWS SDK builds (controlled by awsSdkBuild in JSON settings).
208+
*/
209+
private class AwsFluentClientEnableRetries(private val codegenContext: ClientCodegenContext) : FluentClientCustomization() {
210+
override fun section(section: FluentClientSection): Writable {
211+
if (!codegenContext.sdkSettings().awsSdkBuild) {
212+
return emptySection
213+
}
214+
215+
return when (section) {
216+
is FluentClientSection.CustomizeDefaultPluginParams -> {
217+
writable {
218+
rust(".with_is_aws_sdk(true)")
219+
}
220+
}
221+
else -> emptySection
222+
}
223+
}
224+
}

aws/codegen-aws-sdk/src/test/kotlin/software/amazon/smithy/rustsdk/HttpChecksumTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ internal class HttpChecksumTest {
456456
.region(Region::from_static("doesntmatter"))
457457
.with_test_defaults()
458458
.http_client(http_client)
459+
.retry_config(#{RetryConfig}::disabled())
459460
.build();
460461
461462
let client = $moduleName::Client::from_conf(config);
@@ -489,6 +490,7 @@ internal class HttpChecksumTest {
489490
"tokio" to CargoDependency.Tokio.toType(),
490491
"capture_request" to RuntimeType.captureRequest(rc),
491492
"http_1x" to CargoDependency.Http1x.toType(),
493+
"RetryConfig" to RuntimeType.smithyTypes(rc).resolve("retry::RetryConfig"),
492494
)
493495
}
494496
}

aws/codegen-aws-sdk/src/test/kotlin/software/amazon/smithy/rustsdk/TimeoutConfigMergingTest.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class TimeoutConfigMergingTest {
6565
let operation = Duration::from_secs(4);
6666
let http_client = infallible_client_fn(|_req| http::Response::builder().body(SdkBody::empty()).unwrap());
6767
let sdk_config = SdkConfig::builder()
68+
.behavior_version(aws_smithy_runtime_api::client::behavior_version::BehaviorVersion::v2026_01_12())
6869
.timeout_config(
6970
TimeoutConfig::builder()
7071
.connect_timeout(connect_timeout)
@@ -157,8 +158,6 @@ class TimeoutConfigMergingTest {
157158
&TimeoutConfig::builder()
158159
.read_timeout(Duration::from_secs(10))
159160
.connect_timeout(connect_timeout)
160-
.disable_operation_attempt_timeout()
161-
.disable_operation_timeout()
162161
.build(),
163162
"read timeout overridden"
164163
);

aws/rust-runtime/Cargo.lock

Lines changed: 18 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aws/rust-runtime/aws-config/Cargo.lock

Lines changed: 11 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aws/sdk/Cargo.lock

Lines changed: 18 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)