-
Notifications
You must be signed in to change notification settings - Fork 220
refactor: renaming core classes and APIs #646
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
Changes from 4 commits
d478e35
3b76d5e
5919eac
74920ab
3f92747
fb58685
55b859d
6f07321
444f7d1
8b1be24
424f800
adc543a
1d148ac
9ec3471
910293a
349fc11
2e0ec8b
75b8e0e
8811dc3
224bcdf
94980ee
cadbc8a
0f9eaba
725fb06
b51e69b
0521f8e
4105def
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,10 +14,10 @@ | |
import io.fabric8.kubernetes.client.KubernetesClient; | ||
import io.fabric8.kubernetes.client.Version; | ||
import io.javaoperatorsdk.operator.api.LifecycleAware; | ||
import io.javaoperatorsdk.operator.api.ResourceController; | ||
import io.javaoperatorsdk.operator.api.config.ConfigurationService; | ||
import io.javaoperatorsdk.operator.api.config.ControllerConfiguration; | ||
import io.javaoperatorsdk.operator.api.config.ExecutorServiceManager; | ||
import io.javaoperatorsdk.operator.api.reconciler.Reconciler; | ||
import io.javaoperatorsdk.operator.processing.ConfiguredController; | ||
|
||
@SuppressWarnings("rawtypes") | ||
|
@@ -114,9 +114,9 @@ public void close() { | |
* @param <R> the {@code CustomResource} type associated with the controller | ||
* @throws OperatorException if a problem occurred during the registration process | ||
*/ | ||
public <R extends CustomResource<?, ?>> void register(ResourceController<R> controller) | ||
public <R extends CustomResource<?, ?>> void registerController(Reconciler<R> controller) | ||
metacosm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
throws OperatorException { | ||
register(controller, null); | ||
registerController(controller, null); | ||
} | ||
|
||
/** | ||
|
@@ -126,28 +126,28 @@ public void close() { | |
* passing it the controller's original configuration. The effective registration of the | ||
* controller is delayed till the operator is started. | ||
* | ||
* @param controller the controller to register | ||
* @param reconciler part of the controller to register | ||
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. I think that if we do this change, we need to remove the 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. Answered above, the controller. Reconciler is just the logic how to reconciler, but this is basically same in controller runtime, the controller is the whole , reconciler is just part of it. |
||
* @param configuration the configuration with which we want to register the controller, if {@code | ||
* null}, the controller's original configuration is used | ||
* @param <R> the {@code CustomResource} type associated with the controller | ||
* @throws OperatorException if a problem occurred during the registration process | ||
*/ | ||
public <R extends CustomResource<?, ?>> void register( | ||
ResourceController<R> controller, ControllerConfiguration<R> configuration) | ||
public <R extends CustomResource<?, ?>> void registerController( | ||
Reconciler<R> reconciler, ControllerConfiguration<R> configuration) | ||
throws OperatorException { | ||
final var existing = configurationService.getConfigurationFor(controller); | ||
final var existing = configurationService.getConfigurationFor(reconciler); | ||
if (existing == null) { | ||
throw new OperatorException( | ||
"Cannot register controller with name " + controller.getClass().getCanonicalName() + | ||
" controller named " + ControllerUtils.getNameFor(controller) | ||
"Cannot register controller with name " + reconciler.getClass().getCanonicalName() + | ||
" controller named " + ControllerUtils.getNameFor(reconciler) | ||
+ " because its configuration cannot be found.\n" + | ||
" Known controllers are: " + configurationService.getKnownControllerNames()); | ||
} else { | ||
if (configuration == null) { | ||
configuration = existing; | ||
} | ||
final var configuredController = | ||
new ConfiguredController<>(controller, configuration, kubernetesClient); | ||
new ConfiguredController<>(reconciler, configuration, kubernetesClient); | ||
controllers.add(configuredController); | ||
|
||
final var watchedNS = | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,34 +11,34 @@ | |
import io.javaoperatorsdk.operator.CustomResourceUtils; | ||
import io.javaoperatorsdk.operator.MissingCRDException; | ||
import io.javaoperatorsdk.operator.OperatorException; | ||
import io.javaoperatorsdk.operator.api.Context; | ||
import io.javaoperatorsdk.operator.api.DeleteControl; | ||
import io.javaoperatorsdk.operator.api.EventSourceInitializer; | ||
import io.javaoperatorsdk.operator.api.LifecycleAware; | ||
import io.javaoperatorsdk.operator.api.ResourceController; | ||
import io.javaoperatorsdk.operator.api.UpdateControl; | ||
import io.javaoperatorsdk.operator.api.config.ControllerConfiguration; | ||
import io.javaoperatorsdk.operator.api.monitoring.Metrics.ControllerExecution; | ||
import io.javaoperatorsdk.operator.api.reconciler.Context; | ||
import io.javaoperatorsdk.operator.api.reconciler.DeleteControl; | ||
import io.javaoperatorsdk.operator.api.reconciler.EventSourceInitializer; | ||
import io.javaoperatorsdk.operator.api.reconciler.Reconciler; | ||
import io.javaoperatorsdk.operator.api.reconciler.UpdateControl; | ||
import io.javaoperatorsdk.operator.processing.event.DefaultEventSourceManager; | ||
import io.javaoperatorsdk.operator.processing.event.EventSourceManager; | ||
|
||
public class ConfiguredController<R extends CustomResource<?, ?>> implements ResourceController<R>, | ||
public class ConfiguredController<R extends CustomResource<?, ?>> implements Reconciler<R>, | ||
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. Maybe this class should be renamed 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. hehe, yes also wrote this above , maybe this should be the I think this class should be our high level aggregate (therefore name it as Controller), so it will contiain the Reconciler, the EventSourceManager, the EventProcessor (former DefaultEventHandler). Basically every aspect of a single controller instance. The benefit is that we are now closer to go terminology, but on the other hand yes it can be confusing for the users. But getting it right now for v2 is probably the good time to do it "once and for all" :) |
||
LifecycleAware, EventSourceInitializer<R> { | ||
private final ResourceController<R> controller; | ||
private final Reconciler<R> reconciler; | ||
private final ControllerConfiguration<R> configuration; | ||
private final KubernetesClient kubernetesClient; | ||
private DefaultEventSourceManager<R> eventSourceManager; | ||
|
||
public ConfiguredController(ResourceController<R> controller, | ||
public ConfiguredController(Reconciler<R> reconciler, | ||
ControllerConfiguration<R> configuration, | ||
KubernetesClient kubernetesClient) { | ||
this.controller = controller; | ||
this.reconciler = reconciler; | ||
this.configuration = configuration; | ||
this.kubernetesClient = kubernetesClient; | ||
} | ||
|
||
@Override | ||
public DeleteControl deleteResource(R resource, Context context) { | ||
public DeleteControl deleteResources(R resource, Context context) { | ||
return configuration.getConfigurationService().getMetrics().timeControllerExecution( | ||
new ControllerExecution<>() { | ||
@Override | ||
|
@@ -58,13 +58,13 @@ public String successTypeName(DeleteControl deleteControl) { | |
|
||
@Override | ||
public DeleteControl execute() { | ||
return controller.deleteResource(resource, context); | ||
return reconciler.deleteResources(resource, context); | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public UpdateControl<R> createOrUpdateResource(R resource, Context context) { | ||
public UpdateControl<R> createOrUpdateResources(R resource, Context context) { | ||
return configuration.getConfigurationService().getMetrics().timeControllerExecution( | ||
new ControllerExecution<>() { | ||
@Override | ||
|
@@ -91,7 +91,7 @@ public String successTypeName(UpdateControl<R> result) { | |
|
||
@Override | ||
public UpdateControl<R> execute() { | ||
return controller.createOrUpdateResource(resource, context); | ||
return reconciler.createOrUpdateResources(resource, context); | ||
} | ||
}); | ||
} | ||
|
@@ -124,8 +124,8 @@ public String toString() { | |
return "'" + configuration.getName() + "' Controller"; | ||
} | ||
|
||
public ResourceController<R> getController() { | ||
return controller; | ||
public Reconciler<R> getReconciler() { | ||
return reconciler; | ||
} | ||
|
||
public ControllerConfiguration<R> getConfiguration() { | ||
|
@@ -169,8 +169,8 @@ public void start() throws OperatorException { | |
|
||
try { | ||
eventSourceManager = new DefaultEventSourceManager<>(this); | ||
if (controller instanceof EventSourceInitializer) { | ||
((EventSourceInitializer<R>) controller).prepareEventSources(eventSourceManager); | ||
if (reconciler instanceof EventSourceInitializer) { | ||
((EventSourceInitializer<R>) reconciler).prepareEventSources(eventSourceManager); | ||
} | ||
} catch (MissingCRDException e) { | ||
throwMissingCRDException(crdName, specVersion, controllerName); | ||
|
Uh oh!
There was an error while loading. Please reload this page.