xunliu commented on code in PR #6515:
URL: https://github.com/apache/gravitino/pull/6515#discussion_r1971735841
##########
authorizations/authorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/RangerAuthorizationPlugin.java:
##########
@@ -273,8 +273,13 @@ public Boolean onRoleDeleted(Role role) throws
AuthorizationPluginException {
rangerClient.deleteRole(
rangerHelper.generateGravitinoRoleName(role.name()),
rangerAdminName, rangerServiceName);
} catch (RangerServiceException e) {
- // Ignore exception to support idempotent operation
- LOG.warn("Ranger delete role: {} failed!", role, e);
+ if (e.getMessage().contains("No RangerRole found for name")) {
Review Comment:
The `e.getMessage().contains("No RangerRole found for name")` is Not a
stable way. I think we can use `rangerClient.getRole()?` to double check it.
##########
authorizations/authorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/RangerHelper.java:
##########
@@ -278,9 +278,18 @@ protected RangerRole createRangerRoleIfNotExists(String
roleName, boolean isOwne
try {
rangerRole = rangerClient.getRole(roleName, rangerAdminName,
rangerServiceName);
} catch (RangerServiceException e) {
- // ignore exception, If the role does not exist, then create it.
- LOG.warn("The role({}) does not exist in the Ranger!", roleName);
+
+ // The client will return a error message contains `doesn't have
permission` if the role does
+ // not exist, then create it.
+ if (e.getMessage().contains("User doesn't have permissions to get
details")) {
+ LOG.warn("The role({}) does not exist in the Ranger!, e: {}",
roleName, e);
Review Comment:
The `e.getMessage().contains("User doesn't have permissions to get
details")` is Not a stable way. I think we can use another way to double check
it.
--
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]