Skip to content

blob/s3: Adds NewSessionFromURLParams for AWS to set profile in the URL#3008

Merged
vangent merged 2 commits into
google:masterfrom
ekini:feature/aws_session_url_parameters
May 28, 2021
Merged

blob/s3: Adds NewSessionFromURLParams for AWS to set profile in the URL#3008
vangent merged 2 commits into
google:masterfrom
ekini:feature/aws_session_url_parameters

Conversation

@ekini

@ekini ekini commented May 27, 2021

Copy link
Copy Markdown
Contributor

It is used for s3 blob to enable setting profile from S3 URLs like: s3://bucket_name?profile=main

Fixes #2865

The first cut. I had to replace lazySessionOpener private class because after this change it is possible to open several s3 buckets using different AWS profiles, so creating a session with init.Do doesn't make much sense anymore.

Basically, the idea is to get profile from the url and pass the rest of the parameters to ConfigFromURLParams afterwards.

Maybe it would be a good idea to refactor those functions that parse the URL somehow, so they are not repeated in several places in this repository (i.e. https://github.com/google/go-cloud/blob/master/blob/azureblob/azureblob.go#L318 does pretty much the same thing, but it's private, and also doesn't allow multiple values for the same parameter).

It is used for s3 blob to enable setting profile
from the s3 URL like: s3://bucket_name?profile=main

Fixes google#2865
@google-cla

google-cla Bot commented May 27, 2021

Copy link
Copy Markdown

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@google-cla google-cla Bot added the cla: no Cannot accept contribution until Google CLA is signed. label May 27, 2021
@ekini

ekini commented May 27, 2021

Copy link
Copy Markdown
Contributor Author

@googlebot I signed it!

@google-cla google-cla Bot added cla: yes Google CLA has been signed! and removed cla: no Cannot accept contribution until Google CLA is signed. labels May 27, 2021
@codecov

codecov Bot commented May 27, 2021

Copy link
Copy Markdown

Codecov Report

Merging #3008 (49b93eb) into master (066d3e3) will decrease coverage by 0.07%.
The diff coverage is 78.94%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3008      +/-   ##
==========================================
- Coverage   69.49%   69.42%   -0.08%     
==========================================
  Files         111      111              
  Lines       11675    11684       +9     
==========================================
- Hits         8114     8112       -2     
- Misses       2892     2903      +11     
  Partials      669      669              
Impacted Files Coverage Δ
blob/s3blob/s3blob.go 90.18% <71.42%> (+1.23%) ⬆️
aws/aws.go 89.18% <83.33%> (-2.82%) ⬇️
server/health/sqlhealth/sqlhealth.go 56.75% <0.00%> (-21.63%) ⬇️
internal/retry/retry.go 92.30% <0.00%> (-7.70%) ⬇️
docstore/docstore.go 87.22% <0.00%> (-2.21%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 066d3e3...49b93eb. Read the comment docs.

@vangent vangent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you add a test that uses "profile"?

Should be near here:
https://github.com/google/go-cloud/blob/master/blob/s3blob/s3blob_test.go#L293

It won't really verify the semantics, but at least verify that

  1. using a "profile" query parameter works.
  2. using a "profile" query parameter along with another query parameter works.
  3. using a "profile" query parameter along with an invalid query parameter fails (this will at least partly test the "rest" code path).

@ekini

ekini commented May 28, 2021

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback! The tests added.

@vangent vangent merged commit ec5930b into google:master May 28, 2021
@ekini ekini deleted the feature/aws_session_url_parameters branch June 16, 2021 01:12
@ianhmarkowitz

ianhmarkowitz commented Feb 24, 2022

Copy link
Copy Markdown

I believe this change introduced a race

This is the (partial) error message:

WARNING: DATA RACE
Write at 0x00c0001a4d00 by goroutine 61:
  gocloud.dev/blob/s3blob.(*urlSessionOpener).OpenBucketURL()
      [Removed]/vendor/gocloud.dev/blob/s3blob/s3blob.go:108 +0x1e4
  gocloud.dev/blob.applyPrefixParam()
      [Removed]/vendor/gocloud.dev/blob/blob.go:1270 +0x210
  gocloud.dev/blob.(*URLMux).OpenBucket()
      [Removed]/vendor/gocloud.dev/blob/blob.go:1247 +0xd2
  gocloud.dev/blob.OpenBucket()
      [Removed]/vendor/gocloud.dev/blob/blob.go:1301 +0x32d
      
...

Previous write at 0x00c0001a4d00 by goroutine 60:
  gocloud.dev/blob/s3blob.(*urlSessionOpener).OpenBucketURL()
      [Removed]/vendor/gocloud.dev/blob/s3blob/s3blob.go:108 +0x1e4
  gocloud.dev/blob.applyPrefixParam()
      [Removed]/vendor/gocloud.dev/blob/blob.go:1270 +0x210
  gocloud.dev/blob.(*URLMux).OpenBucket()
      [Removed]/vendor/gocloud.dev/blob/blob.go:1247 +0xd2
  gocloud.dev/blob.OpenBucket()
      [Removed]/vendor/gocloud.dev/blob/blob.go:1301 +0x32d
      
...

@vangent

vangent commented Mar 8, 2022 via email

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes Google CLA has been signed!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

blob/s3: allow to specify profile via query string

3 participants