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

Make PulsarAuthorizationProvider#grantPermissionAsync actually async #13897

Merged

Conversation

michaeljmarshall
Copy link
Member

@michaeljmarshall michaeljmarshall commented Jan 21, 2022

Motivation

This PR is based on an observation from #12515. The content is essentially the same, and the goal is to make an async method actually asynchronous.

Modifications

  • Make PulsarAuthorizationProvider#grantPermissionAsync actually async
  • Update the exception handling to ensure correctness
  • Switch from thenRun to whenComplete for handling future completion in several methods in PulsarAuthorizationProvider.

Verifying this change

There are already tests that cover this section of the code.

Does this pull request potentially affect one of the following parts:

This is only an optimization, it does not include any breaking changes.

Documentation

  • no-need-doc

@michaeljmarshall michaeljmarshall added type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages area/broker area/security doc-not-needed Your PR changes do not impact docs labels Jan 21, 2022
@michaeljmarshall michaeljmarshall added this to the 2.10.0 milestone Jan 21, 2022
@michaeljmarshall michaeljmarshall self-assigned this Jan 21, 2022

return result;
future.exceptionally(ex -> {
log.error("[{}] Failed to set permissions for role {} namespace {}", role, role, namespaceName, ex);
Copy link
Member

Choose a reason for hiding this comment

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

  • it seems we need to getCause here.
  • I think [{}] Failed to set policies while set permissions for role {} namespace {} more specific, what do you think about it?

Copy link
Member Author

Choose a reason for hiding this comment

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

@mattisonchao - great catch, we should use getCause here. I'll revisit the log line too. Both of these are copied closely from #12515, so I'll take a look at modifying that code too. Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

Regarding the log line, I think the lack of clarity is because the API is a bit inconsistent by using policies and permission interchangeably. There are several instances in the file that indicate Failed to set permissions or Failed to get permissions. I think we should leave it as is for now and possibly change it in another PR. Let me know what you think. Thanks.

Copy link
Member

Choose a reason for hiding this comment

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

Agree with you +1 !

@michaeljmarshall
Copy link
Member Author

@codelipenghui - I removed the .getCause() method calls.

Copy link
Contributor

@Technoboy- Technoboy- left a comment

Choose a reason for hiding this comment

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

LGTM

@codelipenghui codelipenghui merged commit 125907c into apache:master Jan 27, 2022
@michaeljmarshall michaeljmarshall deleted the make-grant-permission-async-async branch January 28, 2022 06:04
@michaeljmarshall
Copy link
Member Author

@codelipenghui - since this is only an optimization and not a bug fix, I didn't expect this to get cherry picked back to any maintenance branches? How do we determine what goes into maintenance branches? Thanks.

@codelipenghui
Copy link
Contributor

@michaeljmarshall I have removed release/2.9.3. I thought it was a fix after encountering a problem before.

Nicklee007 pushed a commit to Nicklee007/pulsar that referenced this pull request Apr 20, 2022
…pache#13897)

### Motivation

This PR is based on an observation from apache#12515. The content is essentially the same, and the goal is to make an async method _actually_ asynchronous.

### Modifications

* Make `PulsarAuthorizationProvider#grantPermissionAsync` actually async
* Update the exception handling to ensure correctness
* Switch from `thenRun` to `whenComplete` for handling future completion in several methods in `PulsarAuthorizationProvider`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/broker area/security doc-not-needed Your PR changes do not impact docs type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants