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

enable hyper1 behind BMV #3973

Merged
merged 4 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions aws/rust-runtime/aws-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ repository = "https://github.com/smithy-lang/smithy-rs"
[features]
behavior-version-latest = []
credentials-process = ["tokio/process"]
default = ["default-http-connector", "rt-tokio", "credentials-process", "sso"]
default = ["default-https-client", "rt-tokio", "credentials-process", "sso"]
rt-tokio = ["aws-smithy-async/rt-tokio", "aws-smithy-runtime/rt-tokio", "tokio/rt"]
# NOTE: `client-hyper` and `rustls` were proxies for enabling the default HTTP client plugin of `aws-smithy-runtime`
# there is no direct usage otherwise on hyper or rustls in this crate. These are superceded by the more appropriately
# named `default-http-connector` feature and `client-hyper` and `rustls` are now synonyms for the same
client-hyper = ["aws-smithy-runtime/default-http-connector"]
# named `default-https-client` feature and `client-hyper` and `rustls` are now synonyms for the same
# TODO(hyper1) - deprecate legacy `client-hyper` and `rustls` features when available in cargo: https://github.com/rust-lang/cargo/issues/7130
client-hyper = ["aws-smithy-runtime/default-https-client"]
rustls = ["client-hyper"]
default-http-connector = ["aws-smithy-runtime/default-http-connector"]
default-https-client = ["aws-smithy-runtime/default-https-client"]
sso = ["dep:aws-sdk-sso", "dep:aws-sdk-ssooidc", "dep:ring", "dep:hex", "dep:zeroize", "aws-smithy-runtime-api/http-auth"]
test-util = ["aws-runtime/test-util"]

Expand Down Expand Up @@ -64,7 +65,7 @@ proc-macro2 = { version = "1.0.92", optional = true }
[dev-dependencies]
aws-smithy-async = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-async", features = ["rt-tokio", "test-util"] }
aws-smithy-runtime = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-runtime", features = ["client", "test-util"] }
aws-smithy-http-client = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-http-client", features = ["hyper-1", "test-util"] }
aws-smithy-http-client = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-http-client", features = ["default-client", "test-util"] }
aws-smithy-runtime-api = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-runtime-api", features = ["test-util"] }
futures-util = { version = "0.3.29", default-features = false }
tracing-test = "0.2.4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::meta::credentials::CredentialsProviderChain;
use crate::meta::region::ProvideRegion;
use crate::provider_config::ProviderConfig;

#[cfg(any(feature = "default-http-connector", feature = "rustls"))]
#[cfg(any(feature = "default-https-client", feature = "rustls"))]
/// Default Credentials Provider chain
///
/// The region from the default region provider will be used
Expand Down Expand Up @@ -170,7 +170,7 @@ impl Builder {
/// Creates a `DefaultCredentialsChain`
///
/// ## Panics
/// This function will panic if no connector has been set or the `default-http-connector`
/// This function will panic if no connector has been set or the `default-https-client`
/// feature has been disabled.
pub async fn build(self) -> DefaultCredentialsChain {
let region = match self.region_override {
Expand Down
2 changes: 1 addition & 1 deletion aws/rust-runtime/aws-config/src/imds/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ pub(crate) mod test {
#[cfg_attr(windows, ignore)]
/// Verify that the end-to-end real client has a 1-second connect timeout
#[tokio::test]
#[cfg(feature = "default-http-connector")]
#[cfg(feature = "default-https-client")]
async fn one_second_connect_timeout() {
use crate::imds::client::ImdsError;
use aws_smithy_types::error::display::DisplayErrorContext;
Expand Down
6 changes: 3 additions & 3 deletions aws/rust-runtime/aws-config/src/imds/credentials.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ mod test {
}

#[tokio::test]
#[cfg(feature = "default-http-connector")]
#[cfg(feature = "default-https-client")]
async fn read_timeout_during_credentials_refresh_should_yield_last_retrieved_credentials() {
let client = crate::imds::Client::builder()
// 240.* can never be resolved
Expand All @@ -436,7 +436,7 @@ mod test {
}

#[tokio::test]
#[cfg(feature = "default-http-connector")]
#[cfg(feature = "default-https-client")]
async fn read_timeout_during_credentials_refresh_should_error_without_last_retrieved_credentials(
) {
let client = crate::imds::Client::builder()
Expand All @@ -458,7 +458,7 @@ mod test {
// TODO(https://github.com/awslabs/aws-sdk-rust/issues/1117) This test is ignored on Windows because it uses Unix-style paths
#[cfg_attr(windows, ignore)]
#[tokio::test]
#[cfg(feature = "default-http-connector")]
#[cfg(feature = "default-https-client")]
async fn external_timeout_during_credentials_refresh_should_yield_last_retrieved_credentials() {
use aws_smithy_async::rt::sleep::AsyncSleep;
let client = crate::imds::Client::builder()
Expand Down
7 changes: 4 additions & 3 deletions aws/rust-runtime/aws-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,7 @@ mod loader {

let identity_cache = match self.identity_cache {
None => match self.behavior_version {
#[allow(deprecated)]
Some(bv) if bv.is_at_least(BehaviorVersion::v2024_03_28()) => {
Some(IdentityCache::lazy().build())
}
Expand Down Expand Up @@ -1135,7 +1136,7 @@ mod loader {
assert_eq!(Some(&app_name), conf.app_name());
}

#[cfg(feature = "default-http-connector")]
#[cfg(feature = "default-https-client")]
#[tokio::test]
async fn disable_default_credentials() {
let config = defaults(BehaviorVersion::latest())
Expand All @@ -1145,15 +1146,15 @@ mod loader {
assert!(config.credentials_provider().is_none());
}

#[cfg(feature = "default-http-connector")]
#[cfg(feature = "default-https-client")]
#[tokio::test]
async fn identity_cache_defaulted() {
let config = defaults(BehaviorVersion::latest()).load().await;

assert!(config.identity_cache().is_some());
}

#[cfg(feature = "default-http-connector")]
#[cfg(feature = "default-https-client")]
#[allow(deprecated)]
#[tokio::test]
async fn identity_cache_old_behavior_version() {
Expand Down
4 changes: 2 additions & 2 deletions aws/rust-runtime/aws-config/src/meta/credentials/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl CredentialsProviderChain {
}

/// Add a fallback to the default provider chain
#[cfg(any(feature = "default-http-connector", feature = "rustls"))]
#[cfg(any(feature = "default-https-client", feature = "rustls"))]
pub async fn or_default_provider(self) -> Self {
self.or_else(
"DefaultProviderChain",
Expand All @@ -82,7 +82,7 @@ impl CredentialsProviderChain {
}

/// Creates a credential provider chain that starts with the default provider
#[cfg(any(feature = "default-http-connector", feature = "rustls"))]
#[cfg(any(feature = "default-https-client", feature = "rustls"))]
pub async fn default_provider() -> Self {
Self::first_try(
"DefaultProviderChain",
Expand Down
2 changes: 1 addition & 1 deletion aws/rust-runtime/aws-config/src/profile/credentials.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub(crate) mod repr;
/// future::ProvideCredentials::new(self.load_credentials())
/// }
/// }
/// # if cfg!(feature = "default-http-connector") {
/// # if cfg!(feature = "default-https-client") {
/// let provider = ProfileFileCredentialsProvider::builder()
/// .with_custom_provider("Custom", MyCustomProvider)
/// .build();
Expand Down
2 changes: 1 addition & 1 deletion aws/rust-runtime/aws-config/src/provider_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl ProviderConfig {
///
/// # Examples
/// ```no_run
/// # #[cfg(feature = "default-http-connector")]
/// # #[cfg(feature = "default-https-client")]
/// # fn example() {
/// use aws_config::provider_config::ProviderConfig;
/// use aws_sdk_sts::config::Region;
Expand Down
2 changes: 1 addition & 1 deletion aws/rust-runtime/aws-config/src/test_case.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ where
O: for<'a> Deserialize<'a> + Secrets + PartialEq + Debug,
E: Error,
{
#[cfg(feature = "default-http-connector")]
#[cfg(feature = "default-https-client")]
#[allow(unused)]
/// Record a test case from live (remote) HTTPS traffic
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,13 @@ class AwsFluentClientDecorator : ClientCodegenDecorator {
rustCrate.withModule(ClientRustModule.client) {
AwsFluentClientExtensions(codegenContext, types).render(this)
}
rustCrate.mergeFeature(Feature("rustls", default = true, listOf("aws-smithy-runtime/default-http-connector")))

// TODO(hyper1): disable rustls as a default feature in future release
// NOTE: We enable both rustls and default-https-client as default features. This keeps the legacy hyper+rustls
// stack working as is and lets BehaviorVersion control which client you get. In a future release we will
// break this and disable the rustls feature by default (and break old BMV versions w.r.t http client default).
Comment on lines +71 to +74
Copy link
Contributor

Choose a reason for hiding this comment

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

Like the description 👍

rustCrate.mergeFeature(Feature("rustls", default = true, listOf("aws-smithy-runtime/tls-rustls")))
rustCrate.mergeFeature(Feature("default-https-client", default = true, listOf("aws-smithy-runtime/default-https-client")))
}

override fun libRsCustomizations(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,15 @@ internal class HttpChecksumTest {
// Note about the `//#{PresigningMarker}` below. The `RequestChecksumInterceptor` relies on the `PresigningMarker` type from
// the presigning inlineable. The decorator for that inlineable doesn't play nicely with the test model from the SEP, so we
// use this as a kind of blunt way to include the presigning inlineable without actually wiring it up with the model.
// We also have to ensure the `http-1x` feature the presigning inlineable expects is present on the generated crate.
rustCrate.mergeFeature(
Feature(
"http-1x",
default = false,
listOf("dep:http-body-1x", "aws-smithy-runtime-api/http-1x"),
),
)

val testBase =
writable {
rustTemplate(
Expand Down Expand Up @@ -290,6 +299,7 @@ internal class HttpChecksumTest {
*preludeScope,
"tokio" to CargoDependency.Tokio.toType(),
"capture_request" to RuntimeType.captureRequest(rc),
"http_1x" to CargoDependency.Http1x.toType(),
)
}
}
Expand Down Expand Up @@ -368,6 +378,7 @@ internal class HttpChecksumTest {
*preludeScope,
"tokio" to CargoDependency.Tokio.toType(),
"capture_request" to RuntimeType.captureRequest(rc),
"http_1x" to CargoDependency.Http1x.toType(),
)
}
}
Expand All @@ -389,7 +400,7 @@ internal class HttpChecksumTest {
##[::tokio::test]
async fn ${algoLower}_response_checksums_works() {
let (http_client, _rx) = #{capture_request}(Some(
http::Response::builder()
#{http_1x}::Response::builder()
.header("x-amz-checksum-$algoLower", "${testDef.checksumHeaderValue}")
.body(SdkBody::from("${testDef.responsePayload}"))
.unwrap(),
Expand All @@ -414,6 +425,7 @@ internal class HttpChecksumTest {
*preludeScope,
"tokio" to CargoDependency.Tokio.toType(),
"capture_request" to RuntimeType.captureRequest(rc),
"http_1x" to CargoDependency.Http1x.toType(),
)
}
}
Expand All @@ -435,7 +447,7 @@ internal class HttpChecksumTest {
##[::tokio::test]
async fn ${algoLower}_response_checksums_fail_correctly() {
let (http_client, _rx) = #{capture_request}(Some(
http::Response::builder()
#{http_1x}::Response::builder()
.header("x-amz-checksum-$algoLower", "${testDef.checksumHeaderValue}")
.body(SdkBody::from("${testDef.responsePayload}"))
.unwrap(),
Expand Down Expand Up @@ -476,6 +488,7 @@ internal class HttpChecksumTest {
*preludeScope,
"tokio" to CargoDependency.Tokio.toType(),
"capture_request" to RuntimeType.captureRequest(rc),
"http_1x" to CargoDependency.Http1x.toType(),
)
}
}
Expand Down Expand Up @@ -537,6 +550,7 @@ internal class HttpChecksumTest {
*preludeScope,
"tokio" to CargoDependency.Tokio.toType(),
"capture_request" to RuntimeType.captureRequest(rc),
"http_1x" to CargoDependency.Http1x.toType(),
)
}
}
Expand Down Expand Up @@ -613,7 +627,7 @@ internal class HttpChecksumTest {
##[::tokio::test]
async fn response_config_ua_supported() {
let (http_client, rx) = #{capture_request}(Some(
http::Response::builder()
#{http_1x}::Response::builder()
.header("x-amz-checksum-crc32", "i9aeUg==")
.body(SdkBody::from("Hello world"))
.unwrap(),
Expand Down Expand Up @@ -645,7 +659,7 @@ internal class HttpChecksumTest {
##[::tokio::test]
async fn response_config_ua_required() {
let (http_client, rx) = #{capture_request}(Some(
http::Response::builder()
#{http_1x}::Response::builder()
.header("x-amz-checksum-crc32", "i9aeUg==")
.body(SdkBody::from("Hello world"))
.unwrap(),
Expand Down Expand Up @@ -680,6 +694,7 @@ internal class HttpChecksumTest {
*preludeScope,
"tokio" to CargoDependency.Tokio.toType(),
"capture_request" to RuntimeType.captureRequest(rc),
"http_1x" to CargoDependency.Http1x.toType(),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use std::time::Duration;
// the connector being enabled transitively
#[tokio::test]
#[should_panic(
expected = "Enable the `default-http-connector` crate feature or configure an HTTP client to fix this."
expected = "Enable the `default-https-client` crate feature or configure an HTTP client to fix this."
)]
async fn test_clients_from_sdk_config() {
aws_config::load_defaults(BehaviorVersion::latest()).await;
Expand Down Expand Up @@ -58,8 +58,8 @@ async fn test_clients_from_service_config() {
.expect_err("it should fail to send a request because there is no HTTP client");
let msg = format!("{}", DisplayErrorContext(err));
assert!(
msg.contains("No HTTP client was available to send this request. Enable the `default-http-connector` crate feature or configure an HTTP client to fix this."),
"expected '{msg}' to contain 'No HTTP client was available to send this request. Enable the `default-http-connector` crate feature or set an HTTP client to fix this.'"
msg.contains("No HTTP client was available to send this request. Enable the `default-https-client` crate feature or configure an HTTP client to fix this."),
"expected '{msg}' to contain 'No HTTP client was available to send this request. Enable the `default-https-client` crate feature or set an HTTP client to fix this.'"
);
}

Expand Down
2 changes: 1 addition & 1 deletion aws/sdk/integration-tests/s3/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ aws-smithy-protocol-test = { path = "../../build/aws-sdk/sdk/aws-smithy-protocol
aws-smithy-runtime = { path = "../../build/aws-sdk/sdk/aws-smithy-runtime", features = ["test-util"] }
aws-smithy-runtime-api = { path = "../../build/aws-sdk/sdk/aws-smithy-runtime-api", features = ["test-util", "http-1x"] }
aws-smithy-types = { path = "../../build/aws-sdk/sdk/aws-smithy-types" }
aws-smithy-http-client = { path = "../../build/aws-sdk/sdk/aws-smithy-http-client", features = ["hyper-1", "rustls-ring", "test-util", "wire-mock"] }
aws-smithy-http-client = { path = "../../build/aws-sdk/sdk/aws-smithy-http-client", features = ["default-client", "rustls-ring", "test-util", "wire-mock"] }
aws-types = { path = "../../build/aws-sdk/sdk/aws-types" }
bytes = "1"
bytes-utils = "0.1.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ class FluentClientDecorator : ClientCodegenDecorator {
customizations = listOf(GenericFluentClient(codegenContext)),
).render(rustCrate)

// For backwards compat reasons we have to leave this feature as `rustls` which really historically was
// used to enable the `default_http_client` plugin to work (as rustls feature meant enabling both connector-hyper-0-14 + rustls)
//
// When we moved to hyper-1.x as default we re-purposed this feature flag to still (1) enable a default HTTP
// client and (2) still mean rustls (albeit now with aws-lc instead of ring)
rustCrate.mergeFeature(Feature("rustls", default = true, listOf("aws-smithy-runtime/default-http-connector")))
// TODO(hyper1): disable rustls as a default feature in future release
// NOTE: We enable both rustls and default-https-client as default features. This keeps the legacy hyper+rustls
// stack working as is and lets BehaviorVersion control which client you get. In a future release we will
// break this and disable the rustls feature by default (and break old BMV versions w.r.t http client default).
rustCrate.mergeFeature(Feature("rustls", default = true, listOf("aws-smithy-runtime/tls-rustls")))
rustCrate.mergeFeature(Feature("default-https-client", default = true, listOf("aws-smithy-runtime/default-https-client")))
}

override fun libRsCustomizations(
Expand Down
13 changes: 6 additions & 7 deletions rust-runtime/aws-smithy-http-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ hyper-014 = [
"dep:hyper-0-14",
]

# FIXME(hyper1) - rename feature
hyper-1 = [
default-client = [
"aws-smithy-runtime-api/http-1x",
"aws-smithy-types/http-body-1-x",
"dep:hyper",
Expand All @@ -29,7 +28,7 @@ hyper-1 = [

wire-mock = [
"test-util",
"hyper-1",
"default-client",
"hyper-util?/server",
"hyper-util?/server-auto",
"hyper-util?/service",
Expand Down Expand Up @@ -61,9 +60,9 @@ legacy-test-util = [

legacy-rustls-ring = ["dep:legacy-hyper-rustls", "dep:legacy-rustls", "hyper-014"]

rustls-ring = ["dep:rustls", "rustls?/ring", "dep:hyper-rustls", "hyper-1"]
rustls-aws-lc = ["dep:rustls", "rustls?/aws_lc_rs", "dep:hyper-rustls", "hyper-1"]
rustls-aws-lc-fips = ["dep:rustls", "rustls?/fips", "dep:hyper-rustls", "hyper-1"]
rustls-ring = ["dep:rustls", "rustls?/ring", "dep:hyper-rustls", "default-client"]
rustls-aws-lc = ["dep:rustls", "rustls?/aws_lc_rs", "dep:hyper-rustls", "default-client"]
rustls-aws-lc-fips = ["dep:rustls", "rustls?/fips", "dep:hyper-rustls", "default-client"]

[dependencies]
aws-smithy-async = { path = "../aws-smithy-async" }
Expand Down Expand Up @@ -130,7 +129,7 @@ stable = true
[package.metadata.docs.rs]
all-features = false
features = [
"hyper-1 ",
"default-client ",
"wire-mock",
"test-util",
"rustls-ring",
Expand Down
20 changes: 0 additions & 20 deletions rust-runtime/aws-smithy-http-client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,6 @@ use std::fmt;
use std::sync::RwLock;
use std::time::Duration;

/// Creates an HTTPS client using the default TLS provider
pub fn default_client() -> Option<SharedHttpClient> {
#[cfg(feature = "rustls-aws-lc")]
{
tracing::trace!("creating a new default hyper 1.x client using rustls<aws-lc>");
Some(
Builder::new()
.tls_provider(tls::Provider::Rustls(
tls::rustls_provider::CryptoMode::AwsLc,
))
.build_https(),
)
}
#[cfg(not(feature = "rustls-aws-lc"))]
{
tracing::trace!("no default connector available");
None
}
}

/// Given `HttpConnectorSettings` and an `SharedAsyncSleep`, create a `SharedHttpConnector` from defaults depending on what cargo features are activated.
pub fn default_connector(
settings: &HttpConnectorSettings,
Expand Down
Loading
Loading