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

feat(aws_s3 sink): add option to use virtual addressing #21999

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sam6258
Copy link
Contributor

@sam6258 sam6258 commented Dec 10, 2024

Summary

The following PR adds an option to enable virtual host style addressing to an s3 sink. The force_path_style option defaults to true for backwards compatibility and may eventually be desired to default to false as path style addressing will eventually be removed from aws s3.

This is my first Rust and first Vector PR, so please correct me on any contribution guidelines, style semantics, and code patterns!

Change Type

  • Bug fix
  • New feature
  • Non-functional (chore, refactoring, docs)
  • Performance

Is this a breaking change?

  • Yes
  • No

How did you test this PR?

I pointed an aws s3 sink at my object storage service and validated both path style and vhost style addressing works and also has the correct authority in access logs.

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on our guidelines.
  • No. A maintainer will apply the "no-changelog" label to this PR.

Checklist

  • Please read our Vector contributor resources.
  • If this PR introduces changes Vector dependencies (modifies Cargo.lock), please
    run dd-rust-license-tool write to regenerate the license inventory and commit the changes (if any). More details here.

References

@sam6258 sam6258 requested review from a team as code owners December 10, 2024 06:10
@github-actions github-actions bot added domain: sources Anything related to the Vector's sources domain: sinks Anything related to the Vector's sinks domain: external docs Anything related to Vector's external, public documentation labels Dec 10, 2024
@sam6258 sam6258 force-pushed the sam6258/vhost-buckets branch from 207f753 to 30feaa4 Compare December 10, 2024 06:13
@sam6258 sam6258 force-pushed the sam6258/vhost-buckets branch from 30feaa4 to 5ebb457 Compare December 10, 2024 06:16
Copy link
Member

@jszwedko jszwedko left a comment

Choose a reason for hiding this comment

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

Thanks for this contribution @sam6258 !

Do you think it'd be possible to add an integration test that uses the virtual addressing style? It looks like localstack supports it.

@jszwedko
Copy link
Member

@sam6258
Copy link
Contributor Author

sam6258 commented Dec 10, 2024

Do you think it'd be possible to add an integration test that uses the virtual addressing style?

@jszwedko working on this! My editor didn't let me know I broke integration tests in the call to create_service too. Is it possible to enable tests to run on this PR? I'm working on getting my dev env setup to run integration tests in the meantime.

@sam6258 sam6258 changed the title feat(aws_sdk): add option to use virtual addressing feat(aws_s3): add option to use virtual addressing Dec 10, 2024
@pront
Copy link
Member

pront commented Dec 10, 2024

Do you think it'd be possible to add an integration test that uses the virtual addressing style?

@jszwedko working on this! My editor didn't let me know I broke integration tests in the call to create_service too. Is it possible to enable tests to run on this PR? I'm working on getting my dev env setup to run integration tests in the meantime.

I enabled the CI checks (because it requires approval by maintainers).

Local iterations should be much faster. This might be helpful: https://github.com/vectordotdev/vector/blob/master/scripts/integration/README.md

@sam6258
Copy link
Contributor Author

sam6258 commented Dec 11, 2024

Adapted the integration tests for the new function call structure and added s3_healthchecks_vhost, but I'm getting a lot of test timeouts locally for some reason. Will dig into a bit, since I can't run all the tests I need, but I think the current commit should get us what we want.

@@ -467,7 +467,7 @@ async fn create_client_test() -> CloudwatchLogsClient {
let endpoint = Some(cloudwatch_address());
let proxy = ProxyConfig::default();

create_client::<CloudwatchLogsClientBuilder>(&auth, region, endpoint, &proxy, &None, &None)
create_client::<CloudwatchLogsClientBuilder>(&auth, region, endpoint, &proxy, &None, &None, true)
Copy link
Member

Choose a reason for hiding this comment

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

I think this means we will only test with virtual path style addressing. Could we make sure we have at least one test using each style?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

force_path_style set to true should mean the previous behavior, not virtual host. Most of the components don't even use the value, they just needed the builder implemented with it.

Still digging into integration failures as it seems at least some might be related to changes in the PR

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 got the integration tests working locally and pushed the changes. I had some incorrect values in the test client configs.

On a side note, I did not end up adding an integration test for virtual host style access. This proved more difficult than initially intended as it requires wildcard DNS which docker compose does not support easily. Localstack does support virtual host based lookups and I was able to set up the sdk to do so, but it fails on resolution of the actual bucket. I think wildcard DNS might be out of the scope of this PR.

What are your thoughts 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.

Here is the branch I was playing with if interested https://github.com/sam6258/vector/tree/sam6258/vhost-buckets-test

@sam6258 sam6258 force-pushed the sam6258/vhost-buckets branch 2 times, most recently from 3e95f13 to a6a184e Compare December 12, 2024 08:45
@pront pront changed the title feat(aws_s3): add option to use virtual addressing feat(aws_s3 sink): add option to use virtual addressing Dec 12, 2024
Signed-off-by: Scott Miller <smiller1@coreweave.com>
@sam6258 sam6258 force-pushed the sam6258/vhost-buckets branch from a6a184e to d03f11b Compare December 12, 2024 19:11
@sam6258
Copy link
Contributor Author

sam6258 commented Dec 12, 2024

@pront I fixed the CI check that was failing if you can kick off again, thanks!

@pront
Copy link
Member

pront commented Dec 12, 2024

@pront I fixed the CI check that was failing if you can kick off again, thanks!

Is PR now ready for a final review? There has been difficulty with getting an IT running?

@sam6258
Copy link
Contributor Author

sam6258 commented Dec 12, 2024

Yes, PR in my opinion is ready for final review. It passes existing tests, but I wasn't able to get a test to cover the new functionality per this comment. #21999 (comment)

Copy link
Member

@pront pront left a comment

Choose a reason for hiding this comment

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

Thanks @sam6258

@ADustyOldMuffin
Copy link

Is there anything else we need to do to get this merged?

@pront
Copy link
Member

pront commented Dec 13, 2024

Is there anything else we need to do to get this merged?

Leaving it this up to @jszwedko, due to this thread:
#21999 (comment)

Copy link
Member

@jszwedko jszwedko left a comment

Choose a reason for hiding this comment

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

Thanks @sam6258 ! I see that it'd be difficult to add an integration test due to the necessity of docker-compose supporting wildcard domains. In this case, I think we can just rely on the SDK to do the right thing.

I left one comment about changing the way the configuration is injected, but otherwise I think this looks good to go.

@@ -124,6 +124,9 @@ pub trait ClientBuilder {

/// Build the client using the given config settings.
fn build(config: &SdkConfig) -> Self::Client;

/// Build the client using the given config settings and path style addressing.
fn build_and_force_path_style(config: &aws_types::SdkConfig) -> Self::Client;
Copy link
Member

Choose a reason for hiding this comment

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

I'm not wild about having an S3 specific method on this generic trait.

What would think of, instead of adding this method here, adding a field to

pub(crate) struct S3ClientBuilder;
that controls the argument to force_path_style?

Copy link
Contributor Author

@sam6258 sam6258 Dec 17, 2024

Choose a reason for hiding this comment

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

Yeah, I wasn't crazy about this either, but lacking rust skills here didn't know how else to achieve this. Would that look something like this?

pub(crate) struct S3ClientBuilder{
    // field here?
}

impl ClientBuilder for S3ClientBuilder {

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think it'd be something like that. Then you'll need to add &self to the build() method. I'm happy to play around with it if you get stuck. Hopefully the compiler pushes you in the right directions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain: external docs Anything related to Vector's external, public documentation domain: sinks Anything related to the Vector's sinks domain: sources Anything related to the Vector's sources
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants