tengqm commented on code in PR #6515:
URL: https://github.com/apache/gravitino/pull/6515#discussion_r1972590362
##########
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.
Good point. Maybe we need to treat this seriously. For whatever permission
related errors, always raise a special exception type.
--
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]