Skip to content

V2 migration #717

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 6 commits into from
Nov 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ by [operator-sdk](https://github.com/operator-framework/operator-sdk).

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

**!! NOTE the main branch now contains source code for v2, which is under development, for actual
version see [v1 branch](https://github.com/java-operator-sdk/java-operator-sdk/tree/v1) !!**

Table of Contents
==========

Expand Down
2 changes: 2 additions & 0 deletions docs/_data/sidebar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@
url: /docs/faq
- title: Contributing
url: /docs/contributing
- title: Migrating from v1 to v2
url: /docs/v2-migration

4 changes: 2 additions & 2 deletions docs/documentation/patterns-best-practices.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ of Java Operator SDK.

## Implementing a Controller

### Sync of Async Way of Resource Handling

### Idempotency

### Sync of Async Way of Resource Handling

## Why to Have Automated Retries?

## Managing State
Expand Down
2 changes: 1 addition & 1 deletion docs/documentation/use-samples.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ The Controller implements the business logic and describes all the classes neede

```java

@Controller
@ControllerConfiguration
public class WebServerController implements Reconciler<WebServer> {

// Return the changed resource, so it gets updated. See javadoc for details.
Expand Down
53 changes: 53 additions & 0 deletions docs/documentation/v2-migration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
title: Migrating from v1 to v2
description: Migrating from v1 to v2
layout: docs
permalink: /docs/v2-migration
---

# Migrating from v1 to v2

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

## User Facing API Changes

The following items are renamed and slightly changed:

- [`ResourceController`](https://github.com/java-operator-sdk/java-operator-sdk/blob/v1/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/ResourceController.java)
interface is renamed
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)
. In addition, methods:
- `createOrUpdate` renamed to `reconcile`
- `delete` renamed to `cleanup`
- Events are removed from
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)
of `Reconciler` methods . The rationale behind this, is that there is a consensus now on the pattern that the events
should not be used to implement a reconciliation logic.
- The `init` method is extracted from `ResourceController` / `Reconciler` to a separate interface
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)
that `Reconcile` should implement in order to register event sources. See
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)
for usage. Here also
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)
is renamed
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)
, and it's interface refined.
- [`@Controller`](https://github.com/java-operator-sdk/java-operator-sdk/blob/v1/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/Controller.java)
annotation renamed
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)

### Event Sources

- Addressing resources within event sources (and in the framework internally) is now changed from `.metadata.uid` to a
pair of `.metadata.name` and optional `.metadata.namespace` of resource. Represented
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)
- 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)
API is simplified. Now if an event source produces an event it needs to just produce an instance of this class.
- [`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)
is refactored, but the changes are trivial.