Skip to content

[BugFix] Support TLS on the operator's MySQL connection to FE - #787

Merged
yandongxiao merged 1 commit into
StarRocks:mainfrom
yandongxiao:port-oss-46443404
Jul 31, 2026
Merged

yandongxiao merged 1 commit into
StarRocks:mainfrom
yandongxiao:port-oss-46443404

Conversation

@yandongxiao

Copy link
Copy Markdown
Collaborator

Description

The operator opens its MySQL connection to FE (used for SHOW COMPUTE NODES,
ALTER SYSTEM DROP COMPUTE NODE, DROP WAREHOUSE) in plaintext only, with no switch to enable
TLS. When a user sets ssl_force_secure_transport = true in fe.conf, FE rejects every operator
connection with Error 5205 (HY000): Connections using insecure transport are prohibited and logs
a WARN for each attempt — roughly 10–14 failures per FE per minute in a real deployment, burying
real errors in log noise. There is exactly one MySQL connection site in the repo
(pkg/subcontrollers/cn/cn_mysql.go, two sql.Open call sites) and its DSN ends in a bare /.

Fix: append a tls= parameter to that DSN, controlled by one new global operator flag
--fe-ssl-mode (Helm value starrocksOperator.feSslMode), with values DISABLED / PREFERRED /
REQUIRED, default PREFERRED.

--fe-ssl-mode DSN suffix Semantics
DISABLED none plaintext; byte-for-byte the behavior that predates this change
PREFERRED (default) ?tls=preferred encrypt when FE advertises CLIENT_SSL, stay plaintext otherwise
REQUIRED ?tls=skip-verify always encrypt; fail when FE does not support SSL
VERIFY_CA / VERIFY_IDENTITY — recognized but rejected at startup, with an error explaining why

Values are matched case-insensitively; an unrecognized or empty value makes the operator fail to
start
rather than silently fall back to plaintext. The server certificate is never verified in
any mode — FE's own documentation generates a self-signed keystore whose certificate name cannot
match the Kubernetes service DNS name, so VERIFY_CA / VERIFY_IDENTITY would be unusable in the
documented deployment; the two names are reserved so certificate verification can be added later
without changing the parameter.

Why PREFERRED is a safe default: an FE without a keystore does not advertise CLIENT_SSL, so
the driver takes its AllowFallbackToPlaintext branch and behaves exactly like today. This was
measured against a live FE before fixing the default (no tls param → success, ?tls=preferred →
success, ?tls=skip-verify → TLS requested but server does not support TLS).

No new dependency, no CRD change, no RBAC change, no certificate mounting.
go-sql-driver/mysql is already vendored and preferred / skip-verify are its native values.

Changes:

  • pkg/subcontrollers/cn/cn_mysql_ssl.go (new) — the mode constants, ValidateSSLMode,
    sslModeDSNSuffix.
  • pkg/subcontrollers/cn/cn_mysql.go — the two duplicated DSN literals collapsed into one dsn()
    method, so a future change cannot make one query path negotiate TLS while the other stays
    plaintext.
  • cmd/config/config.go, cmd/main.go — the flag, validated immediately after flag.Parse() so a
    bad value fails at startup instead of at the first reconcile.
  • Operator subchart — starrocksOperator.feSslMode: PREFERRED plus a {{- if }}-gated
    --fe-ssl-mode arg (following the --dns-domain-suffix precedent): setting the value to "" or
    null omits the whole arg and falls back to the binary default, instead of rendering
    --fe-ssl-mode= and killing the operator on start.
  • deploy/operator.yaml and the parent kube-starrocks/values.yaml — regenerated
    (scripts/operator.sh, scripts/create-parent-chart-values.sh).
  • doc/connect_to_ssl_enabled_fe_howto.md (new) — how the flag works, why certificates are not
    verified, how to choose a mode, FE-side keystore traps (PKCS12 -keypass silently ignored;
    loopback connections exempt from ssl_force_secure_transport), and both Helm and raw-manifest
    configuration. Indexed in doc/README.md.

Upgrade behavior: nothing in the StatefulSet / Pod rendering path is touched, so FE / BE / CN
pods are not restarted — only the operator's own Deployment rolls. The only behavioral change is
that an FE which already advertises SSL will get an encrypted operator connection; set
feSslMode: DISABLED to return to the exact previous behavior.

Verification on this branch:

  • 24 new/extended unit subtests across TestSSLModeDSNSuffix, TestValidateSSLMode,
    TestSQLExecutorDSN, TestNewSQLExecutor; go test ./pkg/... green.
  • helm lint clean; render checked end to end through the parent chart: default renders
    --fe-ssl-mode=PREFERRED, --set operator.starrocksOperator.feSslMode=DISABLED passes through,
    an empty value omits the arg.
  • make generate / make manifests produce no diff; golangci-lint run (v2.2.2, the CI-pinned
    version): 0 issues.
  • End-to-end behavior was verified on a kind cluster against FE 4.x with a real SSL keystore:
    with SSL enforced and mode DISABLED the operator logs error 5205 matching FE-side WARNs
    one-to-one; with the default PREFERRED on the same FE, SHOW COMPUTE NODES and
    ALTER SYSTEM DROP COMPUTE NODE succeed (which on a plaintext-rejecting FE can only mean the
    connection was upgraded to TLS); VERIFY_CA and an invalid value each put the new operator pod
    into CrashLoopBackOff with the intended message while the old pod keeps running. A helm upgrade
    across this change left FE/CN StatefulSets untouched (same UID / restartCount /
    controller-revision-hash / resourceVersion).

Related Issue(s)

N/A — reported by an enterprise customer running the operator against an FE with
ssl_force_secure_transport = true (operator v1.11.x has the defect).

Checklist

For operator, please complete the following checklist:

  • run make generate to generate the code. — no diff (no API-type change).
  • run make lint to check the code style. — golangci-lint v2.2.2: 0 issues.
  • run make test to run UT. — all packages ok, including the 24 new subtests in
    pkg/subcontrollers/cn.
  • run make manifests to update the yaml files of CRD. — no CRD diff (this is a global
    operator flag by design, not a CRD field).

For helm chart, please complete the following checklist:

  • make sure you have updated the values.yaml file of starrocks chart. — the value belongs to
    the operator subchart (kube-starrocks/charts/operator/values.yaml,
    starrocksOperator.feSslMode: PREFERRED); the starrocks subchart is deliberately untouched —
    this flag configures the operator process, not the data plane.
  • In scripts directory, run bash create-parent-chart-values.sh to update the values.yaml
    file of the parent chart (kube-starrocks chart). — regenerated, committed.

The operator opens its MySQL connection to FE in plaintext only. When a
user sets ssl_force_secure_transport=true on FE, FE rejects every
operator connection with "Error 5205 (HY000): Connections using insecure
transport are prohibited" and logs a WARN each time, flooding the FE log.

Add a global --fe-ssl-mode flag (Helm value starrocksOperator.feSslMode)
with values DISABLED / PREFERRED / REQUIRED, default PREFERRED, mapped
onto go-sql-driver's tls= DSN parameter:

- DISABLED: plaintext, byte-for-byte the previous behavior.
- PREFERRED (default): encrypt when FE advertises CLIENT_SSL, stay
  plaintext otherwise — a cluster without SSL behaves exactly as before.
- REQUIRED: always encrypt (tls=skip-verify), fail when FE does not
  support SSL.
- VERIFY_CA / VERIFY_IDENTITY: recognized but rejected at startup — FE's
  documented keystore is self-signed, so certificate verification cannot
  succeed; the names are reserved for the future.

An unrecognized or empty value stops the operator at startup instead of
silently falling back to plaintext. The two duplicated DSN literals in
cn_mysql.go are collapsed into one dsn() method so both query paths
always honor the same mode. No new dependency, no CRD change, no RBAC
change; deploy/operator.yaml and the parent chart values are regenerated.

Signed-off-by: yandongxiao <yandongxiao@starrocks.com>
@kevincai
kevincai requested a review from Copilot July 30, 2026 18:11
@kevincai

Copy link
Copy Markdown
Collaborator

@codex review

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.

🟢 Ready to approve

The TLS mode behavior is consistently applied via a shared DSN builder, validated at startup, and is covered by targeted unit tests plus Helm/manifests/docs updates.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

Adds configurable TLS negotiation for the operator’s MySQL-protocol connections to FE (used for maintenance statements), addressing failures when FE enforces ssl_force_secure_transport = true by allowing the operator to use opportunistic or required TLS via a new global flag and Helm value.

Changes:

  • Introduces --fe-ssl-mode / starrocksOperator.feSslMode with validation and DSN suffix mapping (DISABLED / PREFERRED / REQUIRED; rejects VERIFY_CA / VERIFY_IDENTITY).
  • Refactors FE DSN construction into a single dsn() path so both execute/query flows consistently honor the configured TLS mode.
  • Updates Helm charts, raw manifest, and documentation to expose/configure the new option and describe behavior/limitations.
File summaries
File Description
pkg/subcontrollers/cn/cn_mysql.go Adds per-executor SSL mode capture and centralizes DSN construction used by both query/exec paths.
pkg/subcontrollers/cn/cn_mysql_test.go Extends unit tests to assert DSN rendering and executor SSL mode propagation from global config.
pkg/subcontrollers/cn/cn_mysql_ssl.go Implements SSL mode constants, normalization, validation, and DSN TLS parameter suffix mapping.
pkg/subcontrollers/cn/cn_mysql_ssl_test.go Adds unit coverage for SSL mode validation and DSN suffix behavior.
cmd/main.go Adds --fe-ssl-mode flag and validates it immediately after flag.Parse() (fail fast).
cmd/config/config.go Adds global FeSslMode configuration variable documentation.
helm-charts/charts/kube-starrocks/charts/operator/values.yaml Adds starrocksOperator.feSslMode default and documentation comments.
helm-charts/charts/kube-starrocks/charts/operator/templates/deployment.yaml Plumbs feSslMode into operator args (conditionally omitted when empty).
helm-charts/charts/kube-starrocks/values.yaml Exposes umbrella-chart value operator.starrocksOperator.feSslMode with documentation.
deploy/operator.yaml Adds --fe-ssl-mode=PREFERRED to the raw manifest args.
doc/README.md Indexes the new SSL-enabled FE connectivity how-to.
doc/connect_to_ssl_enabled_fe_howto.md Documents the flag semantics, mode selection guidance, and verification limitations.
Review details
  • Files reviewed: 12/12 changed files
  • Comments generated: 0
  • Review effort level: Low

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

@mergify

mergify Bot commented Jul 30, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@yandongxiao
yandongxiao merged commit 4a490d9 into StarRocks:main Jul 31, 2026
7 checks passed
@yandongxiao yandongxiao mentioned this pull request Sep 14, 2026
4 of 6 tasks
blarghmatey added a commit to mitodl/ol-infrastructure that referenced this pull request Oct 26, 2026
* feat(starrocks): require TLS on the operator's connection to FE

Operator 1.11.7 added --fe-ssl-mode (StarRocks/starrocks-kubernetes-operator#787)
and defaults it to PREFERRED, which falls back to plaintext whenever the FE stops
advertising SSL. QA and Production FEs carry a keystore, so those operators now
run REQUIRED. CI's FE has no keystore and stays PREFERRED.

ssl_force_secure_transport stays off: ol-analytics-api's aiomysql pool connects
without TLS and would be refused. The stack comments now say that instead of
pointing at the operator, which no longer blocks it.

Claude-Session: https://claude.ai/code/session_016sFknxDrTqhEdxCTuLEMt7

* doc(starrocks): name unchecked TLS clients and Vault's TLS param

Claude-Session: https://claude.ai/code/session_016sFknxDrTqhEdxCTuLEMt7
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.

3 participants