client: add backoff mechanism for service URL updates#10540
client: add backoff mechanism for service URL updates#10540ti-chi-bot[bot] merged 4 commits intotikv:masterfrom
Conversation
Signed-off-by: bufferflies <1045931706@qq.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds a time-based backoff to updateServiceURLLoop: track last update time, delay discoverAndUpdate() when updates arrive sooner than the retry interval, and allow early exit if the context is canceled. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
|
Re-reviewed the change on top of commit I do not have a new code finding on this delta. The backoff is confined to the error-triggered refresh path, and the wait stays context-aware so shutdown can still break out promptly. Residual risk: I do not see a targeted regression test for the new backoff behavior itself in this PR, so the current validation still relies on the existing RM discovery test surface plus |
Signed-off-by: bufferflies <1045931706@qq.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@client/servicediscovery/resource_manager_service_discovery.go`:
- Line 265: The log reads r.serviceURL without holding r.mu, causing a data
race; fix by reading the protected value while holding the mutex (e.g., use
r.mu.RLock()/RUnlock() around the read) or call the existing GetServiceURL() to
obtain the URL safely, then pass that safe value into log.Info (references:
r.serviceURL, r.mu, GetServiceURL(), resetConn()).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 4ba4e40f-ef93-49e9-a208-3417e5ed7d4a
📒 Files selected for processing (1)
client/servicediscovery/resource_manager_service_discovery.go
Signed-off-by: bufferflies <1045931706@qq.com>
|
Re-reviewed the latest follow-up on top of commit The previous test finding is now addressed:
I do not have a new finding on this follow-up delta. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #10540 +/- ##
==========================================
+ Coverage 78.88% 78.96% +0.07%
==========================================
Files 530 532 +2
Lines 71548 71818 +270
==========================================
+ Hits 56439 56709 +270
+ Misses 11092 11078 -14
- Partials 4017 4031 +14
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
♻️ Duplicate comments (1)
client/servicediscovery/resource_manager_service_discovery.go (1)
266-266:⚠️ Potential issue | 🔴 CriticalRead
serviceURLunder lock (or via accessor) in this log path.This line reads
r.serviceURLdirectly and can race withresetConn()writes. User.GetServiceURL()(orRLock) before logging.Suggested fix
- log.Info("[resource-manager] updating service URL", zap.String("old-url", r.serviceURL)) + log.Info("[resource-manager] updating service URL", zap.String("old-url", r.GetServiceURL()))As per coding guidelines: Guard shared state with mutex/RWMutex; keep lock ordering consistent.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@client/servicediscovery/resource_manager_service_discovery.go` at line 266, The log reads r.serviceURL without holding the lock, which can race with resetConn() writes—wrap the read in the same synchronization used elsewhere: either call r.GetServiceURL() (the safe accessor) or acquire r.RLock()/RUnlock() around the read before calling log.Info; ensure you use the same lock ordering as other methods (e.g., methods that call resetConn()) to avoid deadlocks.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@client/servicediscovery/resource_manager_service_discovery.go`:
- Line 266: The log reads r.serviceURL without holding the lock, which can race
with resetConn() writes—wrap the read in the same synchronization used
elsewhere: either call r.GetServiceURL() (the safe accessor) or acquire
r.RLock()/RUnlock() around the read before calling log.Info; ensure you use the
same lock ordering as other methods (e.g., methods that call resetConn()) to
avoid deadlocks.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 4e2e33ec-de2f-4ab8-bea1-79b978b7aca7
📒 Files selected for processing (2)
client/servicediscovery/resource_manager_service_discovery.goclient/servicediscovery/resource_manager_service_discovery_test.go
Signed-off-by: bufferflies <1045931706@qq.com>
|
Re-reviewed the latest follow-up on top of commit The accepted I do not have a new finding on this follow-up delta. |
|
/retest |
|
/retest |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: disksing, lhy1024, okJiang The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/retest by AI |
|
@bufferflies: The The following commands are available to trigger optional jobs: Use DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/retest |
Summary
Issue Number
Issue Number: ref #10516, close #10539
Validation
cd client && go test . -run 'Test.*ResourceManager.*' -count=1\n-cd client && go test . -run 'TestTryResourceManagerConnectUsesRMForTokenAndFallbackToPD' -count=1\n-make check\n\n## Release Note\nrelease-note\nNone\nSummary by CodeRabbit
Bug Fixes
Tests