-
Notifications
You must be signed in to change notification settings - Fork 217
Dependent resources implementation #785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “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? Sign in to your account
Conversation
066e0fc
to
300dbb6
Compare
dbab033
to
36df956
Compare
d4ca4f4
to
3b7b59b
Compare
One thing that popped up is that even for kubernetes resources we will need ordering, or the "depends on" notion. Like to create resource when other is already up and running. |
This implicitly managed at the moment by the declaring order of the dependents but we should probably make it explicit, indeed. That said, one step at a time. Let's get initial support in and then see what else is needed. |
yep, lets do this in interations. But this "depends-on" notions, makes a good selling point, without it it's not more powerful than a helm chart. |
I beg to differ. You cannot reconcile dependent resources with a helm chart. It's a lot more complex than just installing dependent resources, it's also about managing them as they evolve at runtime. |
What I mean is, that helm charts handles re-apply / changes nicely. It handles when you just apply a list or resources. What does not handle is the situation when you want to "create a resource after an other resource is in a certain state". Basically this is an analogy to |
17b02c5
to
0c09a5d
Compare
tomcat.getMetadata().getName(), | ||
tomcat.getMetadata().getNamespace(), | ||
tomcat.getStatus().getReadyReplicas()); | ||
return UpdateControl.updateStatus(updatedTomcat); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the update
method from the DependentResource
called at this point ? like https://github.com/java-operator-sdk/java-operator-sdk/pull/785/files#diff-06a1ae70b5e55bf828c2120ae4525d9ad22cb82b526c6db644472ad46698f6f9R47
And how does it work when we have more than one secondary resource (like having 3 deployments) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment the dependent resources are reconciled before we reconcile the primary one so any dependent needed to be created is created before the primary reconciler is called, similarly, any updates to secondary resources will be processed before the primary resource is reconciled.
We don't currently handle the case where you have several dependents of the same type very well. The previous version of the implementation allowed you to add a qualifier to your dependent definition specifically for this case. We have a name on EventSource
for that purpose but it should indeed be exposed to the annotation.
...amework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ResourceConfiguration.java
Show resolved
Hide resolved
...r-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/DependentResource.java
Show resolved
Hide resolved
|
||
import java.util.Optional; | ||
|
||
public interface AttributeHolder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that this is used in the context only. WHat is the purpose here? Maybe describe it also in javadoc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also used by the EventSourceContext
@@ -0,0 +1,5 @@ | |||
package io.javaoperatorsdk.operator.api.reconciler; | |||
|
|||
public interface EventSourceContextInjector { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be probably a generics on the EvenSourceContext not sure if also on the interface itself too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand here…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IntelliJ complains that EventSourceContext is without a generics
} | ||
|
||
@SuppressWarnings("unchecked") | ||
protected Persister<R, P> initPersister(DependentResource<R, P> delegate) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about this part, if it needs to implement persister why it can be configured separatelly. Also why is not directly on DependentResource
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure either anymore, tbh… 😅
operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/Controller.java
Outdated
Show resolved
Hide resolved
.../src/main/java/io/javaoperatorsdk/operator/processing/event/source/DependentEventSource.java
Outdated
Show resolved
Hide resolved
extends DefaultResourceConfiguration<R> { | ||
|
||
private final PrimaryResourcesRetriever<R> secondaryToPrimaryResourcesIdSet; | ||
private final AssociatedSecondaryResourceIdentifier<P> associatedWith; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not abbe associatedDependentResource
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what you mean…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's about naming, but I;m probably wrong. So I guess it's already this way to some extent, but:
- The resources that are managed by dependent resources we can call "dependent resources"
- And the secondary resource that is the resource managed by te controller by not the dependent resources mecahnism directly?
Or should not be rather managed dependent resource and dependent resources?
So sometimes the naming is confusing for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The naming is indeed not great… we should probably settle on using dependent
or secondary
everywhere.
import io.javaoperatorsdk.operator.processing.event.source.ResourceCache; | ||
import io.javaoperatorsdk.operator.processing.event.source.UpdatableCache; | ||
|
||
public class InformerManager<T extends HasMetadata, C extends ResourceConfiguration<T>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing Unit tests.
private final AssociatedSecondaryResourceIdentifier<P> associatedWith; | ||
private final boolean skipUpdateEventPropagationIfNoChange; | ||
|
||
public InformerConfiguration(ConfigurationService service, String labelSelector, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The configuration service is a little bit weird here a little bit. Especially if somebody wants to create an Informer without Depdendent resources.
It's not easy to review this big change. What I would like (maybe just temporarily) is also have there the samples without the dependent resources. Since there are some places, where it's not clear (like the informers) how that would work without dependent resources. So that would help. Also miss unit tests in some cases. |
So a goal should be also to preserve the current "low" level API clear and available. Ideally make it clear where is the difference. |
Also we should add docs soons, this is clear how to use. Also update the internal docs: https://javaoperatorsdk.io/docs/architecture-and-internals Since this is quite massive change. |
Pls add also the description of the scope this PR. |
I need to update it but the scope is defined in #771. |
As mentioned several times already, this is completely opt-in. If you don't want to use the dependent resources support, you can keep doing what was done before. |
Easy enough: there is no change. You can use the previous version of the examples without any issue because this is completely opt-in.
Definitely but that will come after the approach is validated. |
I commented in one place the InformerEventSource for example seems to have completetly different API |
aecc4c2
to
6e7ed41
Compare
- Kubernetes-native resources are automatically handled without users having to deal with explicit event sources - Reconcilers and event sources can exchange information via the `EventSourceContext` - Declarative management is completely opt-in and can cohabit with "traditional" handling i.e. it's possible to have only part of the dependents being declared via annotations and others explicitly handled (though from a maintenance perspective it's better to stick to one approach or the other)
cadae26
to
7f1cdca
Compare
SonarCloud Quality Gate failed. |
This PR is now merged in the |
Fixes #771