Skip to content

Add TLS channel failure reporting hooks#18299

Draft
HTHou wants to merge 3 commits into
masterfrom
codex/trusted-channel-failure-hooks
Draft

Add TLS channel failure reporting hooks#18299
HTHou wants to merge 3 commits into
masterfrom
codex/trusted-channel-failure-hooks

Conversation

@HTHou

@HTHou HTHou commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds internal hooks for reporting SSL/TLS channel setup failures together with the initiator and target endpoints. It does not add or expose a new logging or persistence surface.

Failure context

  • Add a shared failure callback that propagates the original exception and both channel endpoints.
  • Generalize the existing session-specific failure event name for use across transport types.
  • Recognize SSL failures through the exception cause chain while preserving the original connection failure behavior.
  • Isolate reporting callback failures so they do not replace the transport exception.

Transport coverage

  • Report outbound SSL failures for ConfigNode-to-DataNode, DataNode-to-ConfigNode, DataNode-to-DataNode, and DataNode-to-AINode request paths.
  • Report inbound TLS handshake failures for ConfigNode RPC, DataNode internal RPC, MPP exchange, IoTConsensus V1/V2, and the Session/JDBC-facing RPC service.
  • Report Jetty HTTPS handshake failures for the REST service.
  • Keep plaintext paths unchanged and use no-op callbacks when failure reporting is not configured.

Validation

  • mvn test -pl iotdb-core/node-commons -Dtest=AbstractAuditLoggerTest,TrustedChannelAuditServerEventHandlerTest
  • mvn test -pl external-service-impl/rest -am -Dtest=TrustedChannelAuditHandshakeListenerTest -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false
  • mvn test-compile -DskipTests -pl external-service-impl/rest -am
  • mvn test-compile -P with-zh-locale -DskipTests -pl external-service-impl/rest -am
  • mvn dependency:analyze-only -pl external-service-impl/rest -DskipTests
  • Spotless, Checkstyle, and git diff --check

This PR has:

  • been self-reviewed.
  • added Javadocs for the shared callback and server-side handler.
  • added unit tests for the new failure-reporting paths.

Key changed/added classes (or packages if there are too many classes) in this PR
  • AbstractAuditLogger
  • TrustedChannelFailureHandler
  • TrustedChannelAuditServerEventHandler
  • TrustedChannelAuditHandshakeListener
  • ConsensusConfig
  • ConfigNode/DataNode internal RPC client and service entry points

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds internal (non-user-facing) hooks to report SSL/TLS channel setup failures with both initiator and target endpoints, integrating the reporting into existing audit logging and wiring it through key outbound/inbound transport entry points (Thrift RPC, MPP exchange, consensus RPC, and REST over Jetty HTTPS).

Changes:

  • Introduces a shared TrustedChannelFailureHandler callback and AbstractAuditLogger helpers to detect SSL failures (via cause chain) and emit a trusted-channel failure audit record.
  • Adds server-side TLS handshake probing/reporting via TrustedChannelAuditServerEventHandler for Thrift services and a Jetty SslHandshakeListener implementation for REST HTTPS.
  • Wires failure reporting into multiple outbound request paths (clients/dispatchers/handlers) and consensus configuration, plus adds unit tests and i18n message constants.

Reviewed changes

Copilot reviewed 37 out of 37 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pom.xml Adds Jetty jetty-io to dependency management for HTTPS handshake listener support.
iotdb-core/node-commons/src/test/java/org/apache/iotdb/commons/service/TrustedChannelAuditServerEventHandlerTest.java Unit tests for server-side Thrift TLS handshake reporting behavior.
iotdb-core/node-commons/src/test/java/org/apache/iotdb/commons/audit/AbstractAuditLoggerTest.java Unit tests for SSL failure detection and trusted-channel audit recording.
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/service/TrustedChannelAuditServerEventHandler.java Server-side Thrift event handler to force handshake and report failures with endpoints.
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/request/AsyncRequestManager.java Adds an extensibility hook (onRequestFailure) for request-failure reporting.
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/audit/TrustedChannelFailureHandler.java New shared callback interface for trusted-channel failure reporting.
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/audit/AuditEventType.java Replaces the prior session-specific encrypt failure event with a generalized trusted-channel event.
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/audit/AbstractAuditLogger.java Adds SSL-failure detection and a trusted-channel failure audit log emission path (with i18n).
iotdb-core/node-commons/src/main/i18n/zh/org/apache/iotdb/commons/i18n/CommonMessages.java Adds zh i18n template for the trusted-channel failure audit log message.
iotdb-core/node-commons/src/main/i18n/en/org/apache/iotdb/commons/i18n/CommonMessages.java Adds en i18n template for the trusted-channel failure audit log message.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/ExternalRPCService.java Wraps external RPC service handler with the trusted-channel server-side audit handler.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/DataNodeInternalRPCService.java Wraps internal RPC service handler with the trusted-channel server-side audit handler.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/scheduler/FragmentInstanceDispatcherImpl.java Records trusted-channel failures on dispatch exceptions to remote nodes.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/scheduler/AsyncSendPlanNodeHandler.java Records trusted-channel failures on async plan-node send errors (captures target endpoint).
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/scheduler/AsyncPlanNodeSender.java Passes target endpoint into the async send handler for accurate failure reporting.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/exchange/source/SourceHandle.java Records trusted-channel failures on MPP source exchange RPC errors.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/exchange/sink/SinkChannel.java Records trusted-channel failures on MPP sink exchange RPC errors.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/exchange/MPPDataExchangeService.java Wraps MPP exchange service handler with the trusted-channel server-side audit handler.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/dn/AsyncTSStatusRPCHandler.java Records trusted-channel failures on async TSStatus RPC failures.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java Records trusted-channel failures when connecting/retrying ConfigNode RPC calls.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/an/AINodeClient.java Records trusted-channel failures when connecting/retrying AINode RPC calls.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/consensus/DataRegionConsensusImpl.java Plumbs trusted-channel failure handler into consensus config creation.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/audit/DNAuditLogger.java Adds a DataNode-side convenience overload to record failures with inferred local endpoint.
iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/pipe/service/IoTConsensusV2RPCService.java Wraps IoTConsensusV2 RPC handler with trusted-channel server-side audit handler; accepts callback.
iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/pipe/IoTConsensusV2.java Passes trusted-channel failure handler into IoTConsensusV2 RPC service construction.
iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/service/IoTConsensusRPCService.java Wraps IoTConsensus RPC handler with trusted-channel server-side audit handler; accepts callback.
iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensus.java Passes trusted-channel failure handler into IoTConsensus RPC service construction.
iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/config/ConsensusConfig.java Adds trusted-channel failure handler to consensus config with NO_OP default and builder setter.
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCService.java Wraps ConfigNode RPC handler with trusted-channel server-side audit handler.
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncDataNodeClientPool.java Records trusted-channel failures during ConfigNode→DataNode sync request retries.
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/CnToDnInternalServiceAsyncRequestManager.java Hooks async request failures to ConfigNode audit logger via the new onRequestFailure extension point.
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeHeartbeatClientPool.java Records trusted-channel failures during async heartbeat dispatch failures.
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/audit/CNAuditLogger.java Adds a ConfigNode-side convenience overload to record failures with inferred local endpoint.
external-service-impl/rest/src/test/java/org/apache/iotdb/rest/TrustedChannelAuditHandshakeListenerTest.java Unit test for capturing endpoints on Jetty HTTPS handshake failures.
external-service-impl/rest/src/main/java/org/apache/iotdb/rest/TrustedChannelAuditHandshakeListener.java Jetty SslHandshakeListener implementation to report TLS handshake failures with endpoints.
external-service-impl/rest/src/main/java/org/apache/iotdb/rest/RestService.java Installs the Jetty handshake listener for REST HTTPS connector TLS failures.
external-service-impl/rest/pom.xml Adds Jetty jetty-io dependency required by the handshake listener types.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 45.12635% with 152 lines in your changes missing coverage. Please review.
✅ Project coverage is 43.04%. Comparing base (d9040c0) to head (f154305).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
...service/TrustedChannelAuditServerEventHandler.java 71.42% 14 Missing ⚠️
...iotv2/container/IoTV2GlobalComponentContainer.java 7.69% 12 Missing ⚠️
...confignode/client/sync/SyncDataNodeClientPool.java 0.00% 11 Missing ⚠️
...mmons/pipe/sink/client/IoTDBSyncClientManager.java 31.25% 11 Missing ⚠️
...s/client/sync/SyncIoTConsensusV2ServiceClient.java 0.00% 9 Missing ⚠️
...client/async/AsyncDataNodeHeartbeatClientPool.java 0.00% 8 Missing ⚠️
...tdb/rest/TrustedChannelAuditHandshakeListener.java 70.83% 7 Missing ⚠️
...sync/CnToDnInternalServiceAsyncRequestManager.java 0.00% 7 Missing ⚠️
.../sink/client/IoTDBConfigNodeSyncClientManager.java 0.00% 7 Missing ⚠️
...ache/iotdb/db/protocol/client/an/AINodeClient.java 0.00% 7 Missing ⚠️
... and 19 more
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #18299      +/-   ##
============================================
+ Coverage     42.99%   43.04%   +0.05%     
- Complexity      374      377       +3     
============================================
  Files          5362     5365       +3     
  Lines        381410   381854     +444     
  Branches      49512    49574      +62     
============================================
+ Hits         164003   164387     +384     
- Misses       217407   217467      +60     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 46 out of 46 changed files in this pull request and generated 3 comments.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 46 out of 46 changed files in this pull request and generated 5 comments.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
E Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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.

2 participants