Skip to content

Conversation

@prabhjyotsingh
Copy link
Contributor

@prabhjyotsingh prabhjyotsingh commented Apr 6, 2017

What is this PR for?

Hive JDBC proxy user option should be available generically.

What type of PR is it?

[Improvement]

What is the Jira issue?

How should this be tested?

Enable Shiro authentication and set zeppelin.jdbc.auth.type as SIMPLE in the interpreter setting, and observe the connection string for the Hive.

Screenshots (if appropriate)

Questions:

  • Does the licenses files need an update? N/A
  • Is there breaking changes for older versions? N/A
  • Does this needs documentation? Yes

@prabhjyotsingh prabhjyotsingh changed the title [Zeppelin 2367] Hive JDBC proxy user option should be avail even without kerberos [Zeppelin 2367] Hive JDBC proxy user option should be available even without kerberos Apr 6, 2017
@r-kamath
Copy link
Member

r-kamath commented Apr 7, 2017

Tested. LGTM.

```

### Impersonation
When Zeppelin server is running with authentication enabled, then this interpreter utilizes Hive's user proxy feature i.e. sends extra parameter for creating and running a session ("hive.server2.proxy.user=": "${loggedInUser}"). This is particularly useful when multi users are sharing a Notebook server.
Copy link
Member

Choose a reason for hiding this comment

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

multi users -> multiple users?

Copy link
Member

Choose a reason for hiding this comment

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

does this affect resource allocation, such as each user could be on different YARN queue and so on?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that could happen, but it was never documented, hence thought to document it here.

}

private void checkAndAppendHiveProxyUser(StringBuilder connectionUrl, String user) {
if (connectionUrl.toString().trim().startsWith("jdbc:hive")) {
Copy link
Member

Choose a reason for hiding this comment

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

hmm.. is this the right approach and abstraction, to have specialize type in a general JDBC interpreter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about other approaches, like using propertyKey, but even in that case name could be anything including default.


if (user != null && !user.equals("anonymous") &&
!"false".equalsIgnoreCase(property.getProperty("hive.proxy.user"))) {
logger.debug("Using hive proxy user");
Copy link
Member

Choose a reason for hiding this comment

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

logger.info?
also, log the user value?

<td></td>
<td><b>( Optional ) </b>Other properties used by the driver of <code>%hive(${prefix})</code> </td>
</tr>
<tr>
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, then I'll revert my changes from this file, and apply it on jdbc.md

<tr>
<td>hive.proxy.user</td>
<td>true</td>
<td><b>( Optional ) </b>If want to use `hive.server2.proxy.user`</td>
Copy link
Contributor

Choose a reason for hiding this comment

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

These back quoters won't work properly in <table> tag. So please use <code> tag like this:
<code>hive.server2.proxy.user</code>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you @AhyoungRyu , have taken care of this in jdbc.md.

@prabhjyotsingh
Copy link
Contributor Author

@AhyoungRyu @felixcheung thank you for the review, have made the suggested changes.

@prabhjyotsingh
Copy link
Contributor Author

@AhyoungRyu, @felixcheung ping

@prabhjyotsingh
Copy link
Contributor Author

Merging this to master and branch-0.7 if no more discussion.

@felixcheung
Copy link
Member

felixcheung commented Apr 14, 2017 via email

@prabhjyotsingh
Copy link
Contributor Author

prabhjyotsingh commented Apr 14, 2017

Yes, I thought of few options but this was bit convenient. Any suggestions?

# Conflicts:
#	jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java
@prabhjyotsingh
Copy link
Contributor Author

@felixcheung any specific change that you are looking for?

@felixcheung
Copy link
Member

felixcheung commented Apr 20, 2017 via email

@prabhjyotsingh
Copy link
Contributor Author

prabhjyotsingh commented Apr 20, 2017

Sure, got it, have renamed it to appendProxyUserToURL.

@felixcheung
Copy link
Member

actually, I wasn't referring to the function name at all. instead of having this fairly hive specific, how about a function like this to take the user name property name and value

// Untested!
 private void appendProxyUserToURL(StringBuilder connectionUrl, String user) {
     if ("true".equalsIgnoreCase(property.getProperty("jdbc.url.set.user") {
       Integer lastIndexOfUrl = connectionUrl.indexOf("?");
       if (lastIndexOfUrl == -1) {
         lastIndexOfUrl = connectionUrl.length();
       }
 
       if (user != null && !user.equals("anonymous") &&
           property.getProperty("jdbc.url.user.property").length() > 1)  { // check not empty or whitespace instead
         logger.info("Using jdbc user as :" + user);
         connectionUrl.insert(lastIndexOfUrl, ";" + property.getProperty("jdbc.url.user.property") + "=" + user + ";");
       }
     }
   }

@prabhjyotsingh
Copy link
Contributor Author

@felixcheung Sure what you have recommended does make a lot of sense, have implemented what you have suggested.

@prabhjyotsingh
Copy link
Contributor Author

Copy link
Member

@felixcheung felixcheung left a comment

Choose a reason for hiding this comment

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

looks reasonable. why is zeppelin.jdbc.auth.kerberos.proxy.enable removed?
also is there a way not to hardcode hive jdbc here

StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(e.getMessage()).append("\n");
stringBuilder.append(e.getCause());
throw new InterpreterException(stringBuilder.toString());
Copy link
Member

Choose a reason for hiding this comment

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

why not just include e as inner exception like InterpreterException(message, e)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure just did it, thank you for the hint.

@prabhjyotsingh
Copy link
Contributor Author

why is zeppelin.jdbc.auth.kerberos.proxy.enable removed?

My bad, while fixing the above issues, I thought this is redundant, but I forgot about the case where KERBEROS is enabled and the user does not want to use proxy behavior. Have reverted that change.

also is there a way not to hardcode hive jdbc here

Hive doesn't work with this (UserGroupInformation.createProxyUser), and since we allow user to configure multiple JDBC sources using the same interpreter setting; there can be a case where user has configured say Phoenix (requires UserGroupInformation.createProxyUser to proxy user) and Hive (fails if UserGroupInformation.createProxyUser is used), we could introduce new parameter like {profile}.kerberos.proxy.enable but this will increase the documentation part.

@prabhjyotsingh
Copy link
Contributor Author

@felixcheung have removed hard coded string "hive" as well.

CI fails for; not relavent for this change.

Tests in error: 
  ParagraphActionsIT.testClearOutputButton:335->AbstractZeppelinIT.clickAndWait:126 » ElementNotVisible

@prabhjyotsingh
Copy link
Contributor Author

@felixcheung ping

Copy link
Member

@felixcheung felixcheung left a comment

Choose a reason for hiding this comment

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

I like it! a few questions

</tr>
</table>

Connection to Hive JDBC with a proxy user can be disabled with `hive.proxy.user` property (set to true by default)
Copy link
Member

Choose a reason for hiding this comment

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

is hive.proxy.user removed then? do we need to doc to explain the migration?
also you have this line here still with hive.proxy.user property (set to true by default)

Copy link
Member

Choose a reason for hiding this comment

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

I guess the preference would be to have a way to migrate existing users and config by having it automatically converted, add a log warning etc.

but it's your call in the specific case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What I meant in above line was the key is default.proxy.user.property with an example value hive.server2.proxy.user; fair point, let me tweak this documentation.

Yes, adding a log (logger.warn) does make sense, let me do it right away.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was looking at http://zeppelin.apache.org/docs/0.7.1/interpreter/jdbc.html#apache-hive, hive.proxy.user hasn't made it to the doc section, so I think in this case no need to add migration steps. However, I have added logger.warn as well.

}
logger.debug("JDBC PropretiesMap: {}", basePropretiesMap);

if (!isEmpty(property.getProperty("zeppelin.jdbc.auth.type"))) {
Copy link
Member

Choose a reason for hiding this comment

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

this is also removed? zeppelin.jdbc.auth.type?

Copy link
Contributor Author

@prabhjyotsingh prabhjyotsingh Apr 29, 2017

Choose a reason for hiding this comment

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

JDBCSecurityImpl.createSecureConfiguration call is moved to line#358 (https://github.com/apache/zeppelin/pull/2229/files/9fee9d2a9e476769b5d28a50d17f3a7ad38fc453#diff-ecdae8ee9594a5c4b21a3c217a3f130cR358). Instead of making this object JDBCSecurityImpl.getAuthtype(property) every time on open() do it only if required.

Copy link
Member

Choose a reason for hiding this comment

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

ah ok, doc change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since it's just a removal of extra call, so no doc change required.


To enable this set following:
- `zeppelin.jdbc.auth.type` as `SIMPLE` or `KERBEROS` (if required) in the interpreter setting.
- `default.proxy.user.property` as `hive.server2.proxy.user`
Copy link
Member

Choose a reason for hiding this comment

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

should we clarify, default here could also be the name of the hive interpreter instance like hive.proxy.user.property?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, let me change this to {propertyKey}.proxy.user.property and post a sample configuration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for reviewing this. Have handled your review comments.

@prabhjyotsingh
Copy link
Contributor Author

@felixcheung Have handled your review comments. Let me know if I missed any.

Copy link
Member

@felixcheung felixcheung left a comment

Choose a reason for hiding this comment

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

LGTM

@prabhjyotsingh
Copy link
Contributor Author

Thank you @felixcheung. Will merge this to master.

@asfgit asfgit closed this in 08a9814 May 3, 2017
asfgit pushed a commit that referenced this pull request May 8, 2017
### What is this PR for?
Fix JDBC doc after #2229.

### What type of PR is it?
[Bug Fix]

### Screenshots (if appropriate)

### Questions:
* Does the licenses files need update?
* Is there breaking changes for older versions?
* Does this needs documentation?

Author: Prabhjyot Singh <[email protected]>

Closes #2314 from prabhjyotsingh/minor/jdbc-doc-zeppelin-2367 and squashes the following commits:

e54a3a2 [Prabhjyot Singh] @AhyoungRyu  review comments
0f396ac [Prabhjyot Singh] fix doc for zeppelin-2367
michelemilesi pushed a commit to icteam-spa/zeppelin that referenced this pull request May 11, 2017
### What is this PR for?
Fix JDBC doc after apache#2229.

### What type of PR is it?
[Bug Fix]

### Screenshots (if appropriate)

### Questions:
* Does the licenses files need update?
* Is there breaking changes for older versions?
* Does this needs documentation?

Author: Prabhjyot Singh <[email protected]>

Closes apache#2314 from prabhjyotsingh/minor/jdbc-doc-zeppelin-2367 and squashes the following commits:

e54a3a2 [Prabhjyot Singh] @AhyoungRyu  review comments
0f396ac [Prabhjyot Singh] fix doc for zeppelin-2367
prabhjyotsingh added a commit to prabhjyotsingh/zeppelin that referenced this pull request Sep 1, 2017
…without kerberos

### What is this PR for?
Hive JDBC proxy user option should be available generically.

### What type of PR is it?
[Improvement]

### What is the Jira issue?
* [Zeppelin 2367](https://issues.apache.org/jira/browse/ZEPPELIN-2367)

### How should this be tested?
Enable Shiro authentication and set `zeppelin.jdbc.auth.type` as `SIMPLE` in the interpreter setting, and observe the connection string for the Hive.

### Screenshots (if appropriate)

### Questions:
* Does the licenses files need an update? N/A
* Is there breaking changes for older versions? N/A
* Does this needs documentation? Yes

Author: Prabhjyot Singh <[email protected]>

Closes apache#2229 from prabhjyotsingh/ZEPPELIN-2367 and squashes the following commits:

84b5e55 [Prabhjyot Singh] add logger.warn for hive and impersonation
45c90a8 [Prabhjyot Singh] improve doc
9fee9d2 [Prabhjyot Singh] replace hive with generic method
a348e96 [Prabhjyot Singh] revert "zeppelin.jdbc.auth.kerberos.proxy.enable" behaviour
e2bdbb2 [Prabhjyot Singh] include e as inner exception
c180f5c [Prabhjyot Singh] Merge remote-tracking branch 'origin/master' into ZEPPELIN-2367
1802b45 [Prabhjyot Singh] remove hive string from logger
513987a [Prabhjyot Singh] apply genric logic to appendProxyUserToURL
3fa2b1e [Prabhjyot Singh] change name to appendProxyUserToURL
a751674 [Prabhjyot Singh] Merge remote-tracking branch 'origin/master' into ZEPPELIN-2367
4c382ee [Prabhjyot Singh] log user details as well
d51e770 [Prabhjyot Singh] add doc in jdbc.md
01b18b9 [Prabhjyot Singh] add doc (reverted from commit ee8a6b5)
40489c8 [Prabhjyot Singh] Merge remote-tracking branch 'origin/master' into ZEPPELIN-2367
ee8a6b5 [Prabhjyot Singh] add doc
8999d93 [Prabhjyot Singh] ZEPPELIN-2367: Hive JDBC proxy user option should be avail even without kerberos
prabhjyotsingh added a commit to prabhjyotsingh/zeppelin that referenced this pull request Oct 23, 2017
…without kerberos

### What is this PR for?
Hive JDBC proxy user option should be available generically.

### What type of PR is it?
[Improvement]

### What is the Jira issue?
* [Zeppelin 2367](https://issues.apache.org/jira/browse/ZEPPELIN-2367)

### How should this be tested?
Enable Shiro authentication and set `zeppelin.jdbc.auth.type` as `SIMPLE` in the interpreter setting, and observe the connection string for the Hive.

### Screenshots (if appropriate)

### Questions:
* Does the licenses files need an update? N/A
* Is there breaking changes for older versions? N/A
* Does this needs documentation? Yes

Author: Prabhjyot Singh <[email protected]>

Closes apache#2229 from prabhjyotsingh/ZEPPELIN-2367 and squashes the following commits:

84b5e55 [Prabhjyot Singh] add logger.warn for hive and impersonation
45c90a8 [Prabhjyot Singh] improve doc
9fee9d2 [Prabhjyot Singh] replace hive with generic method
a348e96 [Prabhjyot Singh] revert "zeppelin.jdbc.auth.kerberos.proxy.enable" behaviour
e2bdbb2 [Prabhjyot Singh] include e as inner exception
c180f5c [Prabhjyot Singh] Merge remote-tracking branch 'origin/master' into ZEPPELIN-2367
1802b45 [Prabhjyot Singh] remove hive string from logger
513987a [Prabhjyot Singh] apply genric logic to appendProxyUserToURL
3fa2b1e [Prabhjyot Singh] change name to appendProxyUserToURL
a751674 [Prabhjyot Singh] Merge remote-tracking branch 'origin/master' into ZEPPELIN-2367
4c382ee [Prabhjyot Singh] log user details as well
d51e770 [Prabhjyot Singh] add doc in jdbc.md
01b18b9 [Prabhjyot Singh] add doc (reverted from commit ee8a6b5)
40489c8 [Prabhjyot Singh] Merge remote-tracking branch 'origin/master' into ZEPPELIN-2367
ee8a6b5 [Prabhjyot Singh] add doc
8999d93 [Prabhjyot Singh] ZEPPELIN-2367: Hive JDBC proxy user option should be avail even without kerberos
@prabhjyotsingh prabhjyotsingh deleted the ZEPPELIN-2367 branch February 25, 2018 03:50
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