-
Notifications
You must be signed in to change notification settings - Fork 32
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
SSH tunnel support for S3Store #882
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #882 +/- ##
==========================================
+ Coverage 87.76% 88.16% +0.39%
==========================================
Files 44 45 +1
Lines 3614 3633 +19
==========================================
+ Hits 3172 3203 +31
+ Misses 442 430 -12 ☔ View full report in Codecov by Sentry. |
Thanks @mjwen , this looks like a nice enhancement. After a quick review, can I ask for two changes?
Finally (and this is a bigger ask), if you'd be able to add a page to the docs describing how to connect via SSH, I'm sure many users would appreciate it. But I understand if that's not possible at this time. |
@rkingsbury thanks for the quick feedback! Great that the functionality looks alright to you. I will add the enhancements (tests and docs) you mentioned above and ping you once ready. |
def local_port_available(local_port): # noqa: PT004 | ||
"""Fixture to determine if a local port is available to test the SSH tunnel.""" | ||
client = paramiko.SSHClient() | ||
client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) |
Check failure
Code scanning / CodeQL
Accepting unknown SSH host keys when using Paramiko High test
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.
Would the tests work if you were to set client.set_missing_host_key_policy(RejectPolicy)
? If so, please do that. If not, it's OK b/c this is just a test file so I'm not so concerned about security issues like this.
See here for more details: https://github.com/materialsproject/maggma/security/code-scanning/138
@rkingsbury I've addressed your comments. Sorry for the delay. A couple of stuff to consider before we think about merging it in?
|
Is there some way to spoof the ssh_tunnel connection? So I think if the basic tests are designed only in a way to check the arguments to For more complex tests, you can consider mocking the entry functions to the ssh_tunnel and have that turn some kind of a flag, then you just have to check that connecting to a DB properly hits that flag? |
Thanks @mjwen !
I'll defer to Jimmy on this one, and I think the approach he suggested sounds ok (just make sure we are passing the right arguments, not testing the tunnel itself)
I'm not sure I follow - as far as I can tell, the current docs you linked are up to date. I think you just need to add modify a . I guess the docs build process isn't document, but we use |
@rkingsbury My bad regarding the docs! I was looking for some configure file in the |
@jmmshn Thanks for the suggestions! Sounds like a good compromise for the CI tests. I've added some fake tunnel to test the functionality s3store. |
@rkingsbury Ready for final review. Note, the CI won't test some of the attributes assignments of the SSHTunnel because of the way we are setting it up. Also, the CI tests seem fail. I've taken a quick look at it -- seems related to |
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.
Thanks @mjwen , looks good. I just have a few minor typo edits to suggest.
Apologies for the CI issues; apparently there was a setuptools update or something that broke the tests. They should be working now if you pull the latest.
def local_port_available(local_port): # noqa: PT004 | ||
"""Fixture to determine if a local port is available to test the SSH tunnel.""" | ||
client = paramiko.SSHClient() | ||
client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) |
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.
Would the tests work if you were to set client.set_missing_host_key_policy(RejectPolicy)
? If so, please do that. If not, it's OK b/c this is just a test file so I'm not so concerned about security issues like this.
See here for more details: https://github.com/materialsproject/maggma/security/code-scanning/138
I've checked I believe we need to leave it like that. |
Thanks @mjwen ! |
Summary
This PR adds the support to use an ssh tunnel for
S3Store
, which can be useful for self-hosted MinIO. This follows the same pattern as the ssh tunnel support forMongoStore
.ssh_tunnel.py
and moved the SSHTunnel class and related stuff there. It's a bit weird to put it in the monogostore file.local_port
for the SSHTunnel class. This is necessary for MinIO, by default which uses the 9000 port. The original implementation that uses an automatically chosen free port will not work in general.ssh_tunnel
support for theS3Store
.SSHTunnel
.