Skip to content

docs: skip reconcile of a DR #2732

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 3 commits into from
Mar 13, 2025
Merged
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
43 changes: 37 additions & 6 deletions docs/content/en/docs/faq/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: FAQ
weight: 80
---

### Q: How can I access the events which triggered the Reconciliation?
### How can I access the events which triggered the Reconciliation?

In the v1.* version events were exposed to `Reconciler` (which was called `ResourceController`
then). This included events (Create, Update) of the custom resource, but also events produced by
Expand All @@ -16,7 +16,7 @@ sound agreement between the developers that this is the way to go.
Note that this is also consistent with Kubernetes
[level based](https://cloud.redhat.com/blog/kubernetes-operators-best-practices) reconciliation approach.

### Q: Can I re-schedule a reconciliation, possibly with a specific delay?
### Can I re-schedule a reconciliation, possibly with a specific delay?

Yes, this can be done
using [`UpdateControl`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/UpdateControl.java)
Expand Down Expand Up @@ -46,7 +46,7 @@ without an update:
Although you might consider using `EventSources`, to handle reconciliation triggering in a smarter
way.

### Q: How can I run an operator without cluster scope rights?
### How can I run an operator without cluster scope rights?

By default, JOSDK requires access to CRs at cluster scope. You may not be granted such
rights and you will see some error at startup that looks like:
Expand Down Expand Up @@ -74,7 +74,7 @@ is `true` (`false` by default). To disable, set it to `false` at [Operator-level
Operator operator = new Operator( override -> override.checkingCRDAndValidateLocalModel(false));
```

### Q: I'm managing an external resource that has a generated ID, where should I store that?
### I'm managing an external resource that has a generated ID, where should I store that?

It is common that a non-Kubernetes or external resource is managed from a controller. Those external resources might
have a generated ID, so are not simply addressable based on the spec of a custom resources. Therefore, the
Expand All @@ -91,8 +91,39 @@ it is not guaranteed that during the next reconciliation you will see the fresh
which do this, usually cache the updated status in memory to make sure it is present for next reconciliation.

Dependent Resources feature supports the [first approach](../dependent-resources/_index.md#external-state-tracking-dependent-resources).

### How can I skip the reconciliation of a dependent resource?

### Q: How to fix `sun.security.provider.certpath.SunCertPathBuilderException` on Rancher Desktop and k3d/k3s Kubernetes
Skipping workflow reconciliation altogether is possible with the explicit invocation feature since v5.
You can read more about this in [v5 release notes](https://javaoperatorsdk.io/blog/2025/01/06/version-5-released/#explicit-workflow-invocation).

However, what if you want to avoid reconciling a single dependent resource based on some state?
First of all, remember that the dependent resource won't be modified if the desired state and the actual state match.
Moreover, it is generally a good practice to reconcile all your resources, JOSDK taking care of only processing the
resources which state doesn't match the desired one.
However, in some corner cases (for example, if it is expensive to compute the desired state or compare it to the actual
state), it is somtimes useful to be able to only skip the reconcilation of some resources but not all, if it is known
that they don't need to be processed based for example on the status of the custom resource.

A common mistake is to use `ReconcilePrecondition`, if the condition does not hold it will delete the resources.
This is by design (although it's true that the name of this condition might be misleading), but not what we want in this
case.

The way to go is to override the matcher in the dependent resource:

```java
public Result<R> match(R actualResource, R desired, P primary, Context<P> context) {
if (alreadyIsCertainState(primary.getStatus())) {
return true;
} else {
return super.match(actual, desired, primary, context);
}
}
```

This will make sure that the dependent resource is not updated if the primary resource is in certain state.

### How to fix `sun.security.provider.certpath.SunCertPathBuilderException` on Rancher Desktop and k3d/k3s Kubernetes

It's a common issue when using k3d and the fabric8 client tries to connect to the cluster an exception is thrown:

Expand All @@ -111,4 +142,4 @@ the following dependency on the classpath:
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
</dependency>
```
```