Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Hi, I have a use case very similar to the PrimaryToSecondaryDependent example. The difference is, however, that in my case a CRD (called Benchmark) refers to a list of ConfigMaps and a ConfigMap can be referred to from multiple Benchmarks. That means when a ConfigMap, for example, changes, 0 to many Benchmarks have to be reconciled.

I modified the PrimaryToSecondaryDependent example accordingly, but get the error:

java.lang.IllegalStateException: More than 1 secondary resource related to primary

Is this behavior expected? If yes, what would be a possible workaround for this use case? If not, I can also share more details on what I implemented to identify what I did wrong.

Thanks in advance!

You must be logged in to vote

Hi I would just not use dependents for now, as it described. Version 5 is not released and not sure when it will be, might be few months there are some decisions around still hanging.

So I would just not use dependents, use the informer from example that triggers the reconciliation, and implement the logic with low level API.

Replies: 1 comment · 7 replies

Comment options

Hi @SoerenHenning ,
So I guess you modified to PrimaryToSecondaryMapper to return multiple ConfigMaps. That is fine.

When do you get exactly this error? Pls paste the logs that might be enough. Is it happening from a dependent or you calling context.getSecondaryResource from a reconciler.

Note that if you calling it from reconcile there is simply a version of this method that returns multiple configMaps:

<R> Set<R> getSecondaryResources(Class<R> expectedType);
default <R> Stream<R> getSecondaryResourcesAsStream(Class<R> expectedType) {
return getSecondaryResources(expectedType).stream();
}

You must be logged in to vote
7 replies
@csviri
Comment options

Do I understand correctly that Benchmark can reference multiple config maps? If yes, then I guess you have one dependent representing a configMap, is there one particular that you want to reference or this should be actually a BulkDependetResource?

@csviri
Comment options

Note that read only bulk dependent resources are not supported in v4.x (will be in v5, already implemented).
#2233

see also: https://javaoperatorsdk.io/docs/dependent-resources/#read-only-dependent-resources-vs-event-source

@SoerenHenning
Comment options

I think, the pointer to BulkDependetResource is already a good hint. To answer your questions: Yes, a Benchmark can reference multiple ConfigMaps. Whenever any of these ConfigMaps changes, I need to reconcile all the Benchmarks that do reference this ConfigMap.

My ConfigMapDependent currently simply looks like this (again Kotlin code):

class ConfigMapDependent : KubernetesDependentResource<ConfigMap, BenchmarkCRD>(ConfigMap::class.java) {
}

Would I simply have to extend from BulkDependetResource instead? Maybe I do not fully get the concept of dependents, so sorry if the answer to my question is too obvious.

I am currently still on v4.x (we are migrating a self-built operator with an older fabric8 version to JOSDK), but if it solves the problem, I can directly try to go with v5.x

@csviri
Comment options

Hi I would just not use dependents for now, as it described. Version 5 is not released and not sure when it will be, might be few months there are some decisions around still hanging.

So I would just not use dependents, use the informer from example that triggers the reconciliation, and implement the logic with low level API.

Answer selected by SoerenHenning
@SoerenHenning
Comment options

Thank you very much, it looks like this solved by simply removing the @Dependent annotation. 🎉
Do you think it still makes sense to use a BulkDependetResource for the reasons described in “Read-only” Dependent Resources vs. Event Source or will there be no advantage for this use case?

@csviri
Comment options

So, it is useful I think if you use some other workflow features in in combination, like adding a ready condition or reconcilePrecondiotion to it. Otherwise it is not that useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.