Repository navigation
[BugFix] Support TLS on the operator's MySQL connection to FE - #787
Conversation
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>
4ed4a9c to
d6fa549
Compare
|
@codex review |
There was a problem hiding this comment.
🟢 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.feSslModewith validation and DSN suffix mapping (DISABLED/PREFERRED/REQUIRED; rejectsVERIFY_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.
|
Tick the box to add this pull request to the merge queue (same as
|
* 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
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 enableTLS. When a user sets
ssl_force_secure_transport = trueinfe.conf, FE rejects every operatorconnection with
Error 5205 (HY000): Connections using insecure transport are prohibitedand logsa 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, twosql.Opencall 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 valuestarrocksOperator.feSslMode), with valuesDISABLED/PREFERRED/REQUIRED, defaultPREFERRED.--fe-ssl-modeDISABLEDPREFERRED(default)?tls=preferredCLIENT_SSL, stay plaintext otherwiseREQUIRED?tls=skip-verifyVERIFY_CA/VERIFY_IDENTITYValues 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_IDENTITYwould be unusable in thedocumented deployment; the two names are reserved so certificate verification can be added later
without changing the parameter.
Why
PREFERREDis a safe default: an FE without a keystore does not advertiseCLIENT_SSL, sothe driver takes its
AllowFallbackToPlaintextbranch and behaves exactly like today. This wasmeasured against a live FE before fixing the default (no
tlsparam → 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/mysqlis already vendored andpreferred/skip-verifyare 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 onedsn()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 afterflag.Parse()so abad value fails at startup instead of at the first reconcile.
starrocksOperator.feSslMode: PREFERREDplus a{{- if }}-gated--fe-ssl-modearg (following the--dns-domain-suffixprecedent): setting the value to""ornullomits the whole arg and falls back to the binary default, instead of rendering--fe-ssl-mode=and killing the operator on start.deploy/operator.yamland the parentkube-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 notverified, how to choose a mode, FE-side keystore traps (PKCS12
-keypasssilently ignored;loopback connections exempt from
ssl_force_secure_transport), and both Helm and raw-manifestconfiguration. 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: DISABLEDto return to the exact previous behavior.Verification on this branch:
TestSSLModeDSNSuffix,TestValidateSSLMode,TestSQLExecutorDSN,TestNewSQLExecutor;go test ./pkg/...green.helm lintclean; render checked end to end through the parent chart: default renders--fe-ssl-mode=PREFERRED,--set operator.starrocksOperator.feSslMode=DISABLEDpasses through,an empty value omits the arg.
make generate/make manifestsproduce no diff;golangci-lint run(v2.2.2, the CI-pinnedversion): 0 issues.
with SSL enforced and mode
DISABLEDthe operator logs error 5205 matching FE-side WARNsone-to-one; with the default
PREFERREDon the same FE,SHOW COMPUTE NODESandALTER SYSTEM DROP COMPUTE NODEsucceed (which on a plaintext-rejecting FE can only mean theconnection was upgraded to TLS);
VERIFY_CAand an invalid value each put the new operator podinto CrashLoopBackOff with the intended message while the old pod keeps running. A
helm upgradeacross 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:
make generateto generate the code. — no diff (no API-type change).make lintto check the code style. — golangci-lint v2.2.2: 0 issues.make testto run UT. — all packages ok, including the 24 new subtests inpkg/subcontrollers/cn.make manifeststo update the yaml files of CRD. — no CRD diff (this is a globaloperator flag by design, not a CRD field).
For helm chart, please complete the following checklist:
values.yamlfile of starrocks chart. — the value belongs tothe operator subchart (
kube-starrocks/charts/operator/values.yaml,starrocksOperator.feSslMode: PREFERRED); thestarrockssubchart is deliberately untouched —this flag configures the operator process, not the data plane.
scriptsdirectory, runbash create-parent-chart-values.shto update the values.yamlfile of the parent chart (kube-starrocks chart). — regenerated, committed.