Skip to content

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

Merged
merged 1 commit into from
Aug 16, 2021

Conversation

lburgazzoli
Copy link
Collaborator

@lburgazzoli lburgazzoli commented Aug 13, 2021

@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

if (!started) {
this.controllers.add(new ControllerRef(controller, configuration));
} else {
this.controllers.add(new ControllerRef(controller, configuration));
Copy link
Collaborator Author

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 {
Copy link
Collaborator

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…

Copy link
Collaborator Author

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.

Copy link
Collaborator

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.

Copy link
Collaborator Author

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) {
Copy link
Collaborator

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"})
Copy link
Collaborator

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 metacosm merged commit 1735651 into operator-framework:master Aug 16, 2021
@lburgazzoli lburgazzoli deleted the operator-lifecycle branch August 20, 2021 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[discussion] perform Operator::register when invoking Operator::start Prevent Operator star/stop procedure be performed twice
2 participants