Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#4620] improvement(authz): Throw the necessary exception when handling Ranger plugin exception #6515

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jerqi
Copy link
Contributor

@jerqi jerqi commented Feb 25, 2025

What changes were proposed in this pull request?

Don't ignore the necessary exception. We should throw necessary exception from underlying system,

Why are the changes needed?

Fix: #4620

Does this PR introduce any user-facing change?

No.

How was this patch tested?

New uts and existing uts.

@jerryshao
Copy link
Contributor

@xunliu can you please help to review?

// 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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, this method ensures that that a specific ranger role exists.
If the role is not there yet, we'll create it.
This means we may want to print an info log rather than a warning, right?

If the user cannot check if a role exists or not, we still allow the function to continue. Does this mean that a user can create a role but he/she cannot view it?
The role becomes Write-Only for him/her?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Yes, we should use info log.

  2. Usually we use admin user to do these operations, so this case shouldn't occur.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no better way to check this. Do you have suggestion?

@jerqi jerqi changed the title [#4620] improvement(authz): Throw the necessary exception when Ranger plugin the exception [#4620] improvement(authz): Throw the necessary exception when handling Ranger plugin exception Feb 26, 2025
@tengqm
Copy link
Contributor

tengqm commented Feb 26, 2025

lgtm

@@ -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")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if role doesn't, getRole will return exception. It isn't a good way.

// 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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Subtask] Consistency of failure of the underlying system for operational authorization
4 participants