Skip to content

Commit ec0785f

Browse files
androndoclaude
andcommitted
fix(redis-operator): use REDISCLI_AUTH for valkey-cli auth in generated scripts
The freshworks-oss operator authenticates the CLI in its generated readiness and shutdown scripts by exporting the engine's auth env var before invoking it. For the Valkey engine it used VALKEYCLI_AUTH, but valkey-cli honours only REDISCLI_AUTH (its --help documents that name and no VALKEYCLI_AUTH). With auth enabled the readiness probe's valkey-cli call therefore returned NOAUTH, the role never resolved, and the data pods never became Ready. Patch valkeyEngine.CLIAuthEnvName to REDISCLI_AUTH so auth-enabled Valkey instances pass readiness. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Signed-off-by: Andrey Kolkov <[email protected]>
1 parent daa867c commit ec0785f

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
diff --git a/operator/redisfailover/service/engine.go b/operator/redisfailover/service/engine.go
2+
index 1601924..9c27ce9 100644
3+
--- a/operator/redisfailover/service/engine.go
4+
+++ b/operator/redisfailover/service/engine.go
5+
@@ -22,7 +22,7 @@ type valkeyEngine struct{}
6+
7+
func (valkeyEngine) ServerBinary() string { return "valkey-server" }
8+
func (valkeyEngine) CLIBinary() string { return "valkey-cli" }
9+
-func (valkeyEngine) CLIAuthEnvName() string { return "VALKEYCLI_AUTH" }
10+
+func (valkeyEngine) CLIAuthEnvName() string { return "REDISCLI_AUTH" }
11+
12+
// EngineFor returns the engine implementation for pod generation. Empty or Redis uses Redis binaries; Valkey uses Valkey binaries.
13+
func EngineFor(rf *redisfailoverv1.RedisFailover) DatabaseEngineProvider {
14+
diff --git a/operator/redisfailover/service/engine_test.go b/operator/redisfailover/service/engine_test.go
15+
index 9f95b09..3724e0a 100644
16+
--- a/operator/redisfailover/service/engine_test.go
17+
+++ b/operator/redisfailover/service/engine_test.go
18+
@@ -19,7 +19,7 @@ func TestEngineFor(t *testing.T) {
19+
}{
20+
{"omitted is redis", "", "redis-server", "redis-cli", "REDISCLI_AUTH"},
21+
{"redis", redisfailoverv1.RedisEngine, "redis-server", "redis-cli", "REDISCLI_AUTH"},
22+
- {"valkey", redisfailoverv1.ValkeyEngine, "valkey-server", "valkey-cli", "VALKEYCLI_AUTH"},
23+
+ {"valkey", redisfailoverv1.ValkeyEngine, "valkey-server", "valkey-cli", "REDISCLI_AUTH"},
24+
}
25+
for _, tc := range cases {
26+
t.Run(tc.name, func(t *testing.T) {
27+
diff --git a/test/integration/redisfailover/database_engine_test.go b/test/integration/redisfailover/database_engine_test.go
28+
index dc6b10e..6cc4da9 100644
29+
--- a/test/integration/redisfailover/database_engine_test.go
30+
+++ b/test/integration/redisfailover/database_engine_test.go
31+
@@ -185,10 +185,10 @@ func (c *clients) testValkeyWorkloadBinaries(t *testing.T, currentNamespace, rfN
32+
shutdownCM, err := c.k8sClient.CoreV1().ConfigMaps(currentNamespace).Get(context.Background(), fmt.Sprintf("rfr-s-%s", rfName), metav1.GetOptions{})
33+
require.NoError(err)
34+
assert.Contains(shutdownCM.Data["shutdown.sh"], "valkey-cli")
35+
- assert.Contains(shutdownCM.Data["shutdown.sh"], "VALKEYCLI_AUTH")
36+
+ assert.Contains(shutdownCM.Data["shutdown.sh"], "REDISCLI_AUTH")
37+
38+
readinessCM, err := c.k8sClient.CoreV1().ConfigMaps(currentNamespace).Get(context.Background(), fmt.Sprintf("rfr-readiness-%s", rfName), metav1.GetOptions{})
39+
require.NoError(err)
40+
assert.Contains(readinessCM.Data["ready.sh"], "valkey-cli")
41+
- assert.Contains(readinessCM.Data["ready.sh"], "VALKEYCLI_AUTH")
42+
+ assert.Contains(readinessCM.Data["ready.sh"], "REDISCLI_AUTH")
43+
}

0 commit comments

Comments
 (0)