Skip to content

improve: use the default list methods with read-cache-after-write consistency#3336

Open
csviri wants to merge 5 commits intooperator-framework:nextfrom
csviri:list-improve
Open

improve: use the default list methods with read-cache-after-write consistency#3336
csviri wants to merge 5 commits intooperator-framework:nextfrom
csviri:list-improve

Conversation

@csviri
Copy link
Copy Markdown
Collaborator

@csviri csviri commented May 7, 2026

Remove the index and list related methods "strong consistency variant".

The rational behind this change is that the user either uses read-cache-after-write consistency feature,
than the "strong read" should be used. If on the other hand tha feature,
is not used, the current implementation does not impose any overhead.

In addition to that strong consistency is not a good name, we call this feature
as read-cache-after-write consistency, that might be too long though.

Adds ghost resource handling for keys().

Add also missing javadocs.

Signed-off-by: Attila Mészáros a_meszaros@apple.com

Copilot AI review requested due to automatic review settings May 7, 2026 11:59
@openshift-ci openshift-ci Bot requested review from metacosm and xstefank May 7, 2026 11:59
@csviri csviri requested review from metacosm, shawkins and xstefank and removed request for metacosm and xstefank May 7, 2026 11:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes the “strong consistency” list/index variants by folding read-cache-after-write consistency behavior into the default list(...) / byIndexStream(...) methods on ManagedInformerEventSource, and updates tests to use the new API surface.

Changes:

  • Replaced listWithStrongConsistency(...) with list(...) implementations that merge informer results with the temporary cache for read-cache-after-write consistency.
  • Replaced byIndexStreamWithStrongConsistency(...) with byIndexStream(...) and updated byIndex(...) to return merged results.
  • Updated informer event source tests to call the renamed/default methods.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/informer/ManagedInformerEventSource.java Removes “strong consistency” variants, makes default list/index methods merge with the temp cache, and adjusts index lookup behavior.
operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/source/informer/InformerEventSourceTest.java Updates tests to use list(...) / byIndexStream(...) instead of the removed “strong consistency” methods.

public List<R> byIndex(String indexName, String indexKey) {
return mergeWithWithTempCacheResources(
manager().byIndexStream(indexName, indexKey), indexName, indexKey)
.toList();
Comment on lines +242 to 245
public Stream<R> list(String namespace, Predicate<R> predicate) {
return mergeWithWithTempCacheResources(
manager().list(namespace, predicate), namespace, predicate);
}
* Like {@link #list(Predicate)} but for read-cache-after-write consistency. This is useful when
* resources are updated using {@link
* io.javaoperatorsdk.operator.api.reconciler.ResourceOperations}.
*/
Comment on lines +261 to 264
public Stream<R> byIndexStream(String indexName, String indexKey) {
return mergeWithWithTempCacheResources(
manager().byIndexStream(indexName, indexKey), indexName, indexKey);
}
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

Comment on lines +278 to +282
@Override
public List<R> byIndex(String indexName, String indexKey) {
return mergeWithWithTempCacheResources(
manager().byIndexStream(indexName, indexKey), indexName, indexKey);
manager().byIndexStream(indexName, indexKey), indexName, indexKey)
.toList();
Comment on lines +238 to +242
* {@inheritDoc}
*
* <p>This implementation is read-cache-after-write consistent. Results are merged with the
* temporary resource cache to ensure recently written resources are reflected in the output.
*/
csviri and others added 5 commits May 7, 2026 15:03
…sistency

Remove the index and list related methods "strong consistency variant".

The rational behind this change is that the user either uses read-cache-after-write consistency feature,
than the "strong read" should be used. If on the other hand tha feature,
is not used, the current implementation does not impose any overhead.

In addition to that strong consistency is not a good name, we call this feature
as read-cache-after-write consistency, that might be too long though.

Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

return manager().keys();
}
var tempKeys = temporaryResourceCache.getResources().keySet();
return Stream.concat(manager().keys(), tempKeys.stream().filter(k -> !manager().contains(k)));
Comment on lines +237 to +246
/**
* {@inheritDoc}
*
* <p>This implementation is read-cache-after-write consistent. Results are merged with the
* temporary resource cache to ensure recently written resources are reflected in the output.
*/
@Override
public Stream<R> list(String namespace, Predicate<R> predicate) {
return manager().list(namespace, predicate);
return mergeWithWithTempCacheResources(
manager().list(namespace, predicate), namespace, predicate);
Comment on lines 260 to 270
/**
* Like {@link #list(String, Predicate)} but for read-cache-after-write consistency. This is
* useful when resources are updated using {@link
* io.javaoperatorsdk.operator.api.reconciler.ResourceOperations}.
* {@inheritDoc}
*
* <p>This implementation is read-cache-after-write consistent. Results are merged with the
* temporary resource cache to ensure recently written resources are reflected in the output.
*/
public Stream<R> listWithStrongConsistency(String namespace, Predicate<R> predicate) {
@Override
public Stream<R> byIndexStream(String indexName, String indexKey) {
return mergeWithWithTempCacheResources(
manager().list(namespace, predicate), namespace, predicate);
}

/**
* Like {@link #list(Predicate)} but for read-cache-after-write consistency. This is useful when
* resources are updated using {@link
* io.javaoperatorsdk.operator.api.reconciler.ResourceOperations}.
*/
public Stream<R> listWithStrongConsistency(Predicate<R> predicate) {
return mergeWithWithTempCacheResources(cache.list(predicate), null, predicate);
manager().byIndexStream(indexName, indexKey), indexName, indexKey);
}
Comment on lines +245 to 247
return mergeWithWithTempCacheResources(
manager().list(namespace, predicate), namespace, predicate);
}
Copy link
Copy Markdown
Collaborator

@xstefank xstefank left a comment

Choose a reason for hiding this comment

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

Do we have a policy that public methods should be first deprecated before they are removed?

@csviri
Copy link
Copy Markdown
Collaborator Author

csviri commented May 7, 2026

Do we have a policy that public methods should be first deprecated before they are removed?

This is against next branch and code that is not released yet. Otherwise we deprecate methods, and remove them in the next major version.

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.

3 participants