Repository navigation
fix: skip stale ghost resources in temporary cache merge for list, byIndex and keys - #3704
Conversation
…Index and keys Resources only present in the temporary cache were always added to list, byIndex and keys results. When the informer had already processed a newer state (e.g. a delete, or a version no longer matching the index) but its event handler had not yet cleared the temporary cache, a stale copy was returned. Apply the same last sync resource version check as get(). Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
There was a problem hiding this comment.
🟡 Changes recommended
A critical race between snapshot creation and lazy filtering can omit recently created resources, breaking read-cache-after-write consistency across listing, index filtering, and key enumeration.
1 open issue
What changed in this PR
This PR updates informer cache merging to exclude stale temporary “ghost” resources from collection queries, aligning their version checks with get().
Changes:
- Filter ghost entries in
list,byIndex, andkeysagainst the informer’s last synced resource version. - Add tests for stale ghosts and resources not yet observed by the informer, and update existing test stubs.
| File | Description |
|---|---|
| operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/source/informer/InformerEventSourceTest.java | Tests ghost filtering and updates sync-version stubs. |
| operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/informer/ManagedInformerEventSource.java | Adds version checks when merging temporary ghost resources. |
Review effort: Balanced
Reading the last sync resource version lazily, after the informer state was captured, could drop a recently written resource from both when the informer caught up in between. Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
…ources in list The namespace-scoped list materialized the informer snapshot before the superseded check, so a resource the informer caught up with in between was missing from both. Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
…merge Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified in the temporary-cache merging changes intended to prevent stale ghost resources from appearing in informer results.
No open issues 🎉
1 resolved since last review
Review effort: Balanced
…Index and keys (#3704) Resources only present in the temporary cache were always added to list, byIndex and keys results. When the informer had already processed a newer state (e.g. a delete, or a version no longer matching the index) but its event handler had not yet cleared the temporary cache, a stale copy was returned. Apply the same last sync resource version check as get(). Signed-off-by: Attila Mészáros <a_meszaros@apple.com>

Problem
ManagedInformerEventSource.get()only prefers a temporary cache entry if it is later than the informer's last sync resource version.list,byIndexandkeysadd every temporary cache entry that is missing from the informer result as a "ghost" without that check. The informer updates its store before its event handler removes the temporary cache entry, so in that window:Change
Ghost entries in
list,byIndexandkeysare only included if they are later than the last sync resource version, same as inget().Tests
Unit tests for list, byIndex and keys with a ghost already covered by the informer and a ghost not yet seen by it. Existing ghost tests now stub the last sync resource version.