Skip to content

If ControllerResourceEventCource not initialized firtst can cause issues with indexing and secondary to primary mapping #1238

@csviri

Description

@csviri

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;
    }
    

Metadata

Metadata

Assignees

Labels

kind/bugCategorizes issue or PR as related to a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions