Repository navigation
Conversation
Add withIndexer and withIndexers to InformerEventSourceConfiguration.Builder, expose them through getIndexers, and register them when the InformerEventSource is created. InformerEventSource.addIndexers is deprecated in favor of the builder; ControllerEventSource keeps using it. Closes operator-framework#3731 Signed-off-by: Exar-lab <exarviquezmasis@gmail.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.
🟢 Approval recommended
The change moving informer indexer configuration into the builder has no active review issues.
No open issues 🎉
What changed in this PR
Addresses #3731 by moving InformerEventSource indexer configuration into its builder, alongside other event-source settings.
Changes:
- Adds single and bulk indexer registration methods, exposing an unmodifiable map from built configurations.
- Registers configured indexers during event-source construction and deprecates direct
InformerEventSource.addIndexerscalls. - Adds unit coverage, migrates the read-own-updates reconciler, and documents builder usage.
| File | Description |
|---|---|
operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/readcacheafterwrite/readownupdates/ReadOwnUpdatesReconciler.java |
Configures the resource-version index through the builder. |
operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/source/informer/InformerEventSourceTest.java |
Tests registration of configured indexers during construction. |
operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/config/InformerEventSourceConfigurationTest.java |
Tests default, collected, and unmodifiable indexer maps. |
operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/informer/InformerEventSource.java |
Registers configured indexers and deprecates direct registration. |
operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/informer/InformerEventSourceConfiguration.java |
Adds builder methods and configuration access for indexers. |
docs/content/en/docs/documentation/working-with-es-caches.md |
Documents secondary-resource indexing through the builder. |
Review effort: Balanced
| * @deprecated configure indexers with {@link | ||
| * InformerEventSourceConfiguration.Builder#withIndexer(String, Function)} instead | ||
| */ | ||
| @Deprecated |
There was a problem hiding this comment.
Sorry I have just realized that we might actually have a valid use case for this. It is more of an edge-case but a valid one. If someone dynamically registers an informer and want to add dynamically also an indexer for this purpose this is actually valid.
But at this point we should just simply remove the deprecation, and document that the purpose here is to dynamically add indexer, otherwise user should use the one from the builder.
Closes #3731
Indexers of an
InformerEventSourcecan now be configured on theInformerEventSourceConfigurationbuilder, like the rest of its properties.InformerEventSourceConfiguration.BuildergetswithIndexer(String, Function)andwithIndexers(Map).InformerEventSourceConfiguration#getIndexers()exposes them (default: empty, so existing implementations keep compiling). The built map is unmodifiable.InformerEventSourceregisters them when it is created, so they are in place before it starts.InformerEventSource#addIndexersis overridden and deprecated. As agreed in the issue,ManagedInformerEventSource,IndexerResourceCacheandControllerEventSourceare untouched, since the latter still needs it.ReadOwnUpdatesReconcileruses the builder, andworking-with-es-caches.mddocuments it.Tests: new unit tests for the builder and for an event source created with configured indexers.
InformerEventSourceConfigurationTest,InformerEventSourceTestandInformerWrapperTestpass, andspotless:checkandlicense:checkare clean. I did not run the integration tests, so theReadOwnUpdatesReconcilerchange is only checked by compilation.