Skip to content

fix(mariadb): make cluster chart mode select replication/galera topology#3068

Draft
weicao wants to merge 1 commit into
mainfrom
fix/mariadb-cluster-topology-selectable
Draft

fix(mariadb): make cluster chart mode select replication/galera topology#3068
weicao wants to merge 1 commit into
mainfrom
fix/mariadb-cluster-topology-selectable

Conversation

@weicao

@weicao weicao commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Summary

The addons-cluster/mariadb chart cannot select the replication or galera topology. mode only changes the replica count; the Cluster always resolves an ambiguous componentDef.

Root cause

templates/cluster.yaml used:

componentSpecs:
  - name: mariadb
    componentDef: mariadb
    replicas: {{ include "mariadb-cluster.replicas" . }}

componentDef: mariadb is a name prefix, and the addon ships three CmpDs:

  • mariadb-<version> (standalone)
  • mariadb-replication-merged-<version> (replication)
  • mariadb-galera-<version> (galera)

The prefix mariadb matches all three, so it cannot deterministically select replication or galera. Meanwhile the only topology lever is mode, which templates/_helpers.tpl uses solely to compute replicas (standalone → 1, else .Values.replicas). It never selects a component definition.

values.schema.json further locked this down: mode enum was ["standalone"] only, and replicas had maximum: 1. So even the schema forbade anything but a single standalone node.

The addon already ships a ClusterDefinition named mariadb with three named topologies (standalone default, replication, galera), each pinning the correct compDef by full name — but the cluster chart did not use it.

Fix

Use the KB-native topology selector (same idiom as clickhouse / apecloud-mysql cluster charts):

spec:
  clusterDef: mariadb
  topology: {{ .Values.mode }}
  componentSpecs:
    - name: mariadb
      replicas: {{ include "mariadb-cluster.replicas" . }}
  • mode maps 1:1 to the ClusterDefinition topology names (standalone / replication / galera), so topology: {{ .Values.mode }} resolves the correct compDef.
  • values.schema.json: mode enum expanded to ["standalone", "replication", "galera"]; replicas maximum raised from 1 to 5 (standalone is still forced to 1 by the helper).
  • values.yaml: documented the mode options and replica guidance (replication ≥ 2, galera odd ≥ 3).

Verification

helm template for all three modes renders clusterDef: mariadb + the correct topology:, with no ambiguous componentDef field; standalone forces replicas: 1, replication/galera honor the set value.

The addons-cluster/mariadb chart used `componentDef: mariadb`, a name prefix
that matches all three CmpDs (mariadb-*, mariadb-replication-merged-*,
mariadb-galera-*), so it could not deterministically select replication or
galera. `mode` only drove the replica count. values.schema.json also locked
mode to ["standalone"] and replicas to maximum 1.

Switch to the KB-native selector: clusterDef: mariadb + topology: {{ .Values.mode }},
resolving the correct compDef from the mariadb ClusterDefinition's named
topologies. Expand the mode enum to standalone/replication/galera and raise the
replicas cap to 5 (standalone stays forced to 1 via the helper).

Fixes #3067

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@weicao weicao added the nopick Not auto cherry-pick when PR merged label Jul 6, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (35e0ded) to head (6d33a12).

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #3068   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files        144     144           
  Lines      23013   23013           
=====================================
  Misses     23013   23013           

☔ 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.

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

Labels

nopick Not auto cherry-pick when PR merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants