Skip to content

Commit b3c04b8

Browse files
authored
V2 migration guide (#717)
1 parent efc0f05 commit b3c04b8

File tree

5 files changed

+61
-3
lines changed

5 files changed

+61
-3
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ by [operator-sdk](https://github.com/operator-framework/operator-sdk).
88

99
Our webpage with documentation is getting better every day: https://javaoperatorsdk.io/
1010

11+
**!! NOTE the main branch now contains source code for v2, which is under development, for actual
12+
version see [v1 branch](https://github.com/java-operator-sdk/java-operator-sdk/tree/v1) !!**
13+
1114
Table of Contents
1215
==========
1316

docs/_data/sidebar.yml

+2
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@
1313
url: /docs/faq
1414
- title: Contributing
1515
url: /docs/contributing
16+
- title: Migrating from v1 to v2
17+
url: /docs/v2-migration
1618

docs/documentation/patterns-best-practices.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ of Java Operator SDK.
1212

1313
## Implementing a Controller
1414

15-
### Sync of Async Way of Resource Handling
16-
1715
### Idempotency
1816

17+
### Sync of Async Way of Resource Handling
18+
1919
## Why to Have Automated Retries?
2020

2121
## Managing State

docs/documentation/use-samples.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ The Controller implements the business logic and describes all the classes neede
5858

5959
```java
6060

61-
@Controller
61+
@ControllerConfiguration
6262
public class WebServerController implements Reconciler<WebServer> {
6363

6464
// Return the changed resource, so it gets updated. See javadoc for details.

docs/documentation/v2-migration.md

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
title: Migrating from v1 to v2
3+
description: Migrating from v1 to v2
4+
layout: docs
5+
permalink: /docs/v2-migration
6+
---
7+
8+
# Migrating from v1 to v2
9+
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
15+
see [this issue](https://github.com/java-operator-sdk/java-operator-sdk/issues/655)
16+
17+
## User Facing API Changes
18+
19+
The following items are renamed and slightly changed:
20+
21+
- [`ResourceController`](https://github.com/java-operator-sdk/java-operator-sdk/blob/v1/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/ResourceController.java)
22+
interface is renamed
23+
to [`Reconciler`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/Reconciler.java)
24+
. In addition, methods:
25+
- `createOrUpdate` renamed to `reconcile`
26+
- `delete` renamed to `cleanup`
27+
- Events are removed from
28+
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.
31+
- The `init` method is extracted from `ResourceController` / `Reconciler` to a separate interface
32+
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
34+
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.
40+
- [`@Controller`](https://github.com/java-operator-sdk/java-operator-sdk/blob/v1/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/Controller.java)
41+
annotation renamed
42+
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)
43+
44+
### Event Sources
45+
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
48+
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.
51+
- [`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)
52+
is refactored, but the changes are trivial.
53+

0 commit comments

Comments
 (0)