Skip to content

fix: skip stale ghost resources in temporary cache merge for list, byIndex and keys - #3704

Merged
csviri merged 4 commits into
operator-framework:nextfrom
csviri:fix/temp-cache-merge-excludes-stale-ghosts
Nov 19, 2026
Merged

csviri merged 4 commits into
operator-framework:nextfrom
csviri:fix/temp-cache-merge-excludes-stale-ghosts

Conversation

@csviri

@csviri csviri commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

Problem

ManagedInformerEventSource.get() only prefers a temporary cache entry if it is later than the informer's last sync resource version. list, byIndex and keys add 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:

  • a resource already deleted in the informer is returned again;
  • an older copy that still matches an index key is returned although the informer holds a newer version that no longer matches.

Change

Ghost entries in list, byIndex and keys are only included if they are later than the last sync resource version, same as in get().

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.

…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>
Copilot AI balanced review requested due to automatic review settings November 18, 2026 13:01
@openshift-ci
openshift-ci Bot requested review from metacosm and xstefank November 18, 2026 13:01
@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d88b9705-a164-4017-b00a-fd618e5f7d95

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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, and keys against 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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The namespace-specific list path can omit newly created resources if the informer catches up between cache snapshot creation and the superseded-ID check.

1 open issue
1 resolved since last review

Review effort: Balanced

…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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

@csviri
csviri merged commit ec1fc05 into operator-framework:next Nov 19, 2026
29 checks passed
csviri added a commit that referenced this pull request Nov 19, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants