feat(helm): add cluster mode values for Dragonfly chart#7123
feat(helm): add cluster mode values for Dragonfly chart#7123VedantMadane wants to merge 3 commits intodragonflydb:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds first-class Helm values for enabling Dragonfly’s Redis-compatible cluster mode, so users don’t need to manually supply extraArgs for common cluster flags.
Changes:
- Introduces
cluster.modeandcluster.experimentalShardBySlotin chartvalues.yaml. - Updates the pod template to append
--cluster_mode=...and optionally--experimental_cluster_shard_by_slot=truebased on those values.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| contrib/charts/dragonfly/values.yaml | Adds documented cluster.* values for cluster mode and slot-based sharding. |
| contrib/charts/dragonfly/templates/_pod.tpl | Renders the corresponding Dragonfly CLI flags when cluster.mode is set. |
| extraArgs: [] | ||
|
|
||
| cluster: | ||
| # -- Redis cluster protocol mode passed to Dragonfly as --cluster_mode. Use "emulated", "yes", or leave empty to disable cluster mode. |
There was a problem hiding this comment.
.Values.cluster.mode is documented as accepting "yes", but in YAML users often write mode: yes (unquoted), which parses as a boolean and can either render --cluster_mode=true or even break the ne comparison during templating. Consider updating the docs here to explicitly require quoting (e.g. mode: "yes") and/or changing the chart to coerce the value to string before comparing/printing.
| # -- Redis cluster protocol mode passed to Dragonfly as --cluster_mode. Use "emulated", "yes", or leave empty to disable cluster mode. | |
| # -- Redis cluster protocol mode passed to Dragonfly as --cluster_mode. | |
| # -- This value must be quoted because YAML may parse unquoted `yes` as a boolean. | |
| # -- Use `mode: "emulated"` or `mode: "yes"`, or leave empty to disable cluster mode. |
| {{- if ne (.mode | default "") "" }} | ||
| - "--cluster_mode={{ .mode }}" | ||
| {{- end }} | ||
| {{- if and (ne (.mode | default "") "") .experimentalShardBySlot }} |
There was a problem hiding this comment.
The ne (.mode | default "") "" check and --cluster_mode={{ .mode }} assume .mode is a string; if a user sets cluster.mode: yes without quotes, Helm may parse it as boolean and this comparison can fail (or render --cluster_mode=true). Coerce .mode to a string (and ideally validate allowed values) before comparing/using it.
| {{- if ne (.mode | default "") "" }} | |
| - "--cluster_mode={{ .mode }}" | |
| {{- end }} | |
| {{- if and (ne (.mode | default "") "") .experimentalShardBySlot }} | |
| {{- $clusterMode := printf "%v" (.mode | default "") }} | |
| {{- if ne $clusterMode "" }} | |
| - "--cluster_mode={{ $clusterMode }}" | |
| {{- end }} | |
| {{- if and (ne $clusterMode "") .experimentalShardBySlot }} |
|
augment review |
Abhra303
left a comment
There was a problem hiding this comment.
Thanks for the PR, see some comments.
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} No newline at end of file |
There was a problem hiding this comment.
add back newline at the end of the file
There was a problem hiding this comment.
Done, restored the trailing newline.
|
|
||
| cluster: | ||
| # -- Redis cluster protocol mode passed to Dragonfly as --cluster_mode. | ||
| # -- Use "emulated" or "yes" (must be quoted in YAML to avoid boolean coercion). |
There was a problem hiding this comment.
If the user passes unquoted yes, the template won't validate this and and df will fail. I suggest to either validate the input and fail if the input is not string or support boolean yes as well. As you're adding a cluster specific fields, it makes sense to support boolean yes as well.
for boolean yes support :
{{- with .Values.cluster }}
{{- $modeRaw := .mode | default "" }}
{{- $clusterMode := "" }}
{{- if kindIs "bool" $modeRaw }}
{{- if $modeRaw }}{{- $clusterMode = "yes" }}{{- end }}
{{- else }}
{{- $clusterMode = $modeRaw | toString }}
{{- end }}
{{- if ne $clusterMode "" }}
- "--cluster_mode={{ $clusterMode }}"
{{- end }}
Or, if you want to validate:
{{- with .Values.cluster }}
{{- $modeRaw := .mode | default "" }}
{{- if kindIs "bool" $modeRaw }}
{{- fail "cluster.mode must be a quoted string — use '\"yes\"' or '\"emulated\"' (unquoted 'yes' is parsed as a YAML boolean)" }}
{{- end }}
{{- $clusterMode := $modeRaw | toString }}
There was a problem hiding this comment.
Good call, went with the boolean coercion approach. If .mode is a bool (unquoted yes in YAML), it now maps to the string "yes". Updated the values.yaml comment to document that behavior too.
|
Also wondering we have |
|
@VedantMadane please squash and sign your commits. See this for details: Lines 35 to 53 in 31a8fd3 |
|
You raise a fair point about That said, if you prefer the extraArgs-only approach, I am happy to simplify the PR to just the documentation changes. Let me know which direction you would like. Regarding squash and sign-off: will do that now. |
2817e38 to
da26108
Compare
Add dedicated cluster.mode and cluster.node_count values to the Helm chart so users can enable cluster mode without resorting to extraArgs. The template coerces unquoted YAML booleans (yes/no) to the string Dragonfly expects, preventing silent misconfiguration. Fixes dragonflydb#3861 Signed-off-by: Vedant Madane <vedant.madane@gmail.com>
Summary
Adds predefined Helm values for Redis-compatible cluster mode so users can enable Dragonfly cluster flags without hand-writing
extraArgs.Changes
values.yaml: newcluster.mode(maps to--cluster_mode) andcluster.experimentalShardBySlot(maps to--experimental_cluster_shard_by_slot=truewhen mode is set)templates/_pod.tpl: append the corresponding CLI args whencluster.modeis non-emptyNotes
Valid
cluster.modevalues match the Dragonfly flag:emulated,yes, or empty to leave cluster mode disabled. See servercluster_support.ccfor flag semantics.Fixes #3861