pkg/utils/etcdutil: reload watcher after compaction#11033
Conversation
Reload from a consistent etcd snapshot when the requested watch revision has been compacted, so changes in the compacted interval are not skipped. Keep the first load callback error and only advance the watch revision after a successful reload. Signed-off-by: Ryan Leung <rleungx@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughLoopWatcher now reloads consistent etcd snapshots after compaction, reconciles deleted keys, and preserves callback errors. Metadata watchers coordinate generation-aware reconciliation with concurrent resource-manager writes. ChangesLoopWatcher consistency
Estimated code review effort: 5 (Critical) | ~100 minutes Sequence Diagram(s)sequenceDiagram
participant MetadataWatcher
participant Manager
participant KeyspaceManager
participant ResourceGroupCache
MetadataWatcher->>Manager: Begin metadata snapshot
MetadataWatcher->>KeyspaceManager: Apply generation-aware metadata updates
Manager->>ResourceGroupCache: Coordinate concurrent API writes
MetadataWatcher->>Manager: Finish snapshot
Manager->>KeyspaceManager: Reconcile entries absent from snapshot
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ 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 |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #11033 +/- ##
==========================================
+ Coverage 79.25% 79.27% +0.02%
==========================================
Files 541 542 +1
Lines 76037 76382 +345
==========================================
+ Hits 60262 60554 +292
- Misses 11534 11566 +32
- Partials 4241 4262 +21
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
/retest |
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pkg/utils/etcdutil/etcdutil.go (1)
378-381: 🩺 Stability & Availability | 🔵 Trivial | ⚖️ Poor tradeoffConsider enforcing the "call before StartWatchLoop" contract at runtime.
SetLoadHooks/SetReconcileDeletedKeysmutatepreLoadFn/postLoadFn/reconcileDeletedKeys/loadedKeyswithout synchronization, relying solely on the doc comment for callers to invoke them beforeStartWatchLoop. If ever called after the watch goroutine starts, this is a data race. Consider guarding with astartedflag (panic/log on misuse) instead of doc-only enforcement.Also applies to: 933-938, 943-946
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/utils/etcdutil/etcdutil.go` around lines 378 - 381, Enforce the pre-StartWatchLoop contract at runtime for SetLoadHooks and SetReconcileDeletedKeys: add a synchronized started state, mark it when StartWatchLoop begins, and reject or clearly report calls made afterward before mutating preLoadFn, postLoadFn, reconcileDeletedKeys, or loadedKeys. Ensure all reads and writes of the started state and these hook-related fields use the same synchronization to prevent races.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@pkg/utils/etcdutil/etcdutil.go`:
- Around line 378-381: Enforce the pre-StartWatchLoop contract at runtime for
SetLoadHooks and SetReconcileDeletedKeys: add a synchronized started state, mark
it when StartWatchLoop begins, and reject or clearly report calls made afterward
before mutating preLoadFn, postLoadFn, reconcileDeletedKeys, or loadedKeys.
Ensure all reads and writes of the started state and these hook-related fields
use the same synchronization to prevent races.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: e0d5e992-01dd-4b9c-b0c4-fb2975f4e375
📒 Files selected for processing (10)
pkg/mcs/resourcemanager/server/keyspace_manager.gopkg/mcs/resourcemanager/server/manager.gopkg/mcs/resourcemanager/server/manager_test.gopkg/mcs/resourcemanager/server/metadata_watcher.gopkg/mcs/resourcemanager/server/metadata_watcher_test.gopkg/mcs/resourcemanager/server/resource_group.gopkg/mcs/resourcemanager/server/service_limit.gopkg/mcs/scheduling/server/rule/watcher_test.gopkg/utils/etcdutil/etcdutil.gopkg/utils/etcdutil/etcdutil_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
- pkg/mcs/scheduling/server/rule/watcher_test.go
Signed-off-by: Ryan Leung <rleungx@gmail.com>
|
@rleungx: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions 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. I understand the commands that are listed here. |
What problem does this PR solve?
Issue Number: Close #11032
When an etcd watch revision has been compacted, LoopWatcher resumes from the
compact revision without reloading current state. Changes in the compacted
interval are not replayed, so consumer caches can remain stale.
Paginated loads can also observe different etcd revisions, and an earlier
callback error can be overwritten by a later successful callback.
What is changed and how does it work?
after a successful load.
consistency, and callback error propagation.
Check List
Tests
Release note
Summary by CodeRabbit