-
Notifications
You must be signed in to change notification settings - Fork 219
feat: delay the registration of controller till the operator is started #491
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
feat: delay the registration of controller till the operator is started #491
Conversation
45b7f03
to
e3a32d0
Compare
operator-framework-core/src/main/java/io/javaoperatorsdk/operator/Operator.java
Show resolved
Hide resolved
if (!started) { | ||
this.controllers.add(new ControllerRef(controller, configuration)); | ||
} else { | ||
this.controllers.add(new ControllerRef(controller, configuration)); |
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 ControllerRef
object is added to the queue in case a scenario like start, stop, start would be supported.
@@ -195,4 +249,14 @@ private void throwMissingCRDException(String crdName, String specVersion, String | |||
} | |||
return false; | |||
} | |||
|
|||
private static class ControllerRef { |
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 be parameterized by the CR type so that the ResourceController
and ControllerConfiguration
instances use the same type…
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 how it should be done as the list of ControllerRef would need to be on the base type in any case. Unfortunately, the usage of generic in the project is a little bit confused an inconsistent so the only way I found to make all the methods happy were to remove generics.
But I'm happy to change this if you help me understanding the right way of doing 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.
I agree that the generic usage is inconsistent in the project. Let's address this in a subsequent PR.
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.
thx, can you re-trigger the CI ?
ResourceController<R> controller, | ||
ControllerConfiguration<R> configuration, | ||
MixedOperation<R, KubernetesResourceList<R>, Resource<R>> client) { | ||
ResourceController controller, ControllerConfiguration configuration, MixedOperation client) { |
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 don't think that this change is needed.
@@ -45,10 +43,9 @@ | |||
} | |||
} | |||
|
|||
@SuppressWarnings({"rawtypes", "unchecked"}) |
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.
Unneeded without the following change.
@metacosm @csviri This is a POC of the discussion we had on the weekly meeting about the lifecycle of controllers vs operator' start/stop method.
Fixes #488
Fixes #489