fix: enforce max waiting on control plane also if response is slow#2656
fix: enforce max waiting on control plane also if response is slow#2656
Conversation
WalkthroughModified control plane registration to introduce a timeout-bounded HTTP client. Adjusted imports to include Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
📝 Coding Plan
Comment Tip CodeRabbit can use TruffleHog to scan for secrets in your code with verification capabilities.Add a TruffleHog config file (e.g. trufflehog-config.yml, trufflehog.yml) to your project to customize detectors and scanning behavior. The tool runs only when a config file is present. |
Router-nonroot image scan passed✅ No security vulnerabilities found in image: |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
router/pkg/controlplane/selfregister/self_register.go (1)
65-71: Timeout may limit retry effectiveness when control plane is slow.The 15-second
http.Client.Timeoutapplies to the entire operation including all retries, sinceStandardClient()wraps retry logic in itsRoundTripper. WithRetryMax=3(4 total attempts) andDefaultBackoffwaits (~7s total), only ~8 seconds remain for actual HTTP round-trips.If the control plane is slow (e.g., first request takes 10s before failing), retries may never execute. This is fine if the intent is a hard 15-second cap regardless of retries, but consider:
- Increasing the timeout (e.g., 30-45s) to allow retries when responses are slow, or
- Setting
retryClient.HTTPClient.Timeoutinstead, which applies per-attempt rather than totalIf the current behavior is intentional (hard 15s cap trumps retries), the code is correct as-is.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@router/pkg/controlplane/selfregister/self_register.go` around lines 65 - 71, The 15s httpClient.Timeout set on the client returned by retryClient.StandardClient() caps the entire multi-attempt operation (including retries) and can prevent retries when the control plane is slow; to fix, either increase the timeout (e.g., set httpClient.Timeout = 30*time.Second or 45*time.Second after calling retryClient.StandardClient()) if you want a larger hard cap, or instead set the per-attempt timeout on the retry client itself by configuring retryClient.HTTPClient.Timeout = 30*time.Second before calling retryClient.StandardClient(); update the code around retryClient.StandardClient(), httpClient.Timeout and where c.nodeServiceClient is created to apply the chosen change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@router/pkg/controlplane/selfregister/self_register.go`:
- Around line 65-71: The 15s httpClient.Timeout set on the client returned by
retryClient.StandardClient() caps the entire multi-attempt operation (including
retries) and can prevent retries when the control plane is slow; to fix, either
increase the timeout (e.g., set httpClient.Timeout = 30*time.Second or
45*time.Second after calling retryClient.StandardClient()) if you want a larger
hard cap, or instead set the per-attempt timeout on the retry client itself by
configuring retryClient.HTTPClient.Timeout = 30*time.Second before calling
retryClient.StandardClient(); update the code around
retryClient.StandardClient(), httpClient.Timeout and where c.nodeServiceClient
is created to apply the chosen change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d4981a0b-c497-4125-8c0a-d12688f7a40b
📒 Files selected for processing (1)
router/pkg/controlplane/selfregister/self_register.go
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2656 +/- ##
===========================================
- Coverage 89.54% 62.89% -26.66%
===========================================
Files 20 244 +224
Lines 4360 26134 +21774
Branches 1199 0 -1199
===========================================
+ Hits 3904 16436 +12532
- Misses 456 8357 +7901
- Partials 0 1341 +1341
🚀 New features to boost your workflow:
|
…ntrolplane-is-down
…ntrolplane-is-down
Summary by CodeRabbit
Checklist