Skip to content

Commit 929a051

Browse files
committed
Gate retry enablement by awsSdkBuild JSON setting
1 parent 9cdf2a6 commit 929a051

File tree

4 files changed

+29
-35
lines changed

4 files changed

+29
-35
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,15 @@ private class AwsFluentClientRetryPartition(private val codegenContext: ClientCo
202202
}
203203

204204
/**
205-
* Enables retries by default for AWS SDK clients
205+
* Enables retries by default for AWS SDK clients when awsSdkBuild is true
206206
*/
207207
private class AwsFluentClientEnableRetries(private val codegenContext: ClientCodegenContext) : FluentClientCustomization() {
208208
override fun section(section: FluentClientSection): Writable {
209+
// Only enable for real AWS SDK builds (controlled by awsSdkBuild in JSON settings)
210+
if (!codegenContext.sdkSettings().awsSdkBuild) {
211+
return emptySection
212+
}
213+
209214
return when (section) {
210215
is FluentClientSection.CustomizeDefaultPluginParams -> {
211216
writable {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ class TimeoutConfigMergingTest {
159159
&TimeoutConfig::builder()
160160
.read_timeout(Duration::from_secs(10))
161161
.connect_timeout(connect_timeout)
162+
.disable_operation_timeout()
163+
.disable_operation_attempt_timeout()
162164
.build(),
163165
"read timeout overridden"
164166
);

aws/sdk/integration-tests/s3/tests/retry_defaults.rs

Lines changed: 0 additions & 14 deletions
This file was deleted.

rust-runtime/aws-smithy-runtime/src/client/defaults.rs

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,10 @@ pub fn default_retry_config_plugin(
148148
}
149149

150150
/// Runtime plugin that sets the default retry strategy, config, and partition.
151-
///
151+
///
152152
/// This version respects the behavior version to enable retries by default for newer versions.
153153
/// For AWS SDK clients, retries are enabled by default.
154-
pub fn default_retry_config_plugin_v2(
155-
params: &DefaultPluginParams,
156-
) -> Option<SharedRuntimePlugin> {
154+
pub fn default_retry_config_plugin_v2(params: &DefaultPluginParams) -> Option<SharedRuntimePlugin> {
157155
let default_partition_name = params.retry_partition_name.as_ref()?.clone();
158156
let is_aws_sdk = params.is_aws_sdk;
159157
let retry_partition = RetryPartition::new(default_partition_name);
@@ -214,12 +212,15 @@ pub fn default_timeout_config_plugin() -> Option<SharedRuntimePlugin> {
214212
}
215213

216214
/// Runtime plugin that sets the default timeout config.
217-
///
215+
///
218216
/// This version respects the behavior version to enable connection timeout by default for newer versions.
219217
/// For AWS SDK clients, connection timeout is enabled by default.
220218
pub fn default_timeout_config_plugin_v2(
221219
params: &DefaultPluginParams,
222220
) -> Option<SharedRuntimePlugin> {
221+
let behavior_version = params
222+
.behavior_version
223+
.unwrap_or_else(BehaviorVersion::latest);
223224
let is_aws_sdk = params.is_aws_sdk;
224225
Some(
225226
default_plugin("default_timeout_config_plugin", |components| {
@@ -228,17 +229,19 @@ pub fn default_timeout_config_plugin_v2(
228229
))
229230
})
230231
.with_config(layer("default_timeout_config", |layer| {
231-
let timeout_config = if is_aws_sdk {
232-
// AWS SDK: Set connect_timeout, explicitly disable operation timeouts
233-
TimeoutConfig::builder()
234-
.connect_timeout(Duration::from_millis(3100))
235-
.disable_operation_timeout()
236-
.disable_operation_attempt_timeout()
237-
.build()
238-
} else {
239-
// Non-AWS SDK: All timeouts disabled
240-
TimeoutConfig::disabled()
241-
};
232+
#[allow(deprecated)]
233+
let timeout_config =
234+
if is_aws_sdk && behavior_version.is_at_least(BehaviorVersion::v2025_01_17()) {
235+
// AWS SDK with new behavior version: Set connect_timeout, explicitly disable operation timeouts
236+
TimeoutConfig::builder()
237+
.connect_timeout(Duration::from_millis(3100))
238+
.disable_operation_timeout()
239+
.disable_operation_attempt_timeout()
240+
.build()
241+
} else {
242+
// Old behavior versions or non-AWS SDK: All timeouts disabled
243+
TimeoutConfig::disabled()
244+
};
242245
layer.store_put(timeout_config);
243246
}))
244247
.into_shared(),
@@ -452,8 +455,7 @@ mod tests {
452455
let params = DefaultPluginParams::new()
453456
.with_retry_partition_name("test-partition")
454457
.with_is_aws_sdk(true);
455-
let plugin = default_retry_config_plugin_v2(&params)
456-
.expect("plugin should be created");
458+
let plugin = default_retry_config_plugin_v2(&params).expect("plugin should be created");
457459

458460
let config = plugin.config().expect("config should exist");
459461
let retry_config = config
@@ -472,8 +474,7 @@ mod tests {
472474
let params = DefaultPluginParams::new()
473475
.with_retry_partition_name("test-partition")
474476
.with_is_aws_sdk(false);
475-
let plugin = default_retry_config_plugin_v2(&params)
476-
.expect("plugin should be created");
477+
let plugin = default_retry_config_plugin_v2(&params).expect("plugin should be created");
477478

478479
let config = plugin.config().expect("config should exist");
479480
let retry_config = config

0 commit comments

Comments
 (0)