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

refactor: bump aws sdk, use rustls in s3 client #13286

Merged
merged 6 commits into from
Nov 14, 2023
Merged

refactor: bump aws sdk, use rustls in s3 client #13286

merged 6 commits into from
Nov 14, 2023

Conversation

MrCroxx
Copy link
Contributor

@MrCroxx MrCroxx commented Nov 7, 2023

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

Bump aws sdk version to latest. Replace native-tls with rustls for s3 client because aws sdk doesn't support it anymore.

close #9503 #11842 #11852

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)
  • My PR contains critical fixes that are necessary to be merged into the latest release. (Please check out the details)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

@MrCroxx MrCroxx self-assigned this Nov 7, 2023
@MrCroxx MrCroxx requested a review from a team as a code owner November 7, 2023 09:19
Comment on lines +543 to +573
pub fn new_http_client(config: &S3ObjectStoreConfig) -> impl HttpClient {
let mut http = hyper::client::HttpConnector::new();

// connection config
if let Some(keepalive_ms) = config.keepalive_ms.as_ref() {
http.set_keepalive(Some(Duration::from_millis(*keepalive_ms)));
}
// connection config
if let Some(keepalive_ms) = config.keepalive_ms.as_ref() {
http.set_keepalive(Some(Duration::from_millis(*keepalive_ms)));
}

if let Some(nodelay) = config.nodelay.as_ref() {
http.set_nodelay(*nodelay);
}
if let Some(nodelay) = config.nodelay.as_ref() {
http.set_nodelay(*nodelay);
}

if let Some(recv_buffer_size) = config.recv_buffer_size.as_ref() {
http.set_recv_buffer_size(Some(*recv_buffer_size));
}
if let Some(recv_buffer_size) = config.recv_buffer_size.as_ref() {
http.set_recv_buffer_size(Some(*recv_buffer_size));
}

if let Some(send_buffer_size) = config.send_buffer_size.as_ref() {
http.set_send_buffer_size(Some(*send_buffer_size));
}
if let Some(send_buffer_size) = config.send_buffer_size.as_ref() {
http.set_send_buffer_size(Some(*send_buffer_size));
}

http.enforce_http(false);
hyper_tls::HttpsConnector::from((http, tls.into()))
};
http.enforce_http(false);

let conn = hyper_rustls::HttpsConnectorBuilder::new()
.with_webpki_roots()
.https_or_http()
.enable_all_versions()
.wrap_connector(http);

aws_smithy_client::hyper_ext::Adapter::builder()
.hyper_builder(hyper::client::Builder::default())
.connector_settings(ConnectorSettings::builder().build())
.build(monitor_connector(native_tls, "S3"))
let conn = monitor_connector(conn, "S3");

HyperClientBuilder::new().build(conn)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link

codecov bot commented Nov 7, 2023

Codecov Report

Attention: 77 lines in your changes are missing coverage. Please review.

Comparison is base (932d694) 67.85% compared to head (b0bcbb6) 67.88%.
Report is 2 commits behind head on main.

Files Patch % Lines
src/object_store/src/object/s3.rs 0.00% 49 Missing ⚠️
src/meta/src/rpc/cloud_provider.rs 0.00% 11 Missing ⚠️
src/object_store/src/object/error.rs 0.00% 10 Missing ⚠️
src/connector/src/source/kinesis/source/message.rs 0.00% 3 Missing ⚠️
src/connector/src/aws_auth.rs 0.00% 2 Missing ⚠️
...onnector/src/source/filesystem/s3/source/reader.rs 0.00% 1 Missing ⚠️
.../connector/src/source/kinesis/enumerator/client.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13286      +/-   ##
==========================================
+ Coverage   67.85%   67.88%   +0.02%     
==========================================
  Files        1526     1526              
  Lines      259938   259940       +2     
==========================================
+ Hits       176392   176456      +64     
+ Misses      83546    83484      -62     
Flag Coverage Δ
rust 67.88% <0.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +11626 to +11629
[[patch.unused]]
name = "getrandom"
version = "0.2.9"
source = "git+https://github.com/madsim-rs/getrandom.git?rev=8daf97e#8daf97e4142635fe28543b2db9022f5e2544bb5c"
Copy link
Member

Choose a reason for hiding this comment

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

👀

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, madsim also needs to update the dependency. I'll change to madsim source when @wangrunji0408 publishes the new version.

Copy link
Contributor

Choose a reason for hiding this comment

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

published as madsim-aws-sdk-s3 v0.3.0

Copy link
Contributor

@wangrunji0408 wangrunji0408 Nov 10, 2023

Choose a reason for hiding this comment

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

Btw, getrandom has updated to v0.2.11 some days ago. Although there's nothing important according to its changelog. If we are going to bump its version, remember to bump the patch version as well:

# Cargo.toml
getrandom = { git = "https://github.com/madsim-rs/getrandom.git", rev = "e79a7ae" }

Copy link
Contributor

Choose a reason for hiding this comment

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

If we are going to bump its version, remember to bump the patch version as well:

It was eventually forgotten.

Copy link
Contributor

Choose a reason for hiding this comment

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

🤣

src/object_store/Cargo.toml Outdated Show resolved Hide resolved
Cargo.toml Outdated
Comment on lines 70 to 87
aws-config = { version = "0.57", default-features = false, features = [
"rt-tokio",
"native-tls",
] }
aws-credential-types = { version = "0.55", default-features = false, features = [
aws-credential-types = { version = "0.57", default-features = false, features = [
"hardcoded-credentials",
] }
aws-sdk-kinesis = { version = "0.28", default-features = false, features = [
aws-sdk-kinesis = { version = "0.35", default-features = false, features = [
"rt-tokio",
"native-tls",
] }
aws-sdk-s3 = { version = "0.28", default-features = false, features = [
aws-sdk-s3 = { version = "0.35", default-features = false, features = [
"rt-tokio",
"native-tls",
] }
aws-sdk-ec2 = { version = "0.28", default-features = false, features = [
aws-sdk-ec2 = { version = "0.35", default-features = false, features = [
"rt-tokio",
"native-tls",
] }
aws-sdk-sqs = { version = "0.28", default-features = false, features = [
aws-sdk-sqs = { version = "0.35", default-features = false, features = [
"rt-tokio",
"native-tls",
] }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did we forget to enable the rustls feature here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Is there any way to test if rustls is enabled and https is working?

Copy link
Collaborator

Choose a reason for hiding this comment

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

If you try to connect to S3 via ec2 in the same region without setting the endpoint explicitly, I think https is used by default. You can also set RW_S3_ENDPOINT explicitly with https://.....

@MrCroxx MrCroxx requested a review from hzxa21 November 10, 2023 07:27
Copy link
Collaborator

@hzxa21 hzxa21 left a comment

Choose a reason for hiding this comment

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

Rest LGTM

@@ -293,7 +294,9 @@ impl StreamingUploader for S3StreamingUploader {

fn get_upload_body(data: Vec<Bytes>) -> ByteStream {
SdkBody::retryable(move || {
Body::wrap_stream(stream::iter(data.clone().into_iter().map(ObjectResult::Ok))).into()
SdkBody::from_body_0_4(Body::wrap_stream(stream::iter(
Copy link
Collaborator

Choose a reason for hiding this comment

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

where does from_body_0_4 come from? Any documentation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Now it uses hyper-0-14-x, which matches our deps.

@MrCroxx MrCroxx added this pull request to the merge queue Nov 14, 2023
Merged via the queue into main with commit 09d312c Nov 14, 2023
27 of 28 checks passed
@MrCroxx MrCroxx deleted the xx/bump-aws-sdk branch November 14, 2023 07:10
@TennyZhuang
Copy link
Contributor

The PR bumped getrandom, then we should also update the madsim patch.

getrandom = { git = "https://github.com/madsim-rs/getrandom.git", rev = "8daf97e" }

cc @wangrunji0408

@MrCroxx MrCroxx mentioned this pull request Nov 24, 2023
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

discussion: may change native-tls to rustls to let GCS use http/2
6 participants