Skip to content

improve: extend SecondaryToPrimaryMapper so it also gets the old resource#3388

Draft
csviri wants to merge 2 commits into
operator-framework:nextfrom
csviri:secondary-to-primary-improve
Draft

improve: extend SecondaryToPrimaryMapper so it also gets the old resource#3388
csviri wants to merge 2 commits into
operator-framework:nextfrom
csviri:secondary-to-primary-improve

Conversation

@csviri

@csviri csviri commented May 28, 2026

Copy link
Copy Markdown
Collaborator

This might needed in some corner cases where might help with optimizations to which resource to trigger.

TBD: add more details here

Signed-off-by: Attila Mészáros a_meszaros@apple.com

…urce

This might needed in some corner cases where might help with optimizations to which resource to trigger.

Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 28, 2026
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
@csviri

csviri commented May 28, 2026

Copy link
Copy Markdown
Collaborator Author

@csviri

csviri commented May 28, 2026

Copy link
Copy Markdown
Collaborator Author

as discussed with @dvob , he will created a detailed issue for this.

@dvob

dvob commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

@csviri thank you for implementing this so quickly. I also created issue #3401 for reference which we can more or less close right away if this is merged.

I updated my reproducer to use two different types (MyThing and MyThingConfig), in the hope that it is more understandable. I also updated it to use this PR and it did work (test does no longer fail) https://github.com/dvob/java-operator-sdk-repo-example/tree/csviri-secondary-to-primary-improve

However, when updating my reproducer, I ran into a different challenge. In my initial reproducer I used only one CRD (Repo) which referenced itself. But now I have to two different CRDs and in withPrimaryToSecondaryMapper I basically want to access the MyThingConfig informer which I'm building which is not easily possible. For now I did some dirty hack. But you might have a better idea to achieve this: https://github.com/dvob/java-operator-sdk-repo-example/blob/4b9e01c3099ae580036aa81cbe1558c0d422f0b0/src/main/java/com/example/MyThingReconciler.java#L53 ?

One thing which also came to my mind is, that if you not specify withPrimaryToSecondaryMapper it will use the DefaultPrimaryToSecondaryIndex which most likely will behave wrong in such a scenario. This is not really a problem, as you just can set withPrimaryToSecondaryMapper, but I'm just no sure how obvious this is for users of the API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

InformerEventSource: trigger reconciles based on old and new resource state

2 participants