jerqi commented on code in PR #6575:
URL: https://github.com/apache/gravitino/pull/6575#discussion_r1977424172
##########
authorizations/authorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/RangerAuthorizationPlugin.java:
##########
@@ -91,9 +94,42 @@ protected RangerAuthorizationPlugin(String metalake,
Map<String, String> config)
rangerAdminName =
config.get(RangerAuthorizationProperties.RANGER_USERNAME);
// Apache Ranger Password should be minimum 8 characters with min one
alphabet and one numeric.
String password =
config.get(RangerAuthorizationProperties.RANGER_PASSWORD);
- rangerServiceName =
config.get(RangerAuthorizationProperties.RANGER_SERVICE_NAME);
+
+ String serviceName =
config.get(RangerAuthorizationProperties.RANGER_SERVICE_NAME);
rangerClient = new RangerClientExtension(rangerUrl, authType,
rangerAdminName, password);
+ if (Boolean.parseBoolean(
+
config.get(RangerAuthorizationProperties.RANGER_SERVICE_CREATE_IF_ABSENT))) {
+ if (serviceName == null) {
+ serviceName = config.get(BaseAuthorization.UUID);
+ }
+
+ try {
+ rangerClient.getService(serviceName);
+ } catch (RangerServiceException rse) {
+ if (rse.getStatus().equals(ClientResponse.Status.NOT_FOUND)) {
+ try {
+ RangerService rangerService = new RangerService();
+ rangerService.setType(getServiceType());
+ rangerService.setName(serviceName);
+ rangerService.setConfigs(getServiceConfigs(config));
+ rangerClient.createService(rangerService);
+ List<RangerPolicy> policies =
rangerClient.getPoliciesInService(serviceName);
+ for (RangerPolicy policy : policies) {
+ rangerClient.deletePolicy(policy.getId());
+ }
+ } catch (RangerServiceException crse) {
+ throw new AuthorizationPluginException(
+ "Fail to create ranger service %s, exception: %s",
serviceName, crse.getMessage());
+ }
Review Comment:
OK.
--
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]