Skip to content

Conversation

ksobolew
Copy link
Contributor

@ksobolew ksobolew commented Oct 21, 2025

Description

This includes automatic generation of TLS certificates for internal communication when the certificate is not configured explicitly in the ANNOUNCE node discovery mode.

Additional context and related issues

This follows up on the node inventory refactoring in #26083.

Release notes

( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
(x) Release notes are required, with the following suggested text:

## Section
* Enabled automatic TLS certificate generation in the `ANNOUNCE` node discovery mode. ({issue}`issuenumber`)

Summary by Sourcery

Enable automatic TLS setup for internal communications in both node discovery and announce modes by extracting and applying the configuration logic into a reusable module.

New Features:

  • Enable automatic TLS certificate generation in the ANNOUNCE node discovery mode when certificates are not explicitly configured.

Enhancements:

  • Extract internal communication HTTP client configuration into a new InternalCommunicationForDiscoveryModule.
  • Refactor AirliftNodeInventoryModule and AnnounceNodeInventoryModule to install the new reusable module instead of duplicating setup logic.

So that it can be reused for other announce modes.
This includes automatic generation of TLS certificates for internal
communication when the certificate is not configured explicitly.
@cla-bot cla-bot bot added the cla-signed label Oct 21, 2025
@ksobolew ksobolew requested a review from dain October 21, 2025 09:22
@sourcery-ai
Copy link

sourcery-ai bot commented Oct 21, 2025

Reviewer's Guide

Introduced a reusable module to centralize internal communication setup and enabled automatic TLS certificate generation for ANNOUNCE discovery mode by delegating client configuration and request filters to the new module.

Class diagram for InternalCommunicationForDiscoveryModule and related changes

classDiagram
    class InternalCommunicationForDiscoveryModule {
        -Class<? extends Annotation> httpClientQualifier
        +InternalCommunicationForDiscoveryModule(httpClientQualifier)
        +setup(Binder binder)
    }
    class DiscoveryEncodeAddressAsHostname {
        +filterRequest(Request request) Request
        -toIpEncodedAsHostnameUri(URI uri) URI
    }
    InternalCommunicationForDiscoveryModule <|-- DiscoveryEncodeAddressAsHostname
    class InternalCommunicationConfig {
        +isHttpsRequired() boolean
        +getKeyStorePath() String
        +getTrustStorePath() String
    }
    class InternalAuthenticationManager
    class HttpClientConfig
    class HttpRequestFilter
    InternalCommunicationForDiscoveryModule --> InternalCommunicationConfig
    InternalCommunicationForDiscoveryModule --> HttpClientConfig
    InternalCommunicationForDiscoveryModule --> HttpRequestFilter
    InternalCommunicationForDiscoveryModule --> InternalAuthenticationManager
    DiscoveryEncodeAddressAsHostname ..|> HttpRequestFilter
Loading

File-Level Changes

Change Details Files
Extract internal communication setup into a reusable discovery module
  • Created InternalCommunicationForDiscoveryModule to encapsulate HttpClientConfig binding and request filter logic
  • Moved TLS requirement check and optional DiscoveryEncodeAddressAsHostname filter into the module
  • Bound InternalAuthenticationManager within the module for authentication
core/trino-main/src/main/java/io/trino/node/InternalCommunicationForDiscoveryModule.java
core/trino-main/src/main/java/io/trino/node/AirliftNodeInventoryModule.java
core/trino-main/src/main/java/io/trino/node/AnnounceNodeInventoryModule.java
Update discovery modules to install the new communication module
  • Removed inline HttpClientConfig and filter setup from AirliftNodeInventoryModule
  • Added install of InternalCommunicationForDiscoveryModule with the appropriate qualifier in both AirliftNodeInventoryModule and AnnounceNodeInventoryModule
core/trino-main/src/main/java/io/trino/node/AirliftNodeInventoryModule.java
core/trino-main/src/main/java/io/trino/node/AnnounceNodeInventoryModule.java

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • Consider renaming InternalCommunicationForDiscoveryModule (and its private DiscoveryEncodeAddressAsHostname) to more descriptive, reusable names (e.g. InternalCommunicationHttpClientModule / IpToHostnameRequestFilter) to clarify intent and enable future reuse.
  • Extract DiscoveryEncodeAddressAsHostname into a top-level, testable filter class so that DNS-to-hostname translation logic can be reused and validated in isolation.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider renaming InternalCommunicationForDiscoveryModule (and its private DiscoveryEncodeAddressAsHostname) to more descriptive, reusable names (e.g. InternalCommunicationHttpClientModule / IpToHostnameRequestFilter) to clarify intent and enable future reuse.
- Extract DiscoveryEncodeAddressAsHostname into a top-level, testable filter class so that DNS-to-hostname translation logic can be reused and validated in isolation.

## Individual Comments

### Comment 1
<location> `core/trino-main/src/main/java/io/trino/node/InternalCommunicationForDiscoveryModule.java:71` </location>
<code_context>
-                    .build();
-        }
-
-        private static URI toIpEncodedAsHostnameUri(URI uri)
-        {
-            if (!uri.getScheme().equals("https")) {
</code_context>

<issue_to_address>
**issue:** Potential edge case if uri.getHost() returns null.

Check for a null host before calling InetAddress.getByName to prevent exceptions.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants