-
Notifications
You must be signed in to change notification settings - Fork 224
Extract interfaces for optional behavior of DependentResource #949
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
734577a
feat: extract EventSourceProvider interface to clean up common use case
metacosm fb1ad88
feat: extract DependentResourceConfigurator interface
metacosm cdb66c3
fix: provide configuration via interface on reconciler
metacosm c050d2f
revert: "fix: provide configuration via interface on reconciler"
metacosm 07032b6
feat: change default configuration
metacosm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...a/io/javaoperatorsdk/operator/api/reconciler/dependent/DependentResourceConfigurator.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package io.javaoperatorsdk.operator.api.reconciler.dependent; | ||
|
||
public interface DependentResourceConfigurator<C> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 |
||
void configureWith(C config); | ||
} |
10 changes: 10 additions & 0 deletions
10
...c/main/java/io/javaoperatorsdk/operator/api/reconciler/dependent/EventSourceProvider.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.javaoperatorsdk.operator.api.reconciler.dependent; | ||
|
||
import io.fabric8.kubernetes.api.model.HasMetadata; | ||
import io.javaoperatorsdk.operator.api.reconciler.EventSourceContext; | ||
import io.javaoperatorsdk.operator.processing.event.source.EventSource; | ||
|
||
public interface EventSourceProvider<P extends HasMetadata> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 |
||
|
||
EventSource eventSource(EventSourceContext<P> context); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 relied on the fact that the default
ConfigurationService
implementation will automatically create the configuration associated with the reconciler if it doesn't exist. However, in the general case, this would actually throw an NPE as this would returnnull
: https://github.com/java-operator-sdk/java-operator-sdk/blob/323372a2e7b5b05f25a3af1162b420d5d95c19e5/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/AbstractConfigurationService.java#L54-L62There 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 default is to add AnnotationControllerConfiguration, see:
http://github.com/java-operator-sdk/java-operator-sdk/blob/dbf6c2e001ff5bba701f231babc9affc8c7433a7/operator-framework/src/main/java/io/javaoperatorsdk/operator/config/runtime/DefaultConfigurationService.java#L33-L33
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.
Like the other changes, but have basically conceptual problems with this, using
DependentResourceConfigurationProvider
makes the whole Annotation based Dependent Resource definition kinda loosing it's meaning.So from now in the background what will happen is just the DependentResource will be instantiated (with constaint of empty constructor present), and the the configuration that is explicitly implemented in the reconciler is passed to it.
I really liked that the configuration of the dependent resources is decoupled from the reconciler, since it makes then the reconciler much cleaner. Now rather I would then do just standalone DependentResources instead of this, when implementing an operator. Since we loose even that decoupling.
(And of course the reconcile and prepare event sources will be called explicitly in the background but that is again not a huge benefit and rather could be confusing / hard to understand for people who start with. So has negative sides too)
So I think we should either:
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.
checked, this works no on
next
branch.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.
An alternative what a I see is to pass this on registration:
operator.register(controller, cofiguration, dependentResourceConfiguration)
andoperator.register(controller, dependentResourceConfiguration)
So decouple it from controller configuration.