You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by pr...@apache.org on 2017/03/07 08:02:27 UTC

zeppelin git commit: [ZEPPELIN-1968] Added property to disable hive user impersonation

Repository: zeppelin
Updated Branches:
  refs/heads/master 89386342f -> 79ace932a


[ZEPPELIN-1968] Added property to disable hive user impersonation

### What is this PR for?

Added new property "hive.proxy.user"  to disable hive impersonation (on some clusters, this option is disabled) in order to make Hive Interpreter even without this

### What type of PR is it?
Feature

### Todos

### What is the Jira issue?
https://issues.apache.org/jira/browse/ZEPPELIN-1968

### How should this be tested?
Set "hive.proxy.user" to true in the jdbc interpreter setttings, and you should see "Using hive proxy user" in the jdbc logs.

If "hive.proxy.user" has another value, this is not mentionned in the logs

You can also test with the appropriate hive configuration, but this could take longer :)

### Screenshots (if appropriate)

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

Author: Paolo Genissel <pa...@1000mercis.com>

Closes #2051 from gfalcone/hive_impersonation and squashes the following commits:

a39d11c [Paolo Genissel] Fixed last NPE
1f7f685 [Paolo Genissel] Fixed NPE when getting hive.proxy.user property
433eefb [Paolo Genissel] Added documentation for feature
d6f0c62 [Paolo Genissel] Added property to disable hive user impersonation


Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/79ace932
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/79ace932
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/79ace932

Branch: refs/heads/master
Commit: 79ace932a9d7de247f7cb0f932cd146d459e617b
Parents: 8938634
Author: Paolo Genissel <pa...@1000mercis.com>
Authored: Fri Mar 3 17:49:35 2017 +0100
Committer: Prabhjyot Singh <pr...@gmail.com>
Committed: Tue Mar 7 13:32:22 2017 +0530

----------------------------------------------------------------------
 docs/interpreter/jdbc.md                              |  5 +++++
 .../org/apache/zeppelin/jdbc/JDBCInterpreter.java     | 14 +++++++++-----
 2 files changed, 14 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/79ace932/docs/interpreter/jdbc.md
----------------------------------------------------------------------
diff --git a/docs/interpreter/jdbc.md b/docs/interpreter/jdbc.md
index 346fcbb..75da51f 100644
--- a/docs/interpreter/jdbc.md
+++ b/docs/interpreter/jdbc.md
@@ -427,8 +427,13 @@ Here are some examples you can refer to. Including the below connectors, you can
     <td>default.password</td>
     <td>hive_password</td>
   </tr>
+  <tr>
+    <td>hive.proxy.user</td>
+    <td>true or false</td>
 </table>
 
+Connection to Hive JDBC with a proxy user can be disabled with `hive.proxy.user` property (set to true by default)
+
 [Apache Hive 1 JDBC Driver Docs](https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients#HiveServer2Clients-JDBC)
 [Apache Hive 2 JDBC Driver Docs](https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients#HiveServer2Clients-JDBC)
 

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/79ace932/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java b/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java
index d495224..0b25a23 100644
--- a/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java
+++ b/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java
@@ -378,16 +378,20 @@ public class JDBCInterpreter extends Interpreter {
                 if (lastIndexOfUrl == -1) {
                   lastIndexOfUrl = connectionUrl.length();
                 }
-                connectionUrl.insert(lastIndexOfUrl, ";hive.server2.proxy.user=" + user + ";");
+                boolean hasProxyUser = property.containsKey("hive.proxy.user");
+                if (!hasProxyUser || !property.getProperty("hive.proxy.user").equals("false")){
+                  logger.debug("Using hive proxy user");
+                  connectionUrl.insert(lastIndexOfUrl, ";hive.server2.proxy.user=" + user + ";");
+                }
                 connection = getConnectionFromPool(connectionUrl.toString(),
-                    user, propertyKey, properties);
+                        user, propertyKey, properties);
               } else {
                 UserGroupInformation ugi = null;
                 try {
-                  ugi = UserGroupInformation.createProxyUser(user,
-                    UserGroupInformation.getCurrentUser());
+                  ugi = UserGroupInformation.createProxyUser(
+                          user, UserGroupInformation.getCurrentUser());
                 } catch (Exception e) {
-                  logger.error("Error in createProxyUser", e);
+                  logger.error("Error in getCurrentUser", e);
                   StringBuilder stringBuilder = new StringBuilder();
                   stringBuilder.append(e.getMessage()).append("\n");
                   stringBuilder.append(e.getCause());