feat(plugin-pinot): Add TLS support for self-signed certificate#26151
feat(plugin-pinot): Add TLS support for self-signed certificate#26151nishithakbhaskaran merged 1 commit intoprestodb:masterfrom
Conversation
|
|
Reviewer's GuideThis PR adds end-to-end TLS support for Pinot by introducing a grpc-protobuf dependency, configuring a secure JettyHttpClient with truststore options, and updating authentication headers to use the Basic scheme for all HTTP calls. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
68953c0 to
a9765f5
Compare
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- Refactor HttpClient creation in PinotClusterInfoFetcher to accept a pre-configured client via injection or factory instead of instantiating JettyHttpClient inline with a hardcoded name and null parameters for better configurability and testability.
- Consolidate AUTHORIZATION header logic to avoid setting it twice and ensure the "Basic " prefix is applied consistently across all controller, broker GET, and POST requests.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Refactor HttpClient creation in PinotClusterInfoFetcher to accept a pre-configured client via injection or factory instead of instantiating JettyHttpClient inline with a hardcoded name and null parameters for better configurability and testability.
- Consolidate AUTHORIZATION header logic to avoid setting it twice and ensure the "Basic " prefix is applied consistently across all controller, broker GET, and POST requests.
## Individual Comments
### Comment 1
<location> `presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/PinotBrokerPageSource.java:349-350` </location>
<code_context>
Request.Builder builder = Request.Builder
.preparePost()
.setUri(URI.create(String.format(QUERY_URL_TEMPLATE, pinotConfig.isUseSecureConnection() ? "https" : "http", queryHost)));
+ brokerAuthenticationProvider.getAuthenticationToken(session).ifPresent(token -> builder.setHeader(AUTHORIZATION, "Basic" + " " + token));
brokerAuthenticationProvider.getAuthenticationToken(session).ifPresent(token -> builder.setHeader(AUTHORIZATION, token));
String body = clusterInfoFetcher.doHttpActionWithHeaders(builder, Optional.of(getRequestPayload(pinotQuery)), rpcService);
return populateFromQueryResults(pinotQuery, blockBuilders, types, body);
</code_context>
<issue_to_address>
**issue:** Duplicate header setting for AUTHORIZATION may cause unexpected behavior.
The second assignment will override the first. Remove one to prevent ambiguity and ensure the correct header value is used.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/PinotBrokerPageSource.java
Outdated
Show resolved
Hide resolved
ae654e8 to
bfa2f50
Compare
|
Codenotify: Notifying subscribers in CODENOTIFY files for diff 6616215...f87ba7c. No notifications. |
|
Thanks for the release note! Nits. |
bfa2f50 to
59e5074
Compare
59e5074 to
e52b157
Compare
5a778db to
ed5de8a
Compare
| this.timeBoundaryJsonCodec = requireNonNull(timeBoundaryJsonCodec, "time boundary json codec is null"); | ||
| this.instanceJsonCodec = requireNonNull(instanceJsonCodec, "instance json codec is null"); | ||
| HttpClientConfig config = new HttpClientConfig(); | ||
| if (pinotConfig.isUseSecureConnection()) { |
There was a problem hiding this comment.
Please optimize the code to avoid duplicating the else condition. just like below
if (pinotConfig.isUseSecureConnection()
&& pinotConfig.getGrpcTlsTrustStorePath() != null
&& !pinotConfig.getGrpcTlsTrustStorePath().isEmpty()) {
config.setTrustStorePath(pinotConfig.getGrpcTlsTrustStorePath());
config.setTrustStorePassword(pinotConfig.getGrpcTlsTrustStorePassword());
this.httpClient = new JettyHttpClient("myclient", config, null, Collections.emptyList());
}
else {
this.httpClient = requireNonNull(httpClient, "httpClient is null");
}
There was a problem hiding this comment.
Instead of creating new httpClient here, added these configs during the initial binding time
| .build(); | ||
| Request.Builder builder = Request.builder().prepareGet().setUri(controllerPathUri); | ||
| controllerAuthenticationProvider.getAuthenticationToken().ifPresent(token -> builder.setHeader(AUTHORIZATION, token)); | ||
| controllerAuthenticationProvider.getAuthenticationToken().ifPresent(token -> builder.setHeader(AUTHORIZATION, "Basic" + " " + token)); |
There was a problem hiding this comment.
Why did you change the Authorization header value from token to "Basic" + " " + token?
There was a problem hiding this comment.
It will fix the issue "HTTP protocol violation: Authentication challenge without WWW-Authenticate header"
| <!-- GRPC protobuf--> | ||
| <dependency> | ||
| <groupId>io.grpc</groupId> | ||
| <artifactId>grpc-protobuf</artifactId> |
There was a problem hiding this comment.
Is this runtime dependency relevant for this change?
|
@agrawalreetika imported this issue as lakehouse/presto #26151 |
71bc01a to
cf0b85c
Compare
|
Do we need any changes to the documentation in https://github.com/prestodb/presto/blob/master/presto-docs/src/main/sphinx/connector/pinot.rst#catalog-properties ? |
No new properties are added as per this PR. So changes to this doc file is not requried. |
ShahimSharafudeen
left a comment
There was a problem hiding this comment.
Thanks for the clarifications. LGTM.
7a98092 to
370f49e
Compare
hantangwangd
left a comment
There was a problem hiding this comment.
@Dilli-Babu-Godari, thanks for this feature. Just one little thing, otherwise looks good!
presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/PinotBrokerPageSource.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Nishitha-Bhaskaran <nishithakbhaskaran@gmail.com> Co-authored-by: Lukmanul-hakkeem-A <lukmanul.hakkem.a@ibm.com> Co-authored-by: Reetika Agrawal <agrawal.reetika786@gmail.com>
cd5b2c9 to
f87ba7c
Compare
It was a rebase conflict mistake.Updated the code. Thanks @hantangwangd for pointing this out. |
hantangwangd
left a comment
There was a problem hiding this comment.
Thanks @nishithakbhaskaran, lgtm!
Description
Added TLS support for Pinot for self-signed certificate. Used the existing TLS config properties to set truststore path and password.
Co-authored-by: Dilli-Babu-Godari godari728@gmail.com
Co-authored-by: Nishitha-Bhaskaran nishithakbhaskaran@gmail.com
Co-authored-by: lukmanulhakkeem lukmanul.hakkem.a@ibm.com
Co-authored-by: Reetika Agrawal agrawal.reetika786@gmail.com
Motivation and Context
Impact
Test Plan
Tested in local.
Contributor checklist
Release Notes
Please follow release notes guidelines and fill in the release notes below.