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

Allow setting s3 forcepathstyle without regionendpoint #4291

Merged
merged 1 commit into from
Apr 24, 2024

Conversation

schanzel
Copy link
Contributor

@schanzel schanzel commented Mar 4, 2024

Currently, the forcepathstyle parameter for the s3 storage driver is
considered only if the regionendpoint parameter is set. Since setting
a region endpoint explicitly is discouraged with AWS s3, it is not clear
how to enforce path style URLs with AWS s3.
This also means, that the default value (true) only applies if a region
endpoint is configured.

This change makes sure we always forward the forcepathstyle parameter
to the aws-sdk if present in the config. This is a breaking change where
a regionendpoint is configured but no explicit forcepathstyle value
is set.

Signed-off-by: Benjamin Schanzel benjamin.schanzel@bmw.de

@schanzel
Copy link
Contributor Author

schanzel commented Mar 5, 2024

To retain the current behaviour, we could keep a default of true for forcepathstyle if the regionendpoint parameter is set. That would make the change non-braking but would also alter config defaults based on other config values. I'm not sure if that would be encouraged.

@schanzel
Copy link
Contributor Author

Any chance getting this in, maybe in v3.0.0? @milosgajdos @thaJeztah @Jamstah

@milosgajdos
Copy link
Member

Since setting a region endpoint explicitly is discouraged with AWS s3

Can you point me somewhere where I can read about this? I understand the reasons, just never came across AWS discouraging users from doing this

@schanzel
Copy link
Contributor Author

That's stated in the distribution s3 driver docs here https://github.com/distribution/distribution/blob/main/docs/content/storage-drivers/s3.md?plain=1#L44

regionendpoint: (optional) Endpoint URL for S3 compatible APIs. This should not be provided when using Amazon S3.

@schanzel
Copy link
Contributor Author

Anyone?

Copy link
Member

@milosgajdos milosgajdos left a comment

Choose a reason for hiding this comment

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

Is there a reason why we've changed the bool flag/option into a string? It's not entirely clear to me why we do that

@schanzel
Copy link
Contributor Author

schanzel commented Mar 21, 2024

This was to allow the value to be "unset", so we fall back to the aws-sdk default behavior (like we do now if we don't set the regionendpoint).
I'm happy to change that if there's a better way to do it, or if we are okay with always setting the WithS3ForcePathStyle parameter (and default to false).

Copy link
Member

@milosgajdos milosgajdos left a comment

Choose a reason for hiding this comment

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

I see no reason why forcepathstyle can't remain a boolean and has to be changed to a string 🤷‍♂️

We will also need to update the docs explaining that the value takes effect regardless of the region settings.

Currently, the `forcepathstyle` parameter for the s3 storage driver is
considered only if the `regionendpoint` parameter is set. Since setting
a region endpoint explicitly is discouraged with AWS s3, it is not clear
how to enforce path style URLs with AWS s3.
This also means, that the default value (true) only applies if a region
endpoint is configured.

This change makes sure we always forward the `forcepathstyle` parameter
to the aws-sdk if present in the config. This is a breaking change where
a `regionendpoint` is configured but no explicit `forcepathstyle` value
is set.

Signed-off-by: Benjamin Schanzel <benjamin.schanzel@bmw.de>
@schanzel
Copy link
Contributor Author

schanzel commented Apr 8, 2024

Thanks for the feedback. I updated the change accordingly, always setting WithS3ForcePathStyle with a default value of false (and keeping it a boolean).

Copy link
Member

@milosgajdos milosgajdos left a comment

Choose a reason for hiding this comment

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

LGTM, PTAL @Jamstah @thaJeztah

@squizzi
Copy link
Collaborator

squizzi commented Apr 22, 2024

That would make the change non-braking but would also alter config defaults based on other config values. I'm not sure if that would be encouraged.

What are the drawbacks of retaining the current forcePathStyleBool := true with this change? As in setting that to true irregardless of params.RegionEndpoint's value? Would that work?

@schanzel
Copy link
Contributor Author

That would probably work but would also mean we'd be using pathstyle URLs for aws s3 per default, too. The awssdk uses virutal-hosted-style URLs per default and pathstyle urls are ought to be deprecated with aws s3 at some point (cf. https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html).
So I think we shouldn't set this to true per default.

@squizzi squizzi added the breaking-change This change breaks some current functionality, may need a release note label Apr 23, 2024
@milosgajdos milosgajdos merged commit e6d1d18 into distribution:main Apr 24, 2024
16 checks passed
@schanzel schanzel deleted the allow-s3-pathstyle branch April 24, 2024 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ci area/docs area/storage/s3 area/storage breaking-change This change breaks some current functionality, may need a release note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants