-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Handle slow security policies without blocking gRPC threads. #10633
Conversation
- Introduce PendingAuthListener to handle a ListenableFuture<Status>, progressing the gRPC through each stage in sequence once the future completes and is OK. - Move unit tests away from `checkAuthorizationForService` and into `checkAuthorizationForServiceAsync` since that should be the only method called in production now. - Some tests in `ServerSecurityPolicyTest` had their expectations updated; they previously called synchornous APIs that transformed failed `ListenableFuture<Status>` into one or another status. Now, we call the sync API, so those transformations do not happen anymore, thus the test needs to deal with failed futures directly. - I couldn't figure out if this PR needs extra tests. AFAICT `BinderSecurityTest` should already cover the new codepaths, but please let me know otherwise. This should be the last PR to address grpc#10566.
binder/src/main/java/io/grpc/binder/internal/PendingAuthListener.java
Outdated
Show resolved
Hide resolved
binder/src/main/java/io/grpc/binder/internal/BinderTransportSecurity.java
Outdated
Show resolved
Hide resolved
binder/src/main/java/io/grpc/binder/internal/BinderTransportSecurity.java
Outdated
Show resolved
Hide resolved
binder/src/main/java/io/grpc/binder/internal/PendingAuthListener.java
Outdated
Show resolved
Hide resolved
- Drop sequential executor from PendingAuthListener.
binder/src/main/java/io/grpc/binder/internal/BinderTransportSecurity.java
Outdated
Show resolved
Hide resolved
binder/src/main/java/io/grpc/binder/internal/BinderTransportSecurity.java
Outdated
Show resolved
Hide resolved
binder/src/main/java/io/grpc/binder/internal/BinderTransportSecurity.java
Outdated
Show resolved
Hide resolved
binder/src/main/java/io/grpc/binder/internal/BinderTransportSecurity.java
Outdated
Show resolved
Hide resolved
binder/src/main/java/io/grpc/binder/internal/PendingAuthListener.java
Outdated
Show resolved
Hide resolved
binder/src/main/java/io/grpc/binder/internal/BinderTransportSecurity.java
Show resolved
Hide resolved
binder/src/main/java/io/grpc/binder/internal/PendingAuthListener.java
Outdated
Show resolved
Hide resolved
binder/src/main/java/io/grpc/binder/internal/PendingAuthListener.java
Outdated
Show resolved
Hide resolved
binder/src/main/java/io/grpc/binder/internal/PendingAuthListener.java
Outdated
Show resolved
Hide resolved
binder/src/main/java/io/grpc/binder/internal/PendingAuthListener.java
Outdated
Show resolved
Hide resolved
binder/src/test/java/io/grpc/binder/ServerSecurityPolicyTest.java
Outdated
Show resolved
Hide resolved
- Factory method for PendingAuthListener. - Fix leak of executor when PendingAuthListener encountered an exception while starting the call. - Catching RuntimeException.
- Comment + TODO for multiple concurrent auth checks.
binder/src/main/java/io/grpc/binder/internal/BinderTransportSecurity.java
Outdated
Show resolved
Hide resolved
binder/src/main/java/io/grpc/binder/internal/BinderTransportSecurity.java
Show resolved
Hide resolved
binder/src/main/java/io/grpc/binder/internal/PendingAuthListener.java
Outdated
Show resolved
Hide resolved
binder/src/main/java/io/grpc/binder/internal/PendingAuthListener.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
binder/src/main/java/io/grpc/binder/internal/BinderTransportSecurity.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting really close.
I'm happy with this overall, but I'd like some changes to make this easier to review more completely.
I.e. Undo changes to the struture of interceptCall per my comment there, and undo all unrelated reformatting.
binder/src/test/java/io/grpc/binder/ServerSecurityPolicyTest.java
Outdated
Show resolved
Hide resolved
binder/src/main/java/io/grpc/binder/internal/BinderTransportSecurity.java
Show resolved
Hide resolved
- define BinderTransportSecurity.ShutdownListener interface - take a non-close executor closeable in BinderServer's constructor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for your patience!
Just a couple of minor nits now, then we can go ahead and submit.
There's a couple more things we'll want to do in a follow up to handle nuance around policy decision caching, and server vs. transport shutdown, but this is in a good state.
binder/src/main/java/io/grpc/binder/internal/BinderTransportSecurity.java
Outdated
Show resolved
Hide resolved
binder/src/main/java/io/grpc/binder/internal/BinderTransportSecurity.java
Show resolved
Hide resolved
* resources to be potentially cleaned up. | ||
*/ | ||
public interface ShutdownListener { | ||
void onShutdown(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Server shutdown is actually kind of complex, so if we're going to use the prefix "on" (which I agree makes sense in a listener), we probably want to clarify that this is the server shutdown, and rename this to onServerShutdown().
FWIW, there's actually a bit more nuance here we'll need to handle, but let's leave that for a follow up CL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed.
By "nuance", do you mean code style-wise or are we actually missing something from the implementation? Because if it's the later, I'm not aware of what that is.
checkAuthorizationForService
and intocheckAuthorizationForServiceAsync
since that should be the only method called in production now.ServerSecurityPolicyTest
had their expectations updated; they previously called synchornous APIs that transformed failedListenableFuture<Status>
into one or another status. Now, we call the sync API, so those transformations do not happen anymore, thus the test needs to deal with failed futures directly.BinderSecurityTest
should already cover the new codepaths, but please let me know otherwise.This should be the last PR to address #10566.