Skip to content

DependentResource support for event sources where multiple resources of same type are handled for single primary #1175

New issue

Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “No Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? No Sign in to your account

Closed
csviri opened this issue Apr 22, 2022 · 2 comments · Fixed by #1378

Comments

@csviri
Copy link
Collaborator

csviri commented Apr 22, 2022

In the following PR: #1169 we made sure that every resource event source can handle multiple secondary resources for a primary. A dependent resource however now represents a single resource on cluster. So in order to share a event source between more resource that are (the same type and) related to a single primary resources, we would need to have a discriminator function. So if a dependent resource receives from Set<R> getSecondaryResources() multiple resources this discriminator will select which one to handle from the set.

This is a relative simple but useful way to support this case.

@csviri csviri self-assigned this Apr 22, 2022
@csviri csviri added this to the 3.2 milestone Jun 2, 2022
@csviri csviri modified the milestones: 3.2, 3.3 Jun 28, 2022
@csviri csviri changed the title DependentResource support for event sources where multiple resources are handled for single primary DependentResource support for event sources where multiple resources for same type are handled for single primary Jul 25, 2022
@csviri csviri changed the title DependentResource support for event sources where multiple resources for same type are handled for single primary DependentResource support for event sources where multiple resources of same type are handled for single primary Jul 25, 2022
@csviri csviri linked a pull request Aug 5, 2022 that will close this issue
@csviri csviri modified the milestones: 3.2, 3.3 Aug 30, 2022
@csviri csviri closed this as completed Oct 4, 2022
@grossws
Copy link

grossws commented Oct 21, 2022

FtR: As a workaround for 3.2.x one could try to use distinct labels for different managed resources of the same type plus explicit @Dependent(name = "some-name", type = SomeResource.class) and then use either context.getSecondaryResources(Deployment.class) or context.getSecondaryResource(Deployment.class, "some-name") (but it could be deprecated in #1240).

Not sure if it will lead for other issues though, so it's just a possible approach. I hope @csviri would correct me if it's a wrong way to do it in 3.2.x and if there's better approach.

As example of such approach there's my reproducer project for another issue.

@csviri
Copy link
Collaborator Author

csviri commented Oct 24, 2022

Hi @grossws, in v4.1 (will are getting it released shortly) there will be an explicit support for that. But there is no other approach now in 3.2.

No Sign up for free to join this conversation on GitHub. Already have an account? No Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants