-
Notifications
You must be signed in to change notification settings - Fork 190
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
Feature: Stalled stream protection #3202
Conversation
A new generated diff is ready to view.
A new doc preview is ready to view. |
A new generated diff is ready to view.
A new doc preview is ready to view. |
update external types add defaults for stalled stream protection test stalled stream protection defaults
A new generated diff is ready to view.
A new doc preview is ready to view. |
A new generated diff is ready to view.
A new doc preview is ready to view. |
...otlin/software/amazon/smithy/rust/codegen/client/smithy/generators/OperationCustomization.kt
Outdated
Show resolved
Hide resolved
...y/rust/codegen/client/smithy/generators/config/StalledStreamProtectionConfigCustomization.kt
Outdated
Show resolved
Hide resolved
rust-runtime/aws-smithy-runtime/src/client/stalled_stream_protection.rs
Outdated
Show resolved
Hide resolved
Co-authored-by: John DiSanti <[email protected]>
A new generated diff is ready to view.
A new doc preview is ready to view. |
// This test doesn't work because we can't count on `hyper` to poll the body, | ||
// regardless of whether we schedule a wake. To make this functionality work, | ||
// we'd have to integrate more closely with the orchestrator. | ||
// | ||
// I'll leave this test here because we do eventually want to support stalled | ||
// stream protection for uploads. |
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.
does this work if the body is polled at least once?
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.
I think it would have to be polled twice:
- once to set the start of polling time used to calculate throughput
- once more to see that throughput is below the minimum
Cases where it gets checked once only won't be marked as failed.
...y/rust/codegen/client/smithy/generators/config/StalledStreamProtectionConfigCustomization.kt
Outdated
Show resolved
Hide resolved
...y/rust/codegen/client/smithy/generators/config/StalledStreamProtectionConfigCustomization.kt
Outdated
Show resolved
Hide resolved
${section.newLayerName}.store_put( | ||
#{StalledStreamProtectionConfig}::new_enabled().grace_period(#{Duration}::from_secs(5)).build() | ||
); |
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 the default right? I think we should be setting this in the default_runtime_plugin
, right, @jdisanti?
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.
We need to make sure this doesn't override what the customer is setting, as well.
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.
Oh, good catch. This definitely needs to be a defaults runtime plugin.
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.
The test_stalled_stream_protection_for_downloads_can_be_disabled
ensures that the customer's config isn't overridden.
// Check the grace period future to see if it needs creating. | ||
let mut grace_period_fut = this | ||
.grace_period_fut | ||
.take() | ||
.unwrap_or_else(|| this.async_sleep.sleep(this.options.grace_period())); | ||
if let Poll::Ready(()) = pin!(&mut grace_period_fut).poll(cx) { | ||
// The grace period has ended! | ||
return Poll::Ready(Some(Err(Box::new(Error::ThroughputBelowMinimum { | ||
expected: self.options.minimum_throughput(), | ||
actual: actual_throughput.unwrap(), | ||
})))); | ||
}; | ||
this.grace_period_fut.replace(grace_period_fut); | ||
} else { | ||
poll_res | ||
// Ensure we don't have an active grace period future if we're not | ||
// currently below the minimum throughput. | ||
let _ = this.grace_period_fut.take(); | ||
} | ||
|
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.
what's this change for? bugs discovered?
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 adds support for grace periods. We didn't have it before this PR. I added them b/c John thought they'd be helpful.
A new generated diff is ready to view.
A new doc preview is ready to view. |
A new generated diff is ready to view.
A new doc preview is ready to view. |
A new generated diff is ready to view.
A new doc preview is ready to view. |
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.
LGTM. Would be good to have @rcoh look also.
I need to fix some broken tests before merging this. Namely, turning off the protection for some old tests. |
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.
approved with some non-blocking comments
@@ -65,6 +67,7 @@ async fn test_adaptive_retries_with_no_throttling_errors() { | |||
|
|||
let http_client = StaticReplayClient::new(events); | |||
let config = aws_sdk_dynamodb::Config::builder() | |||
.stalled_stream_protection(StalledStreamProtectionConfig::new_disabled()) |
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.
why do we have to disable this in tests?
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.
is it because we're overriding sleep and the sleep is sleeping instantly?
} | ||
|
||
impl StalledStreamProtectionConfig { | ||
/// Create a new config that enables stalled stream protection. |
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.
"the default grace period will be used"
.with_config(layer("default_stalled_stream_protection_config", |layer| { | ||
layer.store_put( | ||
StalledStreamProtectionConfig::new_enabled() | ||
.grace_period(Duration::from_secs(5)) |
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 the default anyway—I'm a little worried about the default coming from two places because someone might think they're changing it but it won't actually change anything.
maybe the answer is a comment next to the default in options.rs
?
cfg: &mut ConfigBag, | ||
) -> Result<(), BoxError> { | ||
if self.enable_for_request_body { | ||
if let Some(cfg) = cfg.load::<StalledStreamProtectionConfig>() { |
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.
nit: naming this cfg makes me think it's a ConfigBag
…-stalled-stream-protection
- Fix a bug where SSP wasn't being forwarded from aws-config - Fix a bunch of tests
…-stalled-stream-protection
A new generated diff is ready to view.
A new doc preview is ready to view. |
A new generated diff is ready to view.
A new doc preview is ready to view. |
See the upgrade guide for this feature to learn more.
The breaking change is to the
MinimumThroughputBody::new
method.Motivation and Context
#1562
Description
awslabs/aws-sdk-rust#956
Testing
I added several tests
Checklist
CHANGELOG.next.toml
if I made changes to the smithy-rs codegen or runtime cratesCHANGELOG.next.toml
if I made changes to the AWS SDK, generated SDK code, or SDK runtime cratesBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.