Skip to content

server: fix TLS credentials not passed to tiflow in old architecture mode#3720

Merged
ti-chi-bot[bot] merged 1 commit intopingcap:masterfrom
dumanshu:w_dgo-fix-tls-old-arch
Jan 12, 2026
Merged

server: fix TLS credentials not passed to tiflow in old architecture mode#3720
ti-chi-bot[bot] merged 1 commit intopingcap:masterfrom
dumanshu:w_dgo-fix-tls-old-arch

Conversation

@dumanshu
Copy link
Copy Markdown
Contributor

@dumanshu dumanshu commented Dec 19, 2025

What problem does this PR solve?

Issue Number: close #3718

When TiCDC runs in old architecture mode (delegating to tiflow), TLS credentials passed via CLI flags (--ca, --cert, --key) are not transferred to serverConfig.Security. This causes TiCDC to connect to PD using HTTP instead of HTTPS, resulting in connection failures for TLS-enabled clusters.

What is changed and how it works?

Root cause: In runTiFlowServer(), the code marshals o.serverConfig to JSON and passes it to tiflow. However, o.serverConfig.Security was never populated from the CLI flags before marshaling. The tiflow complete() function then copies from the empty o.ServerConfig.Security back to cfg.Security, overwriting any credentials.

Fix:

  1. Call o.getCredential() to populate serverConfig.Security before JSON marshaling
  2. Remove redundant oldOptions.CaPath/CertPath/KeyPath/AllowedCertCN assignments since credentials are now in ServerConfig.Security

This is similar to how complete() does it for new architecture mode at line 161.

Check List

Tests

  • Unit test

Questions

Will it cause performance regression or break compatibility?

No

Do you need to update user documentation, design documentation or monitoring documentation?

No

Release note

Fix TLS credentials not being passed to tiflow when running TiCDC in old architecture mode, which caused connection failures to TLS-enabled PD clusters.

@ti-chi-bot ti-chi-bot Bot added do-not-merge/needs-triage-completed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. contribution This PR is from a community contributor. first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. labels Dec 19, 2025
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Dec 19, 2025

Hi @dumanshu. Thanks for your PR.

I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot ti-chi-bot Bot added the needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. label Dec 19, 2025
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @dumanshu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request fixes a critical bug in TiCDC's old architecture mode that prevented it from connecting to TLS-enabled PD clusters. The issue was due to TLS credentials from CLI flags not being properly propagated to the underlying tiflow server. The changes ensure that security configurations are correctly initialized and passed, thereby restoring secure communication capabilities and enhancing the system's robustness when TLS is enabled.

Highlights

  • TLS Credential Propagation Fix: Resolved an issue where TLS credentials provided via CLI flags (--ca, --cert, --key) were not correctly passed to the tiflow server when TiCDC operates in old architecture mode. This previously caused connection failures to TLS-enabled PD clusters.
  • Root Cause Identified: The problem stemmed from o.serverConfig.Security not being populated from CLI flags before marshaling o.serverConfig to JSON. Consequently, tiflow's complete() function would overwrite any potential credentials with an empty Security struct.
  • Implementation Details: The fix involves explicitly calling o.getCredential() to populate o.serverConfig.Security with the correct TLS information before the configuration is marshaled to JSON. Additionally, redundant assignments of CaPath, CertPath, KeyPath, and AllowedCertCN to oldOptions were removed, as these are now handled within ServerConfig.Security.
  • New Unit Tests: A new test file server_test.go has been added, including TestRunTiFlowServerPopulatesSecurityConfig to verify the correct transfer and preservation of TLS credentials during JSON marshaling, along with additional tests for the getCredential function and default security initialization.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@ti-chi-bot ti-chi-bot Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 19, 2025
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request effectively resolves the issue of TLS credentials not being passed to tiflow in the old architecture mode. The approach of populating serverConfig.Security before marshaling is correct and directly addresses the root cause. The removal of now-redundant code and the addition of comprehensive unit tests are great improvements. I have one suggestion to refactor the new tests for better maintainability, but overall this is a solid contribution.

Comment thread cmd/cdc/server/server_test.go
@dumanshu dumanshu force-pushed the w_dgo-fix-tls-old-arch branch from 5dedf9f to bece430 Compare December 19, 2025 20:39
@ti-chi-bot ti-chi-bot Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Dec 19, 2025
@wk989898 wk989898 requested a review from wlwilliamx December 20, 2025 06:29
@ti-chi-bot ti-chi-bot Bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Dec 23, 2025
@wlwilliamx
Copy link
Copy Markdown
Collaborator

/check-issue-triage-complete

@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Dec 23, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: wk989898, wlwilliamx

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [wk989898,wlwilliamx]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Dec 23, 2025
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Dec 23, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-12-23 03:05:43.440729173 +0000 UTC m=+2133488.254506755: ☑️ agreed by wlwilliamx.
  • 2025-12-23 13:36:19.753096926 +0000 UTC m=+2171324.566874498: ☑️ agreed by wk989898.

@wk989898
Copy link
Copy Markdown
Collaborator

@dumanshu Please run make fmt to pass the test

@dumanshu dumanshu force-pushed the w_dgo-fix-tls-old-arch branch from bece430 to ec3155b Compare January 6, 2026 20:09
@dumanshu
Copy link
Copy Markdown
Contributor Author

dumanshu commented Jan 6, 2026

/retest-required

@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Jan 6, 2026

@dumanshu: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

In response to this:

/retest-required

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@dumanshu
Copy link
Copy Markdown
Contributor Author

dumanshu commented Jan 6, 2026

@wk989898 Done - ran make fmt and pushed the fix. Could you please run /ok-to-test to trigger CI? Thanks!

@wlwilliamx
Copy link
Copy Markdown
Collaborator

Our CI resource pool has been quite strained these past few days, so CIs are frequently aborted. If this happens, just run /retest again after a while.

@wlwilliamx
Copy link
Copy Markdown
Collaborator

/retest

@dumanshu
Copy link
Copy Markdown
Contributor Author

dumanshu commented Jan 7, 2026

/retest

@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Jan 7, 2026

@dumanshu: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@dumanshu
Copy link
Copy Markdown
Contributor Author

dumanshu commented Jan 7, 2026

/test all

@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Jan 7, 2026

@dumanshu: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

In response to this:

/test all

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@dumanshu
Copy link
Copy Markdown
Contributor Author

dumanshu commented Jan 7, 2026

@wlwilliamx - can you help with /ok-to-test as per #3720 (comment) ?

@wk989898
Copy link
Copy Markdown
Collaborator

wk989898 commented Jan 8, 2026

/ok-to-test

@ti-chi-bot ti-chi-bot Bot added ok-to-test Indicates a PR is ready to be tested. and removed needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Jan 8, 2026
@wk989898
Copy link
Copy Markdown
Collaborator

wk989898 commented Jan 8, 2026

/retest

…mode

When TiCDC runs in old architecture mode, TLS credentials passed via
CLI flags (--ca, --cert, --key) were not transferred to serverConfig.Security
before JSON marshaling. This caused tiflow to receive an empty Security
config, resulting in HTTP connections instead of HTTPS.

Fix by calling o.getCredential() to populate serverConfig.Security before
marshaling, similar to how complete() does it for new architecture mode.

Also remove the redundant oldOptions.CaPath/CertPath/KeyPath/AllowedCertCN
assignments since the credentials are now in ServerConfig.Security.

Closes #3718
@dumanshu dumanshu force-pushed the w_dgo-fix-tls-old-arch branch from ec3155b to 8b166ee Compare January 12, 2026 18:44
@ti-chi-bot ti-chi-bot Bot merged commit dc7b11b into pingcap:master Jan 12, 2026
17 checks passed
@dumanshu dumanshu deleted the w_dgo-fix-tls-old-arch branch January 12, 2026 20:29
a-cong pushed a commit to a-cong/ticdc that referenced this pull request Feb 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved contribution This PR is from a community contributor. first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. lgtm ok-to-test Indicates a PR is ready to be tested. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: TLS credentials not passed to tiflow in old architecture mode

3 participants