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

DRILL-7547: Support credentials store for mongo connections #2001

Closed

Conversation

dobesv
Copy link
Contributor

@dobesv dobesv commented Feb 28, 2020

DRILL-7547: Support credentials store for mongo connections

Description

This uses the hadoop Configuration.getPassword method to retrieve the
username and password for mongo connections. This allows the user to
supply credentials or credential store configuration in core-site.xml
instead of inlining the credentials in the storage plugin configuration
that is stored in ZooKeeper.

Refer to the CredentialProviderAPI document for more information about
how credential provider plugins work.

Documentation

Defining Credentials in the Drill core-site.xml File

To configure the mongo username and password in Drill's core-site.xml file, navigate to the $DRILL_HOME/conf or $DRILL_SITE directory, and rename the core-site-example.xml file to core-site.xml. Insert your mongo username and password as shown in the following example:

   <configuration>
       <property>
           <name>drill.exec.store.mongo.username</name>
           <value>drill</value>
       </property>
       <property>
           <name>drill.exec.store.mongo.password</name>
           <value>secretpassword</value>
       </property>
   </configuration>  

Remove any username and password from your mongo storage plugin configuration if you do this.

Notes

  • as with the S3 plugin you can configure an external credentials provider. Refer to those docs for details
  • if you have multiple mongo storage plugins setup or your mongo plugin is not named mongo, replace "mongo" in the property name with the name of the storage plugin you are configuring, e.g. for a storage plugin named "mongo2" you would set drill.exec.store.mongo2.username and drill.exec.store.mongo2.password

Testing

JUnit tests and manual test.

This uses the hadoop `Configuration.getPassword` method to retrieve the
username and password for mongo connections.  This allows the user to
supply credentials or credential store configuration in core-site.xml
instead of inlining the credentials in the storage plugin configuration
that is stored in ZooKeeper.

Refer to the CredentialProviderAPI document for more information about
how credential provider plugins work.
@dobesv dobesv force-pushed the DRILL-7547/mongodb-credentials-store branch from c9d98d1 to caa8538 Compare February 28, 2020 04:47
@cgivre
Copy link
Contributor

cgivre commented Feb 28, 2020

@dobesv Thanks for this! Once this is approved, can you update the Mongo Storage Plugin info on the gh-pages branch for the main Drill website?

@cgivre
Copy link
Contributor

cgivre commented Feb 28, 2020

A question and a comment:

  1. What happens if the user has multiple mongo storage plugins? Are the creds carried over to all of them? If a user specifies creds in the storage plugin config does it overwrite the config file?

  2. This isn't for this PR, but would it make sense for us to do this for other storage plugins that are not likely to have multiple instances? Kudu, HBase or Hive for instance?

@dobesv
Copy link
Contributor Author

dobesv commented Feb 28, 2020

  1. What happens if the user has multiple mongo storage plugins? Are the creds carried over to all of them? If a user specifies creds in the storage plugin config does it overwrite the config file?

The configuration key is based on the plugin name, actually. mongo is the default name for the storage plugin, but if you had another one named mongo-prod you would set drill.exec.store.mongo-prod.username.

If the connection string already has credentials, this will not replace them.

  1. This isn't for this PR, but would it make sense for us to do this for other storage plugins that are not likely to have multiple instances? Kudu, HBase or Hive for instance?

I think it is an OK approach for any plugin that has credentials currently stored in ZooKeeper. Note that the key I use is based on the plugin's name so you can setup multiple.

@dobesv
Copy link
Contributor Author

dobesv commented Feb 28, 2020

@arina-ielchiieva Great catch on the core-site.xml location, I totally thought I had put that in the test resources before, such a silly mistake. Hooray for code reviews!

I think I addressed your other comments as well, and I did a bit of research and added some more detail to the core-site-example file. The credentials provider system is actually pretty powerful once you get into it.

@arina-ielchiieva
Copy link
Member

LGTM, +1

@asfgit asfgit closed this in 0c5e347 Mar 2, 2020
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.

None yet

3 participants