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

s2a,netty: S2AHandshakerServiceChannel doesn't use custom event loop. #11539

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

rmehta19
Copy link
Contributor

@rmehta19 rmehta19 commented Sep 19, 2024

@@ -31,6 +33,36 @@ public final class InternalProtocolNegotiators {

private InternalProtocolNegotiators() {}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ejona86, Is it ok to add this new API? I think we need this to access

public static ProtocolNegotiator tls(SslContext sslContext,
. Please let me if there's a way to do this without making changes to this file

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, adding this API is okay. We'd expect s2a to need to dig deep into Netty at times. The benefit of having it in the same repository is we can use internal APIs easily.

@rmehta19 rmehta19 force-pushed the s2a-handshaker-default-event-loop branch from 03ced73 to a8120bb Compare September 19, 2024 16:15
@rmehta19 rmehta19 changed the title S2AHandshakerServiceChannel doesn't use custom event loop. s2a,netty: S2AHandshakerServiceChannel doesn't use custom event loop. Sep 19, 2024
* Returns a {@link ProtocolNegotiator} that ensures the pipeline is set up so that TLS will
* be negotiated, the {@code handler} is added and writes to the {@link io.netty.channel.Channel}
* may happen immediately, even before the TLS Handshake is complete.
* @param executorPool a dedicated {@link Executor} pool for time-consuming TLS tasks
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't utilize or store executorPool

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For some reason, it didn't get included in original commit, fixed now.

} catch (InterruptedException e) {
isDelegateTerminated = false;
Thread.currentThread().interrupt();
Copy link
Contributor

Choose a reason for hiding this comment

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

if shutdownNow didn't complete, you'll probably want to know about it for debugging, so I'd suggest logging a warning here.

Copy link
Contributor Author

@rmehta19 rmehta19 Sep 20, 2024

Choose a reason for hiding this comment

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

Done in 653ac1e

@@ -227,7 +228,9 @@ protected void handlerAdded0(ChannelHandlerContext ctx) {
@Override
public void onSuccess(SslContext sslContext) {
ChannelHandler handler =
InternalProtocolNegotiators.tls(sslContext).newHandler(grpcHandler);
InternalProtocolNegotiators.tls(
sslContext, new FixedObjectPool<>(Executors.newFixedThreadPool(1)))
Copy link
Member

Choose a reason for hiding this comment

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

This creates a new thread, and doesn't shut it down, for each handshake. If we want to do this temporarily (just as a stepping stone), that is fine, but we'll need to do something better here. (So you can worry about this some in a future PR.)

Since this is client-side, it seems fairly safe to just use an (unlimited) cached thread pool across the connections. That could be served by GrpcUtil.SHARED_CHANNEL_EXECUTOR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion, it SGTM, I've changed it to use the Shared thread pool: 168d62f

@rmehta19 rmehta19 force-pushed the s2a-handshaker-default-event-loop branch from ba02591 to 653ac1e Compare September 20, 2024 01:19
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.

4 participants