Skip to content

Commit 3836ab0

Browse files
metacosmcsviri
andauthored
docs: review and improve docs (#1331)
Also simplify WorkflowBuilder. Co-authored-by: Attila Mészáros <csviri@gmail.com>
1 parent ba3e26e commit 3836ab0

File tree

18 files changed

+1120
-901
lines changed

18 files changed

+1120
-901
lines changed

docs/documentation/architecture-and-internals.md

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,62 @@ permalink: /docs/architecture-and-internals
77

88
# Architecture and Internals
99

10-
This document gives an overview of the internal structure and components of Java Operator SDK core, in order to make it
11-
easier for developers to understand and contribute to it. However, this is just an extract of the backbone of the core
12-
module, but other parts should be fairly easy to understand. We will maintain this document on developer feedback.
10+
This document gives an overview of the internal structure and components of Java Operator SDK core,
11+
in order to make it easier for developers to understand and contribute to it. This document is
12+
not intended to be a comprehensive reference, rather an introduction to the core concepts and we
13+
hope that the other parts should be fairly easy to understand. We will evolve this document
14+
based on the community's feedback.
1315

1416
## The Big Picture and Core Components
1517

16-
![Alt text for broken image link](../assets/images/architecture.svg)
18+
![JOSDK architecture](../assets/images/architecture.svg)
1719

18-
[Operator](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/Operator.java)
20+
An [Operator](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/Operator.java)
1921
is a set of
2022
independent [controllers](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/Controller.java)
21-
. Controller however, is an internal class managed by the framework itself. It encapsulates directly or indirectly all
22-
the processing units for a single custom resource. Other components:
23+
.
24+
The `Controller` class, however, is an internal class managed by the framework itself and
25+
usually shouldn't interacted with directly by end users. It
26+
manages all the processing units involved with reconciling a single type of Kubernetes resource.
2327

28+
Other components include:
29+
30+
- [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)
31+
is the primary entry-point for the developers of the framework to implement the reconciliation
32+
logic.
33+
- [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)
34+
represents a source of events that might eventually trigger a reconciliation.
2435
- [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)
25-
aggregates all the event sources regarding a controller. Provides starts and stops the event sources.
36+
aggregates all the event sources associated with a controller. Manages the event sources'
37+
lifecycle.
2638
- [ControllerResourceEventSource](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/controller/ControllerResourceEventSource.java)
27-
is a central event source that watches the controller related custom resource for changes, propagates events and
28-
caches the state of the custom resources. In the background from V2 it uses Informers.
39+
is a central event source that watches the resources associated with the controller (also
40+
called primary resources) for changes, propagates events and caches the related state.
2941
- [EventProcessor](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/EventProcessor.java)
30-
processes the incoming events. Implements execution serialization. Manages the executor service for execution. Also
31-
implements the post-processing of after the reconciler was executed, like re-schedules and retries of events.
42+
processes the incoming events and makes sure they are executed in a sequential manner, that is
43+
making sure that the events are processed in the order they are received for a given resource,
44+
despite requests being processed concurrently overall. The `EventProcessor` also takes care of
45+
re-scheduling or retrying requests as needed.
3246
- [ReconcilerDispatcher](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/ReconciliationDispatcher.java)
33-
is responsible for managing logic around reconciler execution, deciding which method should be called of the
34-
reconciler, managing the result
35-
(UpdateControl and DeleteControl), making the instructed Kubernetes API calls.
36-
- [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)
37-
is the primary entry-point for the developers of the framework to implement the reconciliation logic.
47+
is responsible for dispatching requests to the appropriate `Reconciler` method and handling
48+
the reconciliation results, making the instructed Kubernetes API calls.
3849

3950
## Typical Workflow
4051

4152
A typical workflows looks like following:
4253

43-
1. An EventSource produces and event, that is propagated to the event processor.
44-
2. In the event processor the related `CustomResource` is read from the cache based on the `ResourceID` in the event.
45-
3. If there is no other execution running for the custom resource, an execution is submitted for the executor (thread
46-
pool) .
47-
4. Executor calls ReconcilerDispatcher which decides which method to execute of the reconciler. Let's say in this case it
48-
was `reconcile(...)`
49-
5. After reconciler execution the Dispatcher calls Kubernetes API server, since the `reconcile` method returned
50-
with `UpdateControl.patchStatus(...)` result.
51-
6. Now the dispatcher finishes the execution and calls back `EventProcessor` to finalize the execution.
52-
7. EventProcessor checks if there is no `reschedule` or `retry` required and if there are no subsequent events received
53-
for the custom resource
54-
8. Neither of this happened, therefore the event execution finished.
54+
1. An `EventSource` produces an event, that is propagated to the `EventProcessor`.
55+
2. The resource associated with the event is read from the internal cache.
56+
3. If the resource is not already being processed, a reconciliation request is
57+
submitted to the executor service to be executed in a different thread, encapsulated in a
58+
`ControllerExecution` instance.
59+
4. This, in turns, calls the `ReconcilerDispatcher` which dispatches the call to the appropriate
60+
`Reconciler` method, passing along all the required information.
61+
5. Once the `Reconciler` is done, what happens depends on the result returned by the
62+
`Reconciler`. If needed, the `ReconcilerDispatcher` will make the appropriate calls to the
63+
Kubernetes API server.
64+
6. Once the `Reconciler` is done, the `EventProcessor` is called back to finalize the
65+
execution and update the controller's state.
66+
7. The `EventProcessor` checks if the request needs to be rescheduled or retried and if there are no
67+
subsequent events received for the same resource.
68+
8. When none of this happens, the processing of the event is finished.

docs/documentation/contributing.md

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ description: Contributing To Java Operator SDK
44
layout: docs
55
permalink: /docs/contributing
66
---
7+
78
# Contributing To Java Operator SDK
89

9-
Firstly, big thanks for considering contributing to the project. We really hope to make this into a
10-
community project and to do that we need your help!
10+
First of all, we'd like to thank you for considering contributing to the project! We really
11+
hope to create a vibrant community around this project but this won't happen without help from
12+
people like you!
1113

1214
## Code of Conduct
1315

@@ -16,21 +18,24 @@ aggressive or insulting behaviour.
1618

1719
To this end, the project and everyone participating in it is bound by the [Code of
1820
Conduct]({{baseurl}}/coc). By participating, you are expected to uphold this code. Please report
19-
unacceptable behaviour to any of the project admins or adam.sandor@container-solutions.com.
21+
unacceptable behaviour to any of the project admins.
2022

2123
## Bugs
2224

23-
If you find a bug, please [open an issue](https://github.com/java-operator-sdk/java-operator-sdk/issues)! Do try
25+
If you find a bug,
26+
please [open an issue](https://github.com/java-operator-sdk/java-operator-sdk/issues)! Do try
2427
to include all the details needed to recreate your problem. This is likely to include:
2528

26-
- The version of the Operator SDK being used
27-
- The exact platform and version of the platform that you're running on
28-
- The steps taken to cause the bug
29+
- The version of the Operator SDK being used
30+
- The exact platform and version of the platform that you're running on
31+
- The steps taken to cause the bug
32+
- Reproducer code is also very welcome to help us diagnose the issue and fix it quickly
2933

3034
## Building Features and Documentation
3135

3236
If you're looking for something to work on, take look at the issue tracker, in particular any items
33-
labelled [good first issue](https://github.com/java-operator-sdk/java-operator-sdk/labels/good%20first%20issue).
37+
labelled [good first issue](https://github.com/java-operator-sdk/java-operator-sdk/labels/good%20first%20issue)
38+
.
3439
Please leave a comment on the issue to mention that you have started work, in order to avoid
3540
multiple people working on the same issue.
3641

@@ -42,18 +47,19 @@ discussing it first to avoid wasting effort. We do commit to listening to all pr
4247
our best to work something out!
4348

4449
Once you've got the go ahead to work on a feature, you can start work. Feel free to communicate with
45-
team via updates on the issue tracker or the [Discord channel](https://discord.gg/DacEhAy) and ask for feedback, pointers etc.
46-
Once you're happy with your code, go ahead and open a Pull Request.
50+
team via updates on the issue tracker or the [Discord channel](https://discord.gg/DacEhAy) and ask
51+
for feedback, pointers etc. Once you're happy with your code, go ahead and open a Pull Request.
4752

4853
## Pull Request Process
4954

50-
First, please format your commit messages so that they follow the [conventional commit](https://www.conventionalcommits.org/en/v1.0.0/) format.
55+
First, please format your commit messages so that they follow
56+
the [conventional commit](https://www.conventionalcommits.org/en/v1.0.0/) format.
5157

5258
On opening a PR, a GitHub action will execute the test suite against the new code. All code is
53-
required to pass the tests, and new code must be accompanied by new tests.
59+
required to pass the tests, and new code must be accompanied by new tests.
5460

55-
All PRs have to be reviewed and signed off by another developer before being merged to the master
56-
branch. This review will likely ask for some changes to the code - please don't be alarmed or upset
61+
All PRs have to be reviewed and signed off by another developer before being merged. This review
62+
will likely ask for some changes to the code - please don't be alarmed or upset
5763
at this; it is expected that all PRs will need tweaks and a normal part of the process.
5864

5965
The PRs are checked to be compliant with the Java Google code style.
@@ -64,12 +70,15 @@ Be aware that all Operator SDK code is released under the [Apache 2.0 licence](L
6470

6571
### Code style
6672

67-
The SDK modules and samples are formatted to follow the Java Google code style.
68-
On every `compile` the code gets formatted automatically,
69-
however, to make things simpler (i.e. avoid getting a PR rejected simply because of code style issues), you can import one of the following code style schemes based on the IDE you use:
73+
The SDK modules and samples are formatted to follow the Java Google code style.
74+
On every `compile` the code gets formatted automatically, however, to make things simpler (i.e.
75+
avoid getting a PR rejected simply because of code style issues), you can import one of the
76+
following code style schemes based on the IDE you use:
7077

71-
- for *Intellij IDEA* import [contributing/intellij-google-style.xml](contributing/intellij-google-style.xml)
72-
- for *Eclipse* import [contributing/eclipse-google-style.xml](contributing/eclipse-google-style.xml)
78+
- for *Intellij IDEA*
79+
import [contributing/intellij-google-style.xml](contributing/intellij-google-style.xml)
80+
- for *Eclipse*
81+
import [contributing/eclipse-google-style.xml](contributing/eclipse-google-style.xml)
7382

7483
## Thanks
7584

0 commit comments

Comments
 (0)