Skip to content

Conversation

@csviri
Copy link
Collaborator

@csviri csviri commented Oct 15, 2025

PR introduces similar mechanism for external resource as for KubernetesDependetResource to easily override a method to provide an ID if user want't to avoid computing desired states multiple times.
Also improves the docs with pointers where we explain how to avoid calling desired multiple times.

[`targetSecondaryResourceID`](https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/AbstractExternalDependentResource.java#L138)
for external resources. See below the related ID handling
- If the approach from above doesn't fit your needs, you can override the target resource selection mechanism by overriding
`selectTargetSecondaryResource` for both [`KubernetesDependentResource`](https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/kubernetes/KubernetesDependentResource.java#L282)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/kubernetes/KubernetesDependentResource.java#L269

Noting also that we should propably look into how to automate this with some kind of annotation comments in code to track correct line numbers.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, if we could solve that, would be awesome.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@csviri but this link still needs to be fixed or not?

…der to avoid calling desired state

Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
@csviri csviri force-pushed the possibility-to-provide-id-for-external-resource branch from ef17ff9 to ffc9e85 Compare October 19, 2025 17:14
@csviri csviri requested a review from xstefank October 19, 2025 17:14
@csviri
Copy link
Collaborator Author

csviri commented Oct 20, 2025

@metacosm I would like to merge this, we can have the desired caching as a followup pr on next. thx

Signed-off-by: Chris Laprun <[email protected]>
@metacosm
Copy link
Collaborator

Reviewing this, I'm not sure I like the current design of putting the provider on the external resource class… I think it might be more appropriate to put it on the related dependent resource implementation since this is where the logic for this should be, imo. It doesn't feel right to put JOSDK-related logic on the external resource class, especially considering that maybe that class is not modifiable (if it's coming from a 3rd party library, for example). It also makes sense to gather the resource identification logic on the dependent resource implementation, imo.

@csviri
Copy link
Collaborator Author

csviri commented Oct 23, 2025

Reviewing this, I'm not sure I like the current design of putting the provider on the external resource class… I think it might be more appropriate to put it on the related dependent resource implementation since this is where the logic for this should be, imo. It doesn't feel right to put JOSDK-related logic on the external resource class, especially considering that maybe that class is not modifiable (if it's coming from a 3rd party library, for example). It also makes sense to gather the resource identification logic on the dependent resource implementation, imo.

Yes, I was also thinking about that. Maybe we could generalize the cacheKeyMapper concept, see also generalization here:

#3007

WDYT?

But those are not necessarily contradicting nor we have to choose, we can have the (renamed to ResourceIDMapper ) cacheKeyMapper in dependent resources, where there will be still a posibility to use the ResourceIdProvider, just not limited to that.

@csviri
Copy link
Collaborator Author

csviri commented Oct 23, 2025

So what I would do is to merge this and #3007 to next, but iterate over it for 5.2 to achieve what you also proposed.

@xstefank
Copy link
Collaborator

I think Chris has a point. So why it would be worth merging this now to next and then changing it later?

@csviri
Copy link
Collaborator Author

csviri commented Oct 23, 2025

replaced by: #3007

@xstefank so I still intend to kepp the ExternalResourceVersionProvider just also use the CacheKeyMapper/ResourceIDMapper for DRs

let's continue the discussion under the linked PR, will prepare one with the mentioned changes

@csviri csviri closed this Oct 23, 2025
@metacosm
Copy link
Collaborator

Should the branch be deleted?

@csviri csviri deleted the possibility-to-provide-id-for-external-resource branch October 24, 2025 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improved default setup for External Dependent Resource for selecting and/or matching resources

3 participants