fix(backend): resolve issue with concurrent agent-session creation#986
Conversation
Signed-off-by: Rahul Shetty <rashetty@redhat.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (5)
WalkthroughThe changes replace Unix timestamp-based naming and identification schemes with UUID-based generation across multiple OAuth and Kubernetes resource handlers. The Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Gkrumbach07
left a comment
There was a problem hiding this comment.
This is great! been bugging me for a while now
…mbient-code#986) ## Summary Replaces all timestamp-based (time.Now().Unix()) resource name generation with UUID-based naming (github.com/google/uuid) to eliminate conflicts under concurrent requests. ### Problem The POST `/api/projects/{PROJECT_NAME}/agentic-sessions` endpoint used `time.Now().Unix()` (1-second precision) to generate session names like session-1711234567. Concurrent requests within the same second produced identical names, causing K8s resource creation conflicts. Reported Bug: ambient-code#976 ### Fix Use uuid.New().String() to guarantee uniqueness regardless of request timing. The same pattern was applied to all other timestamp-based name generators in the backend: <img width="1489" height="504" alt="image" src="https://github.com/user-attachments/assets/86098226-fc0f-45c7-af1c-f172249a3c96" /> ### Test results After applying the fix, now the concurrent API requests are passing successfully: ``` [2026-03-23 08:33:38,147] session-create-dc0e746f-master-ssp2h/INFO/locust.main: Shutting down (exit code 0) Type Name # reqs # fails | Avg Min Max Med | req/s failures/s --------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|----------- POST POST /agentic-sessions 886 0(0.00%) | 23 18 60 23 | 4.92 0.00 --------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|----------- Aggregated 886 0(0.00%) | 23 18 60 23 | 4.92 0.00 Response time percentiles (approximated) Type Name 50% 66% 75% 80% 90% 95% 98% 99% 99.9% 99.99% 100% # reqs --------|--------------------------------------------------------------------------------|--------|------|------|------|------|------|------|------|------|------|------|------ POST POST /agentic-sessions 23 24 25 25 27 29 36 47 61 61 61 886 --------|--------------------------------------------------------------------------------|--------|------|------|------|------|------|------|------|------|------|------|------ Aggregated 23 24 25 25 27 29 36 47 61 61 61 886 ``` Signed-off-by: Rahul Shetty <rashetty@redhat.com>
Summary
Replaces all timestamp-based (time.Now().Unix()) resource name generation with UUID-based naming (github.com/google/uuid) to eliminate conflicts under concurrent requests.
Problem
The POST
/api/projects/{PROJECT_NAME}/agentic-sessionsendpoint usedtime.Now().Unix()(1-second precision) to generate session names like session-1711234567. Concurrent requests within the same second produced identical names, causing K8s resource creation conflicts.Reported Bug: #976
Fix
Use uuid.New().String() to guarantee uniqueness regardless of request timing. The same pattern was applied to all other timestamp-based name generators in the backend:
Test results
After applying the fix, now the concurrent API requests are passing successfully: