Conversation
A ValkeyNode created without a ValkeyCluster never left CreateContainerConfigError. buildContainersDef wired PRIMARY_AUTH to getSystemPasswordSecretName(node.Labels[LabelCluster]), and with no cluster label that resolves to "internal--system-passwords" -- the empty cluster name collapsing the two dashes -- which no controller creates. The surrounding code already anticipates a node created on its own: operatorUserPasswordSecret returns nil on an empty cluster name, and the exporter sidecar is gated on an explicit enabled: true for the same reason. PRIMARY_AUTH was the site that was missed. Move the replication flags into replicationArgsAndEnv, a sibling of valkeyAnnounceArgsAndEnv, which returns nothing when the cluster label is absent. A node with no cluster has no primary to replicate from, so the flags and the env are omitted rather than pointed at a Secret that cannot exist. TestBuildValkeyNodePodTemplateSpec was asserting the broken shape: its fixture sets no labels, so it was a standalone node expecting --primaryauth. It now asserts the standalone shape, and a new test covers the cluster-owned branch. Signed-off-by: seok <seok.engineer@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughChangesThe container resource builder now adds Replication authentication
Suggested reviewers: Priority: ➖ Normal Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to Standalone nodes no longer reference cluster credentials, while cluster-owned nodes retain replication authentication. No actionable merge risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Warning Some tools did not complete. Review the errors below. 🔧 golangci-lint (2.13.2)Error: build linters: plugin(logcheck): plugin "logcheck" not found Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
|
@Alfex4936 |
|
Yeah, One question though, since it decides whether this PR is useful to you at all: will a #387 says data pods reuse Also, separate from all that: Happy to cut this down to just the test change, or close it, whichever you prefer. |
This PR closes #438
Summary
A
ValkeyNodecreated without aValkeyClusternever starts. Its container asks forinternal--system-passwords, a Secret that cannot exist, and the pod sits inCreateContainerConfigError.I ran into this while checking whether a single non-cluster node was possible today. I applied a
bare
ValkeyNode, the StatefulSet came up fine, and then the pod just never went Ready:The double dash is the giveaway.
buildContainersDefwiresPRIMARY_AUTHtogetSystemPasswordSecretName(node.Labels[LabelCluster]), and with no cluster label that name is builtfrom an empty string.
What made me think this was a bug and not intended is that the code around it already handles this
case.
operatorUserPasswordSecretreturns nil when the cluster name is empty, with the comment"this can be empty only when valkeynode is created independently without ValkeyCluster CR". The
exporter sidecar is gated on an explicit
enabled: truefor the same reason, "so a standalone nodemust not gain one by default". And
ensureConfigMapbuilds the node its own ConfigMap whenServerConfigMapNameis empty, rendered bygenerateValkeyNodeConfig, which deliberately leavescluster-enabledoff. So a cluster-less node is provided for in three places.PRIMARY_AUTHlookslike the one site that was missed.
Features / Behaviour Changes
For a node with no
valkey.io/clusterlabel,--primaryuser,--primaryauthand thePRIMARY_AUTHenv are no longer set. Such a node has no primary to replicate from, so the flags had nothing to do
anyway.
Cluster-owned nodes are unchanged.
Implementation
Pulled the replication flags into
replicationArgsAndEnv, a sibling of the existingvalkeyAnnounceArgsAndEnv, returning(nil, nil)when the cluster label is absent. That keepsbuildContainersDefreadable, since the args and env were being appended inline.Limitations
This only makes a bare
ValkeyNodestart. It is still a single non-cluster server with no Service,no replica and no failover, which is what the
ValkeyCRD in #388 / #390 is for. I expect whatevercontroller backs that CRD will create
ValkeyNodes with no cluster label, so it lands on this pathtoo.
Testing
make testandmake lintpass.TestBuildValkeyNodePodTemplateSpecwas asserting the broken shape: its fixture sets no labels, so itwas a standalone node expecting
--primaryauth. Updated it to the standalone expectation, and addedTestBuildValkeyNodePodTemplateSpec_ClusterNodeHasReplicationAuthfor the other branch, so both sidesof the guard are covered.
Also ran both sides for real, on Kubernetes 1.35, with the manager built from
main(3ec092d) andits cache restricted to one namespace with
--watch-namespace.Before, applying the bare
ValkeyNodefrom #438:After, with this patch (the existing pod has to be deleted once, since the StatefulSet rollout is
blocked behind a pod that will never go Ready):
The node reports
cluster_enabled:0, and the operations cluster mode rejects all work:MGETacross slotsCROSSSLOT1 2MSETacross slotsCROSSSLOTOKDELCROSSSLOT2SUNIONacross slotsCROSSSLOTa bMULTI/EXECspanning keysCROSSSLOTOK OKSELECT 1ERR DB index is out of rangeOKChecklist
Before submitting the PR make sure the following are checked:
pre-commit run --all-filesor hooks on commit)