-
Notifications
You must be signed in to change notification settings - Fork 50
fix(redisproxy): support classic ArgoCD applications without agent prefix #623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix(redisproxy): support classic ArgoCD applications without agent prefix #623
Conversation
21eeb05 to
7011c20
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #623 +/- ##
=======================================
Coverage 45.90% 45.91%
=======================================
Files 90 90
Lines 12103 12104 +1
=======================================
+ Hits 5556 5557 +1
Misses 6101 6101
Partials 446 446 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…efix ## 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) Signed-off-by: Petr Lebedev <[email protected]>
7011c20 to
b1a112f
Compare
WalkthroughThe pull request modifies Redis command key parsing to treat namespace-only keys as classic (non-agent-managed) applications, returning empty agent name instead of an error. Additionally, a Changes
Sequence DiagramsequenceDiagram
participant Client
participant Parser as extractAgentNameFromRedisCommandKey
participant Logger
participant Router as Redis Router
Client->>Parser: Redis command key (namespace only)
rect rgb(220, 240, 255)
Note over Parser: OLD: Return error
end
rect rgb(240, 255, 240)
Note over Parser: NEW: Log & route to classic
Parser->>Logger: Log debug message
Logger-->>Parser: ✓
Parser->>Router: Return ("", nil)
Router->>Router: Route as classic app
end
Router-->>Client: Forward to principal Redis
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
🔇 Additional comments (3)
Comment |
Summary
Fix a critical issue where RedisProxy fails to handle classic ArgoCD applications (token-based) in mixed environments with agent-managed applications. Classic app Redis keys without agent prefix now route correctly to principal Redis instead of causing connection errors.
It allows to migrate to agents step by step, cluster by cluster and work in mixed environments: classic ArgoCD clusters + Agents.
Type of Change
Description
Problem
The Redis proxy strictly required all keys to have an agent name prefix (
agentName_). This broke classic ArgoCD applications which generate keys without any prefix, causing:Root Cause
extractAgentNameFromRedisCommandKey()function inprincipal/redisproxy/redisproxy.gothrew an error when unable to find underscore separator, assuming all keys would be agent-prefixed.Solution
Modified the function to gracefully handle keys without prefix by:
if agentName != ""checkExample
Before (broken):
After (fixed):
Testing
Test Results Summary
Files Changed
principal/redisproxy/redisproxy.go (lines 817-821)
principal/redisproxy/redisproxy_test.go (lines 54-63)
Routing Behavior After Fix
app|managed-resources|agent-name_app|1.8.3app|managed-resources|app|1.8.3mfst|...orcluster|...Impact
✅ What Works Now
✅ Backward Compatibility
Verification Checklist
Related Issues
Additional Notes for Reviewers
Why This Approach?
Edge Cases
Summary by CodeRabbit
Bug Fixes
Chores