Skip to content
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

Merged
merged 27 commits into from
Nov 17, 2023
Merged

Conversation

Velfi
Copy link
Contributor

@Velfi Velfi commented Nov 14, 2023

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

  • I have updated CHANGELOG.next.toml if I made changes to the smithy-rs codegen or runtime crates
  • I have updated CHANGELOG.next.toml if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@Velfi Velfi requested review from a team as code owners November 14, 2023 21:33
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@Velfi Velfi added the breaking-change This will require a breaking change label Nov 15, 2023
Copy link

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
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

aws/rust-runtime/aws-config/src/lib.rs Outdated Show resolved Hide resolved
Comment on lines +16 to +21
// 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.
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

aws/rust-runtime/aws-config/src/lib.rs Outdated Show resolved Hide resolved
aws/rust-runtime/aws-config/src/lib.rs Outdated Show resolved Hide resolved
Comment on lines 157 to 159
${section.newLayerName}.store_put(
#{StalledStreamProtectionConfig}::new_enabled().grace_period(#{Duration}::from_secs(5)).build()
);
Copy link
Collaborator

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?

Copy link
Collaborator

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.

Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Comment on lines +66 to +84
// 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();
}

Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

Copy link
Collaborator

@jdisanti jdisanti left a 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.

@Velfi Velfi marked this pull request as draft November 16, 2023 22:18
@Velfi
Copy link
Contributor Author

Velfi commented Nov 16, 2023

I need to fix some broken tests before merging this. Namely, turning off the protection for some old tests.

Copy link
Collaborator

@rcoh rcoh left a 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())
Copy link
Collaborator

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?

Copy link
Collaborator

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.
Copy link
Collaborator

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))
Copy link
Collaborator

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>() {
Copy link
Collaborator

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

rcoh added 3 commits November 16, 2023 19:48
- Fix a bug where SSP wasn't being forwarded from aws-config
- Fix a bunch of tests
@rcoh rcoh marked this pull request as ready for review November 17, 2023 02:35
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@rcoh rcoh enabled auto-merge November 17, 2023 03:21
@rcoh rcoh added this pull request to the merge queue Nov 17, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Nov 17, 2023
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@rcoh rcoh added this pull request to the merge queue Nov 17, 2023
Merged via the queue into main with commit 768237a Nov 17, 2023
40 of 41 checks passed
@rcoh rcoh deleted the zhessler-stalled-stream-protection branch November 17, 2023 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change This will require a breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants