vikaskr22 commented on code in PR #1359:
URL: https://github.com/apache/ranger/pull/1359#discussion_r4750557703


##########
security-admin/src/main/java/org/apache/ranger/biz/KmsKeyMgr.java:
##########
@@ -558,26 +569,37 @@ private void throwServiceNotFoundException(String 
serviceName) {
 
     private String[] getKMSURL(String name) throws Exception {
         String[] providers;
+        String   dbKmsUrl;
 
         try {
             RangerService rangerService = svcStore.getServiceByName(name);
 
-            if (rangerService != null) {
-                String kmsUrl   = 
rangerService.getConfigs().get(KMS_URL_CONFIG);
-                String dbKmsUrl = kmsUrl;
+            if (rangerService == null) {
+                throw new Exception("Service " + name + " not found");
+            }
 
-                if (providerList.containsKey(kmsUrl)) {
-                    kmsUrl = providerList.get(kmsUrl);
-                } else {
-                    providerList.put(kmsUrl, kmsUrl);
-                }
+            dbKmsUrl = rangerService.getConfigs().get(KMS_URL_CONFIG);
+        } catch (Exception excp) {
+            logger.error("getServiceByName({}) failed", name, excp);
 
-                providers = createProvider(dbKmsUrl, kmsUrl);
+            throw new Exception("getServiceByName(" + name + ") failed", excp);
+        }
+
+        // Validate the saved provider before Ranger Admin connects to it
+        validateProviderUrl(name, dbKmsUrl);

Review Comment:
   Agree on this @vyommani . 
   
   I can see same validation logic at two places in the same method, although 
it is against different values. I believe second  check where you are 
validating each created KMS provider is more important and final check and we 
should keep that one only.
   
   Pls see if first invocation of validateProviderUrl can be removed ?



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to