-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Support S3 Virtual Hosted Style #8787
Support S3 Virtual Hosted Style #8787
Conversation
Hi @johanneswuerbach. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/ok-to-test |
/lgtm |
util/pkg/vfs/s3context.go
Outdated
@@ -42,7 +42,7 @@ var ( | |||
// https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region | |||
// TODO: perhaps make region regex more specific, i.e. (us|eu|ap|cn|ca|sa), to prevent matching bucket names that match region format? | |||
// but that will mean updating this list when AWS introduces new regions | |||
s3UrlRegexp = regexp.MustCompile(`s3([-.](?P<region>\w{2}-\w+-\d{1})|[-.](?P<bucket>[\w.\-\_]+)|)?.amazonaws.com(.cn)?(?P<path>.*)?`) | |||
s3UrlRegexp = regexp.MustCompile(`(s3([-.](?P<region>\w{2}-\w+-\d{1})|[-.](?P<bucket>[\w.\-\_]+)|)?|(?P<bucket>[\w\-\_]+).s3.(?P<region>\w{2}-\w+-\d{1})).amazonaws.com(.cn)?(?P<path>.*)?`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why excluding '.' in bucket names in virtual hosted style?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having a dot in the bucket name causes https connection to fail:
https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html#bucketnamingrules
When you use virtual hosted–style buckets with Secure Sockets Layer (SSL), the SSL wildcard certificate only matches buckets that don't contain periods. To work around this, use HTTP or write your own certificate verification logic. We recommend that you do not use periods (".") in bucket names when using virtual hosted–style buckets.
While mirroring assets should work (as kops uses an aws sdk s3 client), the user data script is likely to fail as kops tries to fetch assets from https://bucket
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be a reason to avoid writing out virtual hosted style URIs for such buckets, but doesn't seem a reason to avoid recognizing such URIs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah - there's actually a bug underlying this difference of opinion :-) VFSPath is used in two different places for two quite different things.
Can I suggest that we rename VFSPath to S3URLForHTTPURL or similar? (If you can find something that doesn't look like shouting in the go naming rules, that's even better!)
I started going down this little rabbit hole and it looks like we actually need a bigger refactor... I think one of the usages (storage.go) is really ParseS3Path
and the other one (copyfile.go) is really MapToUploadLocation (and should probably just be inlined in that function.
I'm happy to do that refactor if you want, but I don't want to "steal" the PR from you two that have actually discovered the problem :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@justinsb thanks for the feedback, I did a small refactoring, but not entirely sure whether it goes in the imaging direction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scratch that, I reverted my attempt as I was starting to duplicate a lot of logic and in the end those functions are fairly similar.
Instead I added the .
as asked for by @johngmyers and as a customer your could also specify http://my-bucket
, which would still work, but is less secure obviously.
/lgtm cancel |
959edb0
to
4939aea
Compare
/lgtm |
i poked travis for ya |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
I think we can probable clean up that TODO comment in 43, but let's punt on that one. thanks!
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: geojaz, johanneswuerbach The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest Review the full test history for this PR. Silence the bot with an |
Oh, that Travis failure looks like an actual Go 1.12 incompatibility. Please rebase, as the Travis config has since changed to no longer run on Go 1.12. |
4939aea
to
b92ef68
Compare
@johngmyers rebased :-) |
/lgtm |
Support S3 URLs written in Virtual Hosted Style, which seems to be only recommended notation nowadays, but isn't supported in kops.
https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html#virtual-host-style-url-ex
All the other options are more or less deprecated path style https://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html#path-style-access, old virtual styles https://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html#VirtualHostingBackwardsCompatibility