Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,14 @@ public List<EventSource<?, P>> prepareEventSources(EventSourceContext<P> context
1); // setting max size for testing purposes

var es =
new InformerEventSource<>(
new InformerEventSource<ConfigMap, P>(
InformerEventSourceConfiguration.from(ConfigMap.class, primaryClass())
.withItemStore(boundedItemStore)
.withSecondaryToPrimaryMapper(
Mappers.fromOwnerReferences(
context.getPrimaryResourceClass(),
this instanceof BoundedCacheClusterScopeTestReconciler))
.build(),
context);
.build());

return List.of(es);
}
Expand Down
2 changes: 1 addition & 1 deletion docs/content/en/docs/documentation/event-filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public List<EventSource<?, MyCustomResource>> prepareEventSources(
.withOnAddFilter(cm -> true)
.build();

return List.of(new InformerEventSource<>(informerConfiguration, context));
return List.of(new InformerEventSource<>(informerConfiguration));
}
```

Expand Down
2 changes: 1 addition & 1 deletion docs/content/en/docs/documentation/eventing.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public class WebPageReconciler implements Reconciler<WebPage> {
InformerEventSourceConfiguration.from(Deployment.class, WebPage.class)
.withLabelSelector(SELECTOR)
.build();
return List.of(new InformerEventSource<>(configuration, context));
return List.of(new InformerEventSource<>(configuration));
}

// omitted code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public class MyReconciler implements Reconciler<TestCustomResource> {
InformerEventSource<ConfigMap, TestCustomResource> configMapES =
new InformerEventSource<>(InformerEventSourceConfiguration.from(ConfigMap.class, TestCustomResource.class)
.withNamespacesInheritedFromController(context)
.build(), context);
.build());
Comment on lines 84 to +87

return EventSourceUtils.nameEventSources(configMapES);
}
Expand Down
7 changes: 3 additions & 4 deletions docs/content/en/docs/documentation/working-with-es-caches.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ public class WebPageReconciler implements Reconciler<WebPage> {
configMapEventSource = new InformerEventSource<>(
InformerEventSourceConfiguration.from(ConfigMap.class, WebPage.class)
.withLabelSelector(SELECTOR)
.build(),
context);
.build());

return List.of(configMapEventSource);
}
Expand Down Expand Up @@ -200,7 +199,7 @@ With this index in place, you can retrieve the target resources very efficiently
```java

InformerEventSource<Job,Cluster> clusterInformer =
new InformerEventSource(
new InformerEventSource<>(
InformerEventSourceConfiguration.from(Cluster.class, Job.class)
.withSecondaryToPrimaryMapper(
Comment on lines 201 to 204
cluster ->
Expand All @@ -214,7 +213,7 @@ With this index in place, you can retrieve the target resources very efficiently
.stream()
.map(ResourceID::fromResource)
.collect(Collectors.toSet()))
.withNamespacesInheritedFromController().build(), context);
.withNamespacesInheritedFromController().build());
```

## Read-cache-after-write consistency and event filtering
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import io.javaoperatorsdk.operator.api.monitoring.Metrics;
import io.javaoperatorsdk.operator.api.reconciler.Experimental;
import io.javaoperatorsdk.operator.api.reconciler.dependent.DependentResourceFactory;
import io.javaoperatorsdk.operator.processing.event.source.informer.pool.AbstractInformerPool;
import io.javaoperatorsdk.operator.processing.event.source.informer.pool.InformerPool;

@SuppressWarnings({"unused", "UnusedReturnValue"})
Expand Down Expand Up @@ -184,13 +183,13 @@ public ConfigurationServiceOverrider withCloneSecondaryResourcesWhenGettingFromC
* Overrides the informer pool strategy used to create/share the informers backing the event
* sources. When not set, the default (informer-sharing) pool is used.
*
* <p>Custom strategies extend {@link AbstractInformerPool}, which already takes care of creating
* and starting the informers.
* <p>Custom strategies implement {@link InformerPool}, which already takes care of creating and
* starting the informers.
*/
@Experimental(
"Only the configuration API around informer pooling could still change in a"
+ " non-backwards-compatible way, the pooling itself is prod ready.")
public ConfigurationServiceOverrider withInformerPool(AbstractInformerPool informerPool) {
public ConfigurationServiceOverrider withInformerPool(InformerPool informerPool) {
this.informerPool = informerPool;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ default boolean followControllerNamespaceChanges() {

<P extends HasMetadata> PrimaryToSecondaryMapper<P> getPrimaryToSecondaryMapper();

// todo deprecate
/**
* @deprecated use {@link InformerConfiguration#getResourceGroupVersionKind()}
*/
@Deprecated(forRemoval = true)
Optional<GroupVersionKind> getGroupVersionKind();

default String name() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ protected InformerEventSource<R, P> createEventSource(EventSourceContext<P> cont
configBuilder.updateFrom(kubernetesDependentResourceConfig.informerConfig());
}

var es = new InformerEventSource<>(configBuilder.build(), context);
var es = new InformerEventSource<R, P>(configBuilder.build());
setEventSource(es);
return eventSource().orElseThrow();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ public class InformerEventSource<R extends HasMetadata, P extends HasMetadata>
private final PrimaryToSecondaryMapper<P> primaryToSecondaryMapper;

/**
* @deprecated use {@link InformerEventSource(InformerEventSourceConfiguration)}
* @deprecated use {@link #InformerEventSource(InformerEventSourceConfiguration)}
*/
// todo migrate sample, separate PR?
@Deprecated(forRemoval = true)
public InformerEventSource(
InformerEventSourceConfiguration<R> configuration, EventSourceContext<P> context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ public List<EventSource<?, ChangeNamespaceTestCustomResource>> prepareEventSourc
new InformerEventSource<>(
InformerEventSourceConfiguration.from(
ConfigMap.class, ChangeNamespaceTestCustomResource.class)
.build(),
context);
.build());

return List.of(configMapES);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,13 @@ private ConfigMap desired(ClusterScopedCustomResource resource) {
public List<EventSource<?, ClusterScopedCustomResource>> prepareEventSources(
EventSourceContext<ClusterScopedCustomResource> context) {
var ies =
new InformerEventSource<>(
new InformerEventSource<ConfigMap, ClusterScopedCustomResource>(
InformerEventSourceConfiguration.from(
ConfigMap.class, ClusterScopedCustomResource.class)
.withSecondaryToPrimaryMapper(
Mappers.fromOwnerReferences(context.getPrimaryResourceClass(), true))
.withLabelSelector(TEST_LABEL_KEY + "=" + TEST_LABEL_VALUE)
.build(),
context);
.build());
return List.of(ies);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ public List<EventSource<?, CreateUpdateEventFilterTestCustomResource>> prepareEv
.withComparableResourceVersion(comparableResourceVersion)
.build();

final var informerEventSource = new InformerEventSource<>(informerConfiguration, context);
final var informerEventSource =
new InformerEventSource<ConfigMap, CreateUpdateEventFilterTestCustomResource>(
informerConfiguration);
this.configMapDR.setEventSource(informerEventSource);

return List.of(informerEventSource);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ public UpdateControl<DynamicGenericEventSourceRegistrationCustomResource> reconc

context
.eventSourceRetriever()
.dynamicallyRegisterEventSource(genericInformerFor(ConfigMap.class, context));
context
.eventSourceRetriever()
.dynamicallyRegisterEventSource(genericInformerFor(Secret.class, context));
.dynamicallyRegisterEventSource(genericInformerFor(ConfigMap.class));
context.eventSourceRetriever().dynamicallyRegisterEventSource(genericInformerFor(Secret.class));

context.getClient().resource(secret(primary)).createOr(NonDeletingOperation::update);
context.getClient().resource(configMap(primary)).createOr(NonDeletingOperation::update);
Expand Down Expand Up @@ -89,17 +87,14 @@ private ConfigMap configMap(DynamicGenericEventSourceRegistrationCustomResource

private InformerEventSource<
GenericKubernetesResource, DynamicGenericEventSourceRegistrationCustomResource>
genericInformerFor(
Class<? extends HasMetadata> clazz,
Context<DynamicGenericEventSourceRegistrationCustomResource> context) {
genericInformerFor(Class<? extends HasMetadata> clazz) {

return new InformerEventSource<>(
InformerEventSourceConfiguration.from(
GroupVersionKind.gvkFor(clazz),
DynamicGenericEventSourceRegistrationCustomResource.class)
.withName(clazz.getSimpleName())
.build(),
context.eventSourceRetriever().eventSourceContextForDynamicRegistration());
.build());
}

public int getNumberOfExecutions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ public List<EventSource<?, ExpectationCustomResource>> prepareEventSources(
return List.of(
new InformerEventSource<>(
InformerEventSourceConfiguration.from(Deployment.class, ExpectationCustomResource.class)
.build(),
context));
.build()));
}

private static void createDeployment(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ public List<EventSource<?, PeriodicCleanerExpectationCustomResource>> prepareEve
new InformerEventSource<>(
InformerEventSourceConfiguration.from(
Deployment.class, PeriodicCleanerExpectationCustomResource.class)
.build(),
context));
.build()));
}

private static void createDeployment(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ public List<EventSource<?, Secret>> prepareEventSources(EventSourceContext<Secre
.withNamespacesInheritedFromController()
.withFieldSelector(
new FieldSelectorBuilder().withField("type", OTHER_SECRET_TYPE).build())
.build(),
context);
.build());

return List.of(dependentSecretEventSource);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public List<EventSource<?, FilterTestCustomResource>> prepareEventSources(
!newCM.getData().get(CM_VALUE_KEY).equals(CONFIG_MAP_FILTER_VALUE))
.build();
InformerEventSource<ConfigMap, FilterTestCustomResource> configMapES =
new InformerEventSource<>(informerConfiguration, context);
new InformerEventSource<>(informerConfiguration);

return List.of(configMapES);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ public List<EventSource<?, GenericKubernetesResourceHandlingCustomResource>> pre
EventSourceContext<GenericKubernetesResourceHandlingCustomResource> context) {

var informerEventSource =
new InformerEventSource<>(
new InformerEventSource<
GenericKubernetesResource, GenericKubernetesResourceHandlingCustomResource>(
InformerEventSourceConfiguration.from(
new GroupVersionKind("", VERSION, KIND),
GenericKubernetesResourceHandlingCustomResource.class)
.build(),
context);
.build());

return List.of(informerEventSource);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public List<EventSource<?, InformerEventSourceTestCustomResource>> prepareEventS
InformerEventSourceTestCustomResource.class))
.build();

return List.of(new InformerEventSource<>(config, context));
return List.of(new InformerEventSource<>(config));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public List<EventSource<?, SharedInformerCustomResource1>> prepareEventSources(
var config =
InformerEventSourceConfiguration.from(ConfigMap.class, SharedInformerCustomResource1.class)
.build();
return List.of(new InformerEventSource<>(config, context));
return List.of(new InformerEventSource<>(config));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public List<EventSource<?, SharedInformerCustomResource2>> prepareEventSources(
var config =
InformerEventSourceConfiguration.from(ConfigMap.class, SharedInformerCustomResource2.class)
.build();
return List.of(new InformerEventSource<>(config, context));
return List.of(new InformerEventSource<>(config));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public UpdateControl<DeregisterPrimaryCustomResource> reconcile(
numberOfExecutions.incrementAndGet();

if (primary.getSpec() != null && primary.getSpec().isRegisterEventSource()) {
context.eventSourceRetriever().dynamicallyRegisterEventSource(watchedEventSource(context));
context.eventSourceRetriever().dynamicallyRegisterEventSource(watchedEventSource());
} else {
context.eventSourceRetriever().dynamicallyDeRegisterEventSource(WATCHED_EVENT_SOURCE_NAME);
}
Expand All @@ -54,7 +54,7 @@ public UpdateControl<DeregisterPrimaryCustomResource> reconcile(
}

private InformerEventSource<DeregisterWatchedCustomResource, DeregisterPrimaryCustomResource>
watchedEventSource(Context<DeregisterPrimaryCustomResource> context) {
watchedEventSource() {
var config =
InformerEventSourceConfiguration.from(
DeregisterWatchedCustomResource.class, DeregisterPrimaryCustomResource.class)
Expand All @@ -63,8 +63,7 @@ public UpdateControl<DeregisterPrimaryCustomResource> reconcile(
(DeregisterWatchedCustomResource watched) ->
Set.of(new ResourceID("ignored", watched.getMetadata().getNamespace())))
.build();
return new InformerEventSource<>(
config, context.eventSourceRetriever().eventSourceContextForDynamicRegistration());
return new InformerEventSource<>(config);
}

public int getNumberOfExecutions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,13 @@ public UpdateControl<DynamicSharedInformerPrimaryCustomResource2> reconcile(
DynamicSharedInformerPrimaryCustomResource2 resource,
Context<DynamicSharedInformerPrimaryCustomResource2> context) {
numberOfExecutions.incrementAndGet();
context
.eventSourceRetriever()
.dynamicallyRegisterEventSource(thirdResourceEventSource(context));
context.eventSourceRetriever().dynamicallyRegisterEventSource(thirdResourceEventSource());
return UpdateControl.noUpdate();
}

private InformerEventSource<
DynamicSharedInformerThirdCustomResource, DynamicSharedInformerPrimaryCustomResource2>
thirdResourceEventSource(Context<DynamicSharedInformerPrimaryCustomResource2> context) {
thirdResourceEventSource() {
var config =
InformerEventSourceConfiguration.from(
DynamicSharedInformerThirdCustomResource.class,
Expand All @@ -71,8 +69,7 @@ public UpdateControl<DynamicSharedInformerPrimaryCustomResource2> reconcile(
(DynamicSharedInformerThirdCustomResource third) ->
Set.of(new ResourceID(PRIMARY_NAME, third.getMetadata().getNamespace())))
.build();
return new InformerEventSource<>(
config, context.eventSourceRetriever().eventSourceContextForDynamicRegistration());
return new InformerEventSource<>(config);
}

public int getNumberOfExecutions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public List<EventSource<?, DynamicSharedInformerPrimaryCustomResource1>> prepare
(DynamicSharedInformerThirdCustomResource third) ->
Set.of(new ResourceID(PRIMARY_NAME, third.getMetadata().getNamespace())))
.build();
return List.of(new InformerEventSource<>(config, context));
return List.of(new InformerEventSource<>(config));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public List<EventSource<?, InformerRemoteClusterCustomResource>> prepareEventSou
EventSourceContext<InformerRemoteClusterCustomResource> context) {

var es =
new InformerEventSource<>(
new InformerEventSource<ConfigMap, InformerRemoteClusterCustomResource>(
InformerEventSourceConfiguration.from(
ConfigMap.class, InformerRemoteClusterCustomResource.class)
// owner references do not work cross cluster, using
Expand All @@ -80,8 +80,7 @@ public List<EventSource<?, InformerRemoteClusterCustomResource>> prepareEventSou
// setting remote client for informer
.withKubernetesClient(remoteClient)
.withWatchAllNamespaces()
.build(),
context);
.build());

return List.of(es);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@ public List<EventSource<?, LatestDistinctTestResource>> prepareEventSources(
cm.getMetadata().getNamespace())))
.build();

return List.of(
new InformerEventSource<>(configEs1, context),
new InformerEventSource<>(configEs2, context));
return List.of(new InformerEventSource<>(configEs1), new InformerEventSource<>(configEs2));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public List<EventSource<?, MultipleSecondaryEventSourceCustomResource>> prepareE
})
.build();
InformerEventSource<ConfigMap, MultipleSecondaryEventSourceCustomResource>
configMapEventSource = new InformerEventSource<>(config, context);
configMapEventSource = new InformerEventSource<>(config);
return List.of(configMapEventSource);
}

Expand Down
Loading
Loading