Skip to content

ENH: S3 access using instance role #2621

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

Merged
merged 5 commits into from
Jul 23, 2018
Merged

Conversation

anibalsolon
Copy link
Contributor

Fixes #2620.

Changes proposed in this pull request

  • Try to connect to the bucket non-anonymously when there is no AWS credential, before trying the anonymous config
  • It will give the possibility to use instance roles w/ S3 access, that is safer than dealing with secrets (recommended by AWS)

@codecov-io
Copy link

codecov-io commented Jun 19, 2018

Codecov Report

Merging #2621 into master will increase coverage by 0.47%.
The diff coverage is 3.44%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2621      +/-   ##
==========================================
+ Coverage    67.6%   68.07%   +0.47%     
==========================================
  Files         339      340       +1     
  Lines       42820    44700    +1880     
  Branches     5290     5796     +506     
==========================================
+ Hits        28948    30430    +1482     
- Misses      13189    13512     +323     
- Partials      683      758      +75
Flag Coverage Δ
#smoketests 50.76% <4%> (ø) ⬆️
#unittests 65.69% <3.44%> (+0.6%) ⬆️
Impacted Files Coverage Δ
nipype/interfaces/io.py 55.73% <3.44%> (+1.26%) ⬆️
nipype/utils/logger.py 81.81% <0%> (-5.49%) ⬇️
nipype/utils/filemanip.py 77.92% <0%> (-0.46%) ⬇️
nipype/interfaces/base/specs.py 93.04% <0%> (-0.1%) ⬇️
nipype/interfaces/nipy/preprocess.py 45.79% <0%> (ø) ⬆️
nipype/interfaces/freesurfer/preprocess.py 66.27% <0%> (ø) ⬆️
nipype/pipeline/plugins/__init__.py 100% <0%> (ø) ⬆️
nipype/interfaces/dynamic_slicer.py 17.47% <0%> (ø) ⬆️
nipype/pipeline/plugins/legacymultiproc.py 61.3% <0%> (ø)
nipype/info.py 94.59% <0%> (+0.56%) ⬆️
... and 9 more

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 704b97d...5abe1c9. Read the comment docs.

Copy link
Member

@mgxd mgxd 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 the PR @anibalsolon - it looks like we're not testing DataSink's s3 behavior currently in our CI 😰

Is that something you'd be interested in adding with this PR?

@anibalsolon
Copy link
Contributor Author

@mgxd isn't that because fakes3 is not installed?

https://github.com/nipy/nipype/blob/master/nipype/interfaces/tests/test_io.py#L319-L321

However, I am not sure about the appropriate way to test the IAM Role + S3. FakeS3 does not implement it.

Copy link
Member

@effigies effigies left a comment

Choose a reason for hiding this comment

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

This looks good to me. If there isn't a good way to automatically test, so be it.

A couple very minor comments.

return bucket


def _get_head_bucket(self, s3_resource, bucket_name):
Copy link
Member

Choose a reason for hiding this comment

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

This should probably be a @staticmethod or a helper function outside the class, as it does not use self at all.

dst_sp = dst.split('/')
dst_sp[0] = dst_sp[0].lower()
dst = '/'.join(dst_sp)
if dst[:len(s3_str)].lower().startswith(s3_str):
Copy link
Member

Choose a reason for hiding this comment

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

Since you're already taking the substring, why not:

if dst[:len(s3_str)].lower() == s3_str:

@@ -123,6 +123,35 @@ def add_traits(base, names, trait_type=None):
return base


def get_head_bucket(s3_resource, bucket_name):
Copy link
Member

Choose a reason for hiding this comment

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

Minor quibble: I would put a _ prefix on the function still, just to mark it as a private function that external code shouldn't rely on.

@anibalsolon
Copy link
Contributor Author

Thank you for the reviews @effigies and @mgxd !

@effigies
Copy link
Member

Thanks. LGTM. @mgxd I'll let you merge if you have no more comments.

@effigies effigies added this to the 1.1.1 milestone Jul 23, 2018
@mgxd mgxd merged commit 7fa55ae into nipy:master Jul 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants