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

Add connection poisoning to aws-smithy-client #2445

Merged
merged 9 commits into from
Mar 14, 2023
Merged

Add connection poisoning to aws-smithy-client #2445

merged 9 commits into from
Mar 14, 2023

Conversation

rcoh
Copy link
Collaborator

@rcoh rcoh commented Mar 9, 2023

Motivation and Context

Description

Built on top of two changes to Hyper, this adds the concept of connection poisoning to Smithy client. To do this, we needed machinery to get access to the "connection metadata" used by the request. This is done in a connector agnostic way with the CaptureSmithyConnection bridge.

A separate layer considers the error classification then invokes poison as necessary. To support testing this, WireLeveMock was created, a mocking facility that binds to 0.0.0.0.

For AWS services, this behavior is enabled by default. For generic-smithy clients, this behavior is disabled by default.

Testing

  • integration test in S3
  • detailed tests of specific behavior in aws-smithy-client

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.

@rcoh rcoh changed the title tests passing! Add connection poisoning to aws-smithy-client Mar 9, 2023
@github-actions
Copy link

github-actions bot commented Mar 9, 2023

@github-actions
Copy link

github-actions bot commented Mar 9, 2023

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

A new doc preview is ready to view.

@github-actions
Copy link

github-actions bot commented Mar 9, 2023

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

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@rcoh rcoh marked this pull request as ready for review March 13, 2023 20:09
@rcoh rcoh requested review from a team as code owners March 13, 2023 20:09
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.

Nice work on this!

@@ -108,7 +117,30 @@ use tower::{BoxError, Service};
/// see [the module documentation](crate::hyper_ext).
#[derive(Clone, Debug)]
#[non_exhaustive]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not needed anymore:

Suggested change
#[non_exhaustive]

ReconnectOnTransientError,

/// Disable reconnects
NoReconnect,
Copy link
Collaborator

Choose a reason for hiding this comment

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

The name here is probably good enough, but I could see how it could potentially cause confusion with reconnecting on hang up or something.

Copy link
Contributor

@82marbag 82marbag Mar 14, 2023

Choose a reason for hiding this comment

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

Maybe NoReuseBadConnection? Usage is clearer from the tests / examples

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I renamed NoReconnect to ReuseAllConnections

@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

be reused.
"""
references = ["aws-sdk-rust#160", "smithy-rs#2445"]
meta = { "breaking" = false, "tada" = false, "bug" = false }
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing target

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ah—we changed the default to all at some point which is why this isn't an error

@82marbag 82marbag added needs-client-review Generic client and removed needs-client-review Generic client labels Mar 14, 2023
@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

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.

WireLevelTestConnection is pretty cool!

@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@rcoh rcoh enabled auto-merge March 14, 2023 19:51
@github-actions
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 Mar 14, 2023
Merged via the queue into main with commit 61934da Mar 14, 2023
@rcoh rcoh deleted the poison-connections branch March 14, 2023 20:33
Comment on lines +125 to +126
let capture_conn = capture_conn.clone();
if let Some(conn) = capture_conn.clone().connection_metadata().as_ref() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you really need the double clone here?

http_info.map(|info| info.remote_addr()),
move || match capture_conn.connection_metadata().as_ref() {
Some(conn) => conn.poison(),
None => tracing::trace!("no connection existed to poison"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe rephrase this error message like no connection found that should be poisoned ?

}
tracing::debug!("replying with {:?}", next_event);
let event = generate_response_event(next_event).await;
dbg!(event)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a leftover or do we want to debug every time we spinup a new mock?

let sock_addr = self.socket_addr;
let log = self.log.clone();
Box::pin(async move {
println!("looking up {:?}, replying with {:?}", req, sock_addr);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above: is this a leftover?

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.

5 participants