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

disable stalled stream protection on empty bodies and after read complete #3644

Merged
merged 16 commits into from
May 17, 2024

Conversation

aajtodd
Copy link
Contributor

@aajtodd aajtodd commented May 14, 2024

Motivation and Context

Description

  • Disables stalled stream upload protection for requests with an empty/zero length body.
  • Disables stalled stream upload throughput checking once the request body has been read and handed off to the HTTP layer.

Testing

Additional integration tests added covering empty bodies and completed uploads.

Tested SQS issue against latest runtime and can see it works now. The S3 CopyObject issue is related to downloads and will need a different solution.

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.

Copy link

A new generated diff is ready to view.

  • AWS SDK (ignoring whitespace)
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

Copy link

A new generated diff is ready to view.

  • AWS SDK (ignoring whitespace)
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

Copy link

A new generated diff is ready to view.

  • AWS SDK (ignoring whitespace)
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

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.

add tests for is_end_stream to ByteStream
add tests for size_hint to ByteStream
fix http_body_consumes_data test
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@@ -87,7 +87,7 @@ pub struct MinimumThroughputBodyOptionsBuilder {
grace_period: Option<Duration>,
}

const DEFAULT_GRACE_PERIOD: Duration = Duration::from_secs(0);
const DEFAULT_GRACE_PERIOD: Duration = Duration::from_secs(20);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correctness: Is this the right one?

I also see

const DEFAULT_GRACE_PERIOD: Duration = Duration::from_secs(5);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats the difference between these two? 🤔 , confusing that we have two constants for this..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah nuts, no wonder. Let's delete one.

Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

fix is_end_stream for 0 length PathBody that hasn't been polled
@Velfi Velfi marked this pull request as ready for review May 17, 2024 18:21
@Velfi Velfi requested review from a team as code owners May 17, 2024 18:21
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

Copy link
Contributor

@landonxjames landonxjames left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on our discussions the other day I think this covers everything besides the customization for S3 CopyObject that we agreed to defer to another PR. One comment on a method name I found confusing but otherwise looks good!

///
/// After marking a stream complete [report](#method.report) will forever more return
/// [ThroughputReport::Complete]
pub(super) fn complete(&mut self) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we name this mark_complete or something to indicate that it has a side effect? When I saw this method used in UploadThroughput I assumed it was just checking the completeness, not setting it. And with that the complete method in UploadThroughput should probably be renamed as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heh it was originally named that, yeah I think thats fine

@Velfi
Copy link
Contributor

Velfi commented May 17, 2024

Since Landon mentioned it, here's the "No SSP for CopyObject" PR #3649

///
/// When a stream stalls for longer than this grace period, the stream will
/// return an error.
pub const DEFAULT_GRACE_PERIOD: Duration = Duration::from_secs(20);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why pub?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

b/c there's an SSP option struct in aws-smithy-runtime that also has a default and I wanted a single source of truth.

use std::time::Duration;

/// A collection of options for configuring a [`MinimumThroughputBody`](super::MinimumThroughputBody).
/// A collection of options for configuring a [`MinimumThroughputBody`](super::MinimumThroughputDownloadBody).
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 was correct as it was I think, it applies to MinimumThroughputBody not just MinimumThroughputDownloadBody

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did it to avoid the deprecation message:

/// Use [`MinimumThroughputDownloadBody`] instead.
#[deprecated(note = "Renamed to MinimumThroughputDownloadBody since it doesn't work for uploads")]
pub type MinimumThroughputBody<B> = MinimumThroughputDownloadBody<B>;

///
/// After marking a stream complete [report](#method.report) will forever more return
/// [ThroughputReport::Complete]
pub(super) fn complete(&mut self) -> bool {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heh it was originally named that, yeah I think thats fine

@@ -230,15 +233,18 @@ impl FsBuilder {
enum State {
Unloaded(PathBuf),
Loading(Pin<Box<dyn Future<Output = io::Result<File>> + Send + Sync + 'static>>),
Loaded(ReaderStream<io::Take<File>>),
Loaded {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: I assume this is the case but this gets reset correctly on a retry right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. The PathBody is reconstructed from scratch each time.

@@ -36,6 +36,18 @@ references = ["aws-sdk-rust#1079"]
meta = { "breaking" = false, "bug" = true, "tada" = false }
author = "rcoh"

[[aws-sdk-rust]]
message = "Fixes stalled upload stream protection to not apply to empty request bodies and to stop checking for violations once the request body has been read."
references = ["aws-sdk-rust#1141", "aws-sdk-rust#1146", "aws-sdk-rust#1148"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will aws-sdk-rust#1141 (for CopyObject) and aws-sdk-rust#1146 (for MultipartUpload) be addressed by this PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CopyObject is going to be resolved in a separate PR that I linked in an earlier post. MPU should be fixed by this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, maybe we should remove aws-sdk-rust#1141 from references then?

rust-runtime/aws-smithy-runtime/Cargo.toml Outdated Show resolved Hide resolved
CHANGELOG.next.toml Outdated Show resolved Hide resolved
Copy link
Contributor

@ysaito1001 ysaito1001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

rust-runtime/aws-smithy-types/src/byte_stream.rs Outdated Show resolved Hide resolved
rust-runtime/aws-smithy-types/src/byte_stream.rs Outdated Show resolved Hide resolved
Velfi and others added 2 commits May 17, 2024 12:47
Co-authored-by: ysaito1001 <awsaito@amazon.com>
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@Velfi Velfi added this pull request to the merge queue May 17, 2024
Merged via the queue into main with commit f0ddc66 May 17, 2024
44 checks passed
@Velfi Velfi deleted the atodd/fix-stalled-streams branch May 17, 2024 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants