Description
Source code from Flink operator. Such cases if the controller ES is not initialized first it will mean that the informer's SecondaryToPrimaryMapper won't find resource in the primary index. This is quite natural setup, so makes sense to in general to init ControllerResourceEventSource as first, so the index is filled when other event source are started, so their index is filled also correctly.
public static InformerEventSource<FlinkDeployment, FlinkSessionJob>
getFlinkDeploymentInformerEventSource(EventSourceContext<FlinkSessionJob> context) {
context.getPrimaryCache()
.addIndexer(
FLINK_SESSIONJOB_IDX,
sessionJob -> List.of(sessionJob.getSpec().getDeploymentName()));
InformerConfiguration<FlinkDeployment> configuration =
InformerConfiguration.from(FlinkDeployment.class, context)
.withSecondaryToPrimaryMapper(
flinkDeployment ->
context.getPrimaryCache()
.byIndex(
FLINK_SESSIONJOB_IDX,
flinkDeployment.getMetadata().getName())
.stream()
.map(ResourceID::fromResource)
.collect(Collectors.toSet()))
.withNamespacesInheritedFromController(context)
.followNamespaceChanges(true)
.build();
InformerEventSource<FlinkDeployment, FlinkSessionJob>
flinkDeploymentFlinkSessionJobInformerEventSource =
new InformerEventSource<>(configuration, context);
return flinkDeploymentFlinkSessionJobInformerEventSource;
}