Skip to content

Commit 21eeb05

Browse files
committed
fix(redisproxy): support classic ArgoCD applications without agent prefix
## Problem The redisproxy implementation strictly required all Redis keys to start with an agent name prefix in the format 'agentName_'. This worked for agent-managed applications but broke for classic ArgoCD applications (using token authentication) which generate Redis keys without any prefix. When a key without the prefix arrived at redisproxy, the extractAgentNameFromRedisCommandKey function would fail with 'unexpected lack of "_" namespace/name separator' error, causing PUB/SUB connections to drop and resource requests for classic applications to fail completely. ## Solution Modified extractAgentNameFromRedisCommandKey function to gracefully handle Redis keys without the agent prefix by: 1. Detecting keys without underscore separator in the namespace field 2. Returning empty string (instead of error) for non-agent-prefixed keys 3. This allows these keys to be routed to the principal Redis instead of failing The routing logic in handleConnectionMessageLoop already supports this via the 'if agentName != ""' check, which will forward local keys to principal Redis. ## Changes Made ### principal/redisproxy/redisproxy.go - Modified extractAgentNameFromRedisCommandKey() function - Changed error case for missing underscore to return empty string with debug log - Updated comments to clarify behavior for classic vs agent-managed applications ### principal/redisproxy/redisproxy_test.go - Updated test cases to reflect new behavior - Changed 'errorExpected: true' to 'errorExpected: false' for classic app keys - Updated test descriptions to clarify that keys without prefix are classic apps ## Testing ✅ All existing tests pass (21 tests in redisproxy package) ✅ Code compiles without errors ✅ Multi-platform Docker image builds successfully (linux/amd64 and linux/arm64) ## Impact - ✅ Agent-managed applications continue to work as before - ✅ Classic ArgoCD applications now work correctly - ✅ Mixed environments with both types of applications are now supported - ✅ No breaking changes to existing functionality ## Example Routing - Agent-managed key: 'app|managed-resources|agent-managed_my-app|1.8.3' → Routed to agent via gRPC - Classic app key: 'app|managed-resources|my-app|1.8.3' → Routed to principal Redis (control plane)
1 parent 74dd148 commit 21eeb05

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ vendor/
66
build/
77
__pycache__
88
site/
9+
local*.sh

principal/redisproxy/redisproxy.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -814,10 +814,11 @@ func extractAgentNameFromRedisCommandKey(redisKey string, logCtx *logrus.Entry)
814814
namespaceAndName := splitByPipe[2]
815815

816816
// It is not possible to create a namespace name containing a '_' value, so this is a correct delimiter
817+
// If the namespace/name doesn't contain '_', it's a classic (non-agent-managed) application
818+
// and should be forwarded to principal redis
817819
if !strings.Contains(namespaceAndName, "_") {
818-
errMsg := fmt.Sprintf("unexpected lack of '_' namespace/name separate: '%s'", redisKey)
819-
logCtx.Error(errMsg)
820-
return "", fmt.Errorf("%s", errMsg)
820+
logCtx.Debugf("Redis key without agent prefix detected: '%s'. Routing to principal redis.", redisKey)
821+
return "", nil
821822
}
822823

823824
// namespace is the agent name

principal/redisproxy/redisproxy_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@ func Test_extractAgentNameFromRedisCommandKey(t *testing.T) {
5151
errorExpected: false,
5252
},
5353
{
54-
name: "'app|managed-resources' with only namespace",
54+
name: "'app|managed-resources' with only namespace (classic app without agent prefix)",
5555
key: "app|managed-resources|my-app|1.8.3",
5656
value: "",
57-
errorExpected: true,
57+
errorExpected: false,
5858
},
5959
{
60-
name: "'app|resources-tree' with only namespace",
60+
name: "'app|resources-tree' with only namespace (classic app without agent prefix)",
6161
key: "app|resources-tree|my-app|1.8.3.gz",
6262
value: "",
63-
errorExpected: true,
63+
errorExpected: false,
6464
},
6565
{
6666
name: "'app|resources-tree' with unexpected field format",

0 commit comments

Comments
 (0)