fix: concurrency issue with filtering and caching update#3191
fix: concurrency issue with filtering and caching update#3191csviri wants to merge 10 commits intooperator-framework:nextfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates InformerEventSourceTest to better validate behavior when a secondary resource is updated via event-filtering + caching, specifically ensuring the secondary can be retrieved immediately afterward (via getSecondaryResources) and that the primary-to-secondary index is updated accordingly.
Changes:
- Reuses a dedicated
SecondaryToPrimaryMappermock instance in the test class setup. - Overrides
get(ResourceID)in the testInformerEventSourceto read directly fromTemporaryResourceCache. - Adds a new test asserting that
eventFilteringUpdateAndCacheResourceupdates the primary-to-secondary index such thatgetSecondaryResources(primary)returns results.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| when(informerEventSourceConfiguration.getSecondaryToPrimaryMapper()) | ||
| .thenReturn(mock(SecondaryToPrimaryMapper.class)); | ||
| .thenReturn(mockSecondaryToPrimaryMapper); | ||
| when(informerEventSourceConfiguration.getResourceClass()).thenReturn(Deployment.class); | ||
|
|
||
| informerEventSource = |
There was a problem hiding this comment.
In setup(), getSecondaryToPrimaryMapper() is stubbed to return mockSecondaryToPrimaryMapper, but later in the same method it’s stubbed again to return a different secondaryToPrimaryMapper mock. This makes the test fixture inconsistent (the PrimaryToSecondaryIndex is constructed with the first mock, while propagateEvent() uses the later stubbed one) and can mask bugs. Prefer using a single mapper mock consistently (remove the later re-stubbing/local mock or remove the field).
...va/io/javaoperatorsdk/operator/processing/event/source/informer/InformerEventSourceTest.java
Outdated
Show resolved
Hide resolved
…hing update Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
eb61286 to
3db1ccb
Compare
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 9 changed files in this pull request and generated 6 comments.
Comments suppressed due to low confidence (1)
operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/source/informer/InformerEventSourceTest.java:28
ObjectMetaBuilderis imported but not used anywhere in this test. Since the build uses Spotless withremoveUnusedImports, this should be removed (or the intended usage added) to avoid formatting/CI issues.
import io.fabric8.kubernetes.api.model.ObjectMeta;
import io.fabric8.kubernetes.api.model.apps.Deployment;
import io.fabric8.kubernetes.api.model.apps.DeploymentBuilder;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...io/javaoperatorsdk/operator/processing/event/source/informer/ManagedInformerEventSource.java
Outdated
Show resolved
Hide resolved
...java/io/javaoperatorsdk/operator/processing/dependent/workflow/AbstractWorkflowExecutor.java
Show resolved
Hide resolved
...va/io/javaoperatorsdk/operator/processing/event/source/informer/InformerEventSourceTest.java
Outdated
Show resolved
Hide resolved
...ava/io/javaoperatorsdk/operator/baseapi/cachingfilteringupdate/CachingFilteringUpdateIT.java
Outdated
Show resolved
Hide resolved
...ava/io/javaoperatorsdk/operator/baseapi/cachingfilteringupdate/CachingFilteringUpdateIT.java
Outdated
Show resolved
Hide resolved
...ava/io/javaoperatorsdk/operator/baseapi/cachingfilteringupdate/CachingFilteringUpdateIT.java
Outdated
Show resolved
Hide resolved
…tor/processing/event/source/informer/ManagedInformerEventSource.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Fixes a race condition with the event filtering and caching issue, described in a comment. Added also a dedicated e2e test for this case.
Also increased the timeout for the MySQL e2e test, which seems to be flaky as well.
Improved logging for workflow execution, so that it is more readable in the logs what is happening.
Signed-off-by: Attila Mészáros a_meszaros@apple.com