-
Notifications
You must be signed in to change notification settings - Fork 220
Persistent state dependent resources #1543
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
Co-authored-by: Chris Laprun <metacosm@gmail.com>
* feat: decouple event source from cache + list discriminator (#1378) * feat: bulk dependent resources (#1448) * feat: optional eventsource on dependent resources (#1479) * refactor: simplify handling of reused event sources (#1518) Co-authored-by: Chris Laprun <metacosm@gmail.com> * refactor: isolate index handling to BulkDependentResource interface (#1517) * feat: key based bulk resource creation (#1521) * improvement: bulk dependent resource api * merge Co-authored-by: Chris Laprun <metacosm@gmail.com> Co-authored-by: Chris Laprun <metacosm@users.noreply.github.com>
d483f7b
to
74fd92f
Compare
* refactor: deleteBulkResource -> deleteTargetResource * refactor: remove now unneeded class * refactor: deleteBulkResourcesIfRequired -> deleteExtraResources * fix: javadoc
closes #1221 |
...rc/main/java/io/javaoperatorsdk/operator/processing/dependent/AbstractDependentResource.java
Outdated
Show resolved
Hide resolved
public abstract class AbstractExternalDependentResource<R, P extends HasMetadata, T extends ResourceEventSource<R, P>> | ||
extends AbstractEventSourceHolderDependentResource<R, P, T> { | ||
|
||
private final boolean isDependentResourceWithExplicitState = |
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.
Would someone use this class and not implement DependentResourceWithExplicitState? If yes, why?
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 thing is that the "batteries included" externals should support easily external resources with and without the state. So it should not implement DependentResourceWithExplicitState
by default.
But you got a point, that if some just want to imlpement an external resource event source without state, might just extend AbstractEventSourceHolderDependentResource
.
Maybe we should rename it to ExternalWithStateSupportDependentResource
?
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 renaming the class will fix the problem… Why would someone extend AbstractExternalDependentResource
and not implement DependentResourceWithExplicitState
? Could you detail a use case where someone would extend this class and not want an explicit external state with it?
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.
yep, so we have already samples for that (like the mysql sample):
If somebody want a PollingDependentResource, that does not need an external state.
Note that not every external resource needs an explicit state, for example if it can be addressed only by the information in the custom resource. However some might need one, like if a github PR is managed. Therefore the current implementation allows to a dependent resource to extend PollingDependentResource (and others) and to decide if it needs an external state or not implementing the related DependentResourceWithExplicitState
.
I thing that we might address in a separate PR and could have an impact on this is this issue:
#1511
(but not necessarily)
However I recognize that Polling and PerResourcePolling DRs are quite a thin layer, that basically just creates an instance of a EventSource on top of a standard functionality. (althoug might be extended later for example with an improved configuration). So the structure might change in the future if we for example make it less explic? "Thus just an external event source that provides an event source" abstraction.
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 seems, though, that (most of) the functionality that this class provides is only available if you implement DependentResourceWithExplicitState
so I'm wondering about the benefit of having this class plus a separate interface when most (if not all of the behavior) is specific to that one use case.
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.
Yep, but don't see how we would cover otherwise just optionally having this external state functionality for Polling EventSources.
Co-authored-by: Chris Laprun <metacosm@gmail.com>
* feat: decouple event source from cache + list discriminator (#1378) * feat: bulk dependent resources (#1448) * feat: optional eventsource on dependent resources (#1479) * refactor: simplify handling of reused event sources (#1518) Co-authored-by: Chris Laprun <metacosm@gmail.com> * refactor: isolate index handling to BulkDependentResource interface (#1517) * feat: key based bulk resource creation (#1521) * improvement: bulk dependent resource api * merge Co-authored-by: Chris Laprun <metacosm@gmail.com> Co-authored-by: Chris Laprun <metacosm@users.noreply.github.com>
* refactor: deleteBulkResource -> deleteTargetResource * refactor: remove now unneeded class * refactor: deleteBulkResourcesIfRequired -> deleteExtraResources * fix: javadoc
# Conflicts: # operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/AbstractDependentResource.java # operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/BulkDependentResourceReconciler.java # operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/SingleDependentResourceReconciler.java # operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/external/AbstractPollingDependentResource.java # operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/kubernetes/KubernetesDependentResource.java
|
||
import static io.javaoperatorsdk.operator.sample.externalstate.ExternalStateDependentReconciler.ID_KEY; | ||
|
||
public class ExternalWithStateDependentResourceDependentResourceWith extends |
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.
Can we rename this class to something better?
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.
updated
public abstract class AbstractExternalDependentResource<R, P extends HasMetadata, T extends ResourceEventSource<R, P>> | ||
extends AbstractEventSourceHolderDependentResource<R, P, T> { | ||
|
||
private final boolean isDependentResourceWithExplicitState = |
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 seems, though, that (most of) the functionality that this class provides is only available if you implement DependentResourceWithExplicitState
so I'm wondering about the benefit of having this class plus a separate interface when most (if not all of the behavior) is specific to that one use case.
|
||
@Ignore | ||
public abstract class AbstractPollingDependentResource<R, P extends HasMetadata> | ||
extends AbstractCachingDependentResource<R, P> implements CacheKeyMapper<R> { | ||
extends AbstractExternalDependentResource<R, P, ExternalResourceCachingEventSource<R, P>> | ||
implements CacheKeyMapper<R> { | ||
|
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 a polling dependent resource necessarily external?
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.
Yes, we don't poll kubernetes API.
@@ -1,16 +1,13 @@ | |||
package io.javaoperatorsdk.operator.processing.dependent.kubernetes; | |||
|
|||
import java.util.HashMap; | |||
import java.util.Optional; | |||
import java.util.Set; | |||
|
|||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; |
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.
Should we throw an exception if secondary is null?
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 an outdated place, could you pls point me again where do you mean it?
# Conflicts: # operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/AbstractDependentResource.java # operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/BulkDependentResourceReconciler.java # operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/SingleDependentResourceReconciler.java # operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/external/AbstractPollingDependentResource.java # operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/kubernetes/KubernetesDependentResource.java
Kudos, SonarCloud Quality Gate passed! |
No description provided.