Skip to content

Commit 14a543e

Browse files
authored
fix: use appropriate terms where needed (#790)
1 parent a374f46 commit 14a543e

File tree

9 files changed

+67
-53
lines changed

9 files changed

+67
-53
lines changed

docs/documentation/features.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,15 @@ Always update the custom resource with `UpdateControl`, not with the actual kube
9696
On resource updates there is always an optimistic version control in place, to make sure that another update is not
9797
overwritten (by setting `resourceVersion` ) .
9898

99-
The `DeleteControl` typically instructs the framework to remove the finalizer after the dependent resource are cleaned
100-
up in `cleanup` implementation.
101-
102-
However, there is a possibility to not remove the finalizer, this allows to clean up the resources in a more async way,
103-
mostly for the cases when there is a long waiting period after a delete operation is initiated. Note that in this case
104-
you might want to either schedule a timed event to make sure the
105-
`deleteResource` is executed again or use event sources get notified about the state changes of a deleted resource.
99+
The `DeleteControl` typically instructs the framework to remove the finalizer after the dependent
100+
resource are cleaned up in `cleanup` implementation.
101+
102+
However, there is a possibility to not remove the finalizer, this allows to clean up the resources
103+
in a more async way, mostly for the cases when there is a long waiting period after a delete
104+
operation is initiated. Note that in this case you might want to either schedule a timed event to
105+
make sure
106+
`cleanup` is executed again or use event sources get notified about the state changes of a deleted
107+
resource.
106108

107109
## Generation Awareness and Automatic Observed Generation Handling
108110

docs/documentation/v2-migration.md

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
---
2-
title: Migrating from v1 to v2
3-
description: Migrating from v1 to v2
4-
layout: docs
5-
permalink: /docs/v2-migration
2+
title: Migrating from v1 to v2 description: Migrating from v1 to v2 layout: docs permalink:
3+
/docs/v2-migration
64
---
75

86
# Migrating from v1 to v2
97

10-
Version 2 of the framework introduces improvements, features and breaking changes for the APIs both internal and user
11-
facing ones. The migration should be however trivial in most of the cases. For detailed overview of all major issues
12-
until the release of
13-
v`2.0.0` [see milestone on GitHub](https://github.com/java-operator-sdk/java-operator-sdk/milestone/1). For a summary
14-
and reasoning behind some naming changes
8+
Version 2 of the framework introduces improvements, features and breaking changes for the APIs both
9+
internal and user facing ones. The migration should be however trivial in most of the cases. For
10+
detailed overview of all major issues until the release of
11+
v`2.0.0` [see milestone on GitHub](https://github.com/java-operator-sdk/java-operator-sdk/milestone/1)
12+
. For a summary and reasoning behind some naming changes
1513
see [this issue](https://github.com/java-operator-sdk/java-operator-sdk/issues/655)
1614

1715
## User Facing API Changes
@@ -26,28 +24,35 @@ The following items are renamed and slightly changed:
2624
- `deleteResource` renamed to `cleanup`
2725
- Events are removed from
2826
the [`Context`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/Context.java)
29-
of `Reconciler` methods . The rationale behind this, is that there is a consensus now on the pattern that the events
30-
should not be used to implement a reconciliation logic.
27+
of `Reconciler` methods . The rationale behind this, is that there is a consensus now on the
28+
pattern that the events should not be used to implement a reconciliation logic.
3129
- The `init` method is extracted from `ResourceController` / `Reconciler` to a separate interface
3230
called [EventSourceInitializer](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/EventSourceInitializer.java)
33-
that `Reconcile` should implement in order to register event sources. See
31+
that `Reconciler` should implement in order to register event sources. The method has been renamed
32+
to `prepareEventSources` and should now return a list of `EventSource` implementations that
33+
the `Controller` will automatically register. See
3434
also [sample](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/sample-operators/tomcat-operator/src/main/java/io/javaoperatorsdk/operator/sample/WebappReconciler.java)
35-
for usage. Here also
36-
the [`EventSourceManager`](https://github.com/java-operator-sdk/java-operator-sdk/blob/v1/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/EventSourceManager.java)
37-
is renamed
38-
to [`EventSourceRegistry`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/EventSourceRegistry.java)
39-
, and it's interface refined.
35+
for usage.
36+
- [`EventSourceManager`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/EventSourceManager.java)
37+
is now an internal class that users shouldn't need to interact with.
4038
- [`@Controller`](https://github.com/java-operator-sdk/java-operator-sdk/blob/v1/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/Controller.java)
4139
annotation renamed
4240
to [`@ControllerConfiguration`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/ControllerConfiguration.java)
41+
- The metrics use `reconcile`, `cleanup` and `resource` labels instead of `createOrUpdate`, `delete`
42+
and `cr`, respectively to match the new logic.
4343

4444
### Event Sources
4545

46-
- Addressing resources within event sources (and in the framework internally) is now changed from `.metadata.uid` to a
47-
pair of `.metadata.name` and optional `.metadata.namespace` of resource. Represented
46+
- Addressing resources within event sources (and in the framework internally) is now changed
47+
from `.metadata.uid` to a pair of `.metadata.name` and optional `.metadata.namespace` of resource.
48+
Represented
4849
by [`ResourceID.`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/ResourceID.java)
49-
- The [`Event`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/Event.java)
50-
API is simplified. Now if an event source produces an event it needs to just produce an instance of this class.
50+
-
51+
52+
The [`Event`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/Event.java)
53+
API is simplified. Now if an event source produces an event it needs to just produce an instance of
54+
this class.
55+
5156
- [`EventSource`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/EventSource.java)
5257
is refactored, but the changes are trivial.
5358

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/DeleteControl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public boolean isRemoveFinalizer() {
2323
@Override
2424
public DeleteControl rescheduleAfter(long delay) {
2525
if (removeFinalizer) {
26-
throw new IllegalStateException("Cannot reschedule deleteResource if removing finalizer");
26+
throw new IllegalStateException("Cannot reschedule cleanup if removing finalizer");
2727
}
2828
return super.rescheduleAfter(delay);
2929
}

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/Controller.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public DeleteControl cleanup(R resource, Context context) {
4444
new ControllerExecution<>() {
4545
@Override
4646
public String name() {
47-
return "delete";
47+
return "cleanup";
4848
}
4949

5050
@Override
@@ -70,7 +70,7 @@ public UpdateControl<R> reconcile(R resource, Context context) {
7070
new ControllerExecution<>() {
7171
@Override
7272
public String name() {
73-
return "createOrUpdate";
73+
return "reconcile";
7474
}
7575

7676
@Override
@@ -80,7 +80,7 @@ public String controllerName() {
8080

8181
@Override
8282
public String successTypeName(UpdateControl<R> result) {
83-
String successType = "cr";
83+
String successType = "resource";
8484
if (result.isUpdateStatus()) {
8585
successType = "status";
8686
}

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/ReconciliationDispatcher.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@
1111
import io.fabric8.kubernetes.client.dsl.Resource;
1212
import io.javaoperatorsdk.operator.api.ObservedGenerationAware;
1313
import io.javaoperatorsdk.operator.api.config.ControllerConfiguration;
14-
import io.javaoperatorsdk.operator.api.reconciler.*;
14+
import io.javaoperatorsdk.operator.api.reconciler.BaseControl;
15+
import io.javaoperatorsdk.operator.api.reconciler.Context;
16+
import io.javaoperatorsdk.operator.api.reconciler.DefaultContext;
17+
import io.javaoperatorsdk.operator.api.reconciler.DeleteControl;
18+
import io.javaoperatorsdk.operator.api.reconciler.ErrorStatusHandler;
19+
import io.javaoperatorsdk.operator.api.reconciler.Reconciler;
20+
import io.javaoperatorsdk.operator.api.reconciler.RetryInfo;
21+
import io.javaoperatorsdk.operator.api.reconciler.UpdateControl;
1522
import io.javaoperatorsdk.operator.processing.Controller;
1623

1724
import static io.javaoperatorsdk.operator.processing.KubernetesResourceUtils.getName;
@@ -80,8 +87,8 @@ private PostExecutionControl<R> handleDispatch(ExecutionScope<R> executionScope)
8087
* {@link Reconciler#cleanup(HasMetadata, Context)} method
8188
*
8289
* @param resource the resource to be potentially deleted
83-
* @return {@code true} if the resource should be handed to the controller's {@code
84-
* deleteResource} method, {@code false} otherwise
90+
* @return {@code true} if the resource should be handed to the controller's
91+
* {@link Reconciler#cleanup(HasMetadata, Context)} method, {@code false} otherwise
8592
*/
8693
private boolean shouldNotDispatchToDelete(R resource) {
8794
// we don't dispatch to delete if the controller is configured to use a finalizer but that
@@ -133,7 +140,7 @@ private R cloneResourceForErrorStatusHandlerIfNeeded(R resource, Context context
133140
private PostExecutionControl<R> reconcileExecution(ExecutionScope<R> executionScope,
134141
R resourceForExecution, R originalResource, Context context) {
135142
log.debug(
136-
"Executing createOrUpdate for resource {} with version: {} with execution scope: {}",
143+
"Reconciling resource {} with version: {} with execution scope: {}",
137144
getName(resourceForExecution),
138145
getVersion(resourceForExecution),
139146
executionScope);

sample-operators/mysql-schema/src/main/java/io/javaoperatorsdk/operator/sample/MySQLSchemaReconciler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public UpdateControl<MySQLSchema> reconcile(MySQLSchema schema, Context context)
7979

8080
@Override
8181
public DeleteControl cleanup(MySQLSchema schema, Context context) {
82-
log.info("Execution deleteResource for: {}", schema.getMetadata().getName());
82+
log.info("Cleaning up for: {}", schema.getMetadata().getName());
8383
try (Connection connection = getConnection()) {
8484
var dbSchema = SchemaService.getSchema(connection, schema.getMetadata().getName());
8585
if (dbSchema.isPresent()) {

sample-operators/tomcat-operator/README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,16 @@ run `kubectl apply -f k8s/operator.yaml`. Now you can create Tomcat instances wi
6262
above).
6363

6464
## EventSources
65-
The TomcatController is listening to events about Deployments created by the TomcatOperator by registering a
66-
InformerEventSource with the EventSourceManager. The InformerEventSource will in turn register a watch on
67-
all Deployments managed by the Controller (identified by the `app.kubernetes.io/managed-by` label).
68-
When an event from a Deployment is received we have to identify which Tomcat object does the Deployment
69-
belong to. This is done when the InformerEventSource creates the event.
70-
71-
The TomcatController has to take care of setting the `app.kubernetes.io/managed-by` label on the Deployment so the
72-
InformerEventSource can watch the right Deployments.
73-
The TomcatController also has to set `ownerReference` on the Deployment so later the InformerEventSource can
74-
identify which Tomcat does the Deployment belong to. This is necessary so the frameowork can call the Controller
75-
`createOrUpdate` method correctly.
65+
The TomcatController is listening to events about Deployments created by the TomcatOperator by
66+
registering a InformerEventSource with the EventSourceManager. The InformerEventSource will in turn
67+
register a watch on all Deployments managed by the Controller (identified by
68+
the `app.kubernetes.io/managed-by` label). When an event from a Deployment is received we have to
69+
identify which Tomcat object does the Deployment belong to. This is done when the
70+
InformerEventSource creates the event.
71+
72+
The TomcatController has to take care of setting the `app.kubernetes.io/managed-by` label on the
73+
Deployment so the InformerEventSource can watch the right Deployments. The TomcatController also has
74+
to set `ownerReference` on the Deployment so later the InformerEventSource can identify which Tomcat
75+
does the Deployment belong to. This is necessary so the framework can call the Controller
76+
`reconcile` method correctly.
7677

sample-operators/webpage/src/main/java/io/javaoperatorsdk/operator/sample/WebPageReconciler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public UpdateControl<WebPage> reconcile(WebPage webPage, Context context) {
118118

119119
@Override
120120
public DeleteControl cleanup(WebPage nginx, Context context) {
121-
log.info("Execution deleteResource for: {}", nginx.getMetadata().getName());
121+
log.info("Cleaning up for: {}", nginx.getMetadata().getName());
122122

123123
log.info("Deleting ConfigMap {}", configMapName(nginx));
124124
Resource<ConfigMap> configMap =

smoke-test-samples/common/src/main/java/io/javaoperatorsdk/operator/sample/CustomServiceReconciler.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
@ControllerConfiguration
1818
public class CustomServiceReconciler implements Reconciler<CustomService> {
1919

20-
public static final String KIND = "CustomService";
2120
private static final Logger log = LoggerFactory.getLogger(CustomServiceReconciler.class);
2221

2322
private final KubernetesClient kubernetesClient;
@@ -32,14 +31,14 @@ public CustomServiceReconciler(KubernetesClient kubernetesClient) {
3231

3332
@Override
3433
public DeleteControl cleanup(CustomService resource, Context context) {
35-
log.info("Execution deleteResource for: {}", resource.getMetadata().getName());
36-
return DeleteControl.defaultDelete();
34+
log.info("Cleaning up for: {}", resource.getMetadata().getName());
35+
return Reconciler.super.cleanup(resource, context);
3736
}
3837

3938
@Override
4039
public UpdateControl<CustomService> reconcile(
4140
CustomService resource, Context context) {
42-
log.info("Execution createOrUpdateResource for: {}", resource.getMetadata().getName());
41+
log.info("Reconciling: {}", resource.getMetadata().getName());
4342

4443
ServicePort servicePort = new ServicePort();
4544
servicePort.setPort(8080);

0 commit comments

Comments
 (0)