aasha commented on a change in pull request #2240:
URL: https://github.com/apache/hive/pull/2240#discussion_r637674090



##########
File path: 
ql/src/java/org/apache/hadoop/hive/ql/exec/repl/ranger/RangerRestClientImpl.java
##########
@@ -79,6 +74,7 @@
   private static final String RANGER_REST_URL_EXPORTJSONFILE = 
"service/plugins/policies/exportJson";
   private static final String RANGER_REST_URL_IMPORTJSONFILE =
       "service/plugins/policies/importPoliciesFromFile";
+  private static final String RANGER_REST_URL_DELETEPOLICY = 
"service/public/v2/api/policy";

Review comment:
       is this not available as part of service/plugins/policies?

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/exec/repl/ReplLoadTask.java
##########
@@ -127,6 +127,7 @@ public int execute() {
       if (shouldLoadAtlasMetadata()) {
         addAtlasLoadTask();
       }
+      initiateRangerDenytask();

Review comment:
       you can do this only if deny config is enabled

##########
File path: 
ql/src/java/org/apache/hadoop/hive/ql/exec/repl/ranger/RangerRestClientImpl.java
##########
@@ -420,8 +458,8 @@ boolean checkConnectionPlain(String url, HiveConf hiveConf) 
{
   }
 
   @Override
-  public List<RangerPolicy> addDenyPolicies(List<RangerPolicy> rangerPolicies, 
String rangerServiceName,
-                                            String sourceDb, String targetDb) 
throws SemanticException {
+  public RangerPolicy getDenyPolicyForReplicatedDb(String rangerServiceName,

Review comment:
       are u using the source db param

##########
File path: 
itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationOnHDFSEncryptedZones.java
##########
@@ -97,7 +97,6 @@ public void targetAndSourceHaveDifferentEncryptionZoneKeys() 
throws Throwable {
 
     WarehouseInstance replica = new WarehouseInstance(LOG, miniDFSCluster,
         new HashMap<String, String>() {{
-          put(HiveConf.ConfVars.HIVE_IN_TEST.varname, "false");

Review comment:
       why is this removed?

##########
File path: 
ql/src/java/org/apache/hadoop/hive/ql/exec/repl/ranger/RangerRestClientImpl.java
##########
@@ -444,7 +482,7 @@ boolean checkConnectionPlain(String url, HiveConf hiveConf) 
{
     List<RangerPolicy.RangerPolicyItemAccess> denyExceptionsPolicyItemAccesses 
= new ArrayList<RangerPolicy.
         RangerPolicyItemAccess>();
 
-    resourceNameList.add(sourceDb);
+    resourceNameList.add(targetDb);
     resourceNameList.add("dummy");

Review comment:
       is this dummy needed?

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/exec/repl/RangerDenyTask.java
##########
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.ql.exec.repl;
+
+import com.google.common.annotations.VisibleForTesting;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.metastore.utils.SecurityUtils;
+import org.apache.hadoop.hive.ql.ErrorMsg;
+import org.apache.hadoop.hive.ql.exec.Task;
+import org.apache.hadoop.hive.ql.exec.repl.ranger.RangerRestClient;
+import org.apache.hadoop.hive.ql.exec.repl.ranger.RangerRestClientImpl;
+import org.apache.hadoop.hive.ql.exec.repl.ranger.NoOpRangerRestClient;
+import org.apache.hadoop.hive.ql.exec.repl.ranger.RangerPolicy;
+import org.apache.hadoop.hive.ql.exec.repl.ranger.RangerExportPolicyList;
+import org.apache.hadoop.hive.ql.exec.repl.util.ReplUtils;
+import org.apache.hadoop.hive.ql.parse.SemanticException;
+import org.apache.hadoop.hive.ql.parse.repl.metric.event.Status;
+import org.apache.hadoop.hive.ql.plan.api.StageType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.Serializable;
+import java.net.URL;
+import java.util.ArrayList;
+/**
+ * RangerDenyTask.
+ *
+ * Task to add Ranger Deny Policy
+ **/
+public class RangerDenyTask extends Task<RangerDenyWork> implements 
Serializable {
+    private static final long serialVersionUID = 1L;
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(RangerDenyTask.class);
+
+    private transient RangerRestClient rangerRestClient;
+
+    public RangerDenyTask() {
+        super();
+    }
+
+    @VisibleForTesting
+    RangerDenyTask(final RangerRestClient rangerRestClient, final HiveConf 
conf, final RangerDenyWork work) {
+        this.conf = conf;
+        this.work = work;
+        this.rangerRestClient = rangerRestClient;
+    }
+
+    @Override
+    public String getName() {
+        return "RANGER_DENY";
+    }
+
+    @Override
+    public int execute() {
+        try {
+            LOG.info("Checking Ranger Deny Policy for {}", 
work.getTargetDbName());
+            SecurityUtils.reloginExpiringKeytabUser();
+            if (rangerRestClient == null) {
+                rangerRestClient = getRangerRestClient();
+            }
+            URL url = work.getRangerConfigResource();
+            if (url == null) {
+                throw new 
SemanticException(ErrorMsg.REPL_INVALID_CONFIG_FOR_SERVICE
+                        .format("Ranger configuration is not valid "
+                                + 
ReplUtils.RANGER_CONFIGURATION_RESOURCE_NAME, ReplUtils.REPL_RANGER_SERVICE));
+            }
+            conf.addResource(url);
+            String rangerHiveServiceName = 
conf.get(ReplUtils.RANGER_HIVE_SERVICE_NAME);
+            String rangerEndpoint = conf.get(ReplUtils.RANGER_REST_URL);
+            if (StringUtils.isEmpty(rangerEndpoint)) {
+                throw new 
SemanticException(ErrorMsg.REPL_INVALID_CONFIG_FOR_SERVICE
+                        .format("Ranger endpoint is not valid "
+                                + rangerEndpoint, 
ReplUtils.REPL_RANGER_SERVICE));
+            }
+            if (!rangerRestClient.checkConnection(rangerEndpoint, conf)) {
+                throw new 
SemanticException(ErrorMsg.REPL_EXTERNAL_SERVICE_CONNECTION_ERROR.format(ReplUtils

Review comment:
       in case of auth or authz errors is the error code the same? If yes 
change the error msg




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to