Skip to content

Commit bc9d0a9

Browse files
csvirimetacosm
andauthored
docs: skip reconcile of a DR (#2732)
Signed-off-by: Attila Mészáros <[email protected]> Signed-off-by: Chris Laprun <[email protected]> Co-authored-by: Chris Laprun <[email protected]>
1 parent 94bf820 commit bc9d0a9

File tree

1 file changed

+37
-6
lines changed

1 file changed

+37
-6
lines changed

docs/content/en/docs/faq/_index.md

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: FAQ
33
weight: 80
44
---
55

6-
### Q: How can I access the events which triggered the Reconciliation?
6+
### How can I access the events which triggered the Reconciliation?
77

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

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

2121
Yes, this can be done
2222
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)
@@ -46,7 +46,7 @@ without an update:
4646
Although you might consider using `EventSources`, to handle reconciliation triggering in a smarter
4747
way.
4848

49-
### Q: How can I run an operator without cluster scope rights?
49+
### How can I run an operator without cluster scope rights?
5050

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

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

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

9393
Dependent Resources feature supports the [first approach](../dependent-resources/_index.md#external-state-tracking-dependent-resources).
94+
95+
### How can I skip the reconciliation of a dependent resource?
9496

95-
### Q: How to fix `sun.security.provider.certpath.SunCertPathBuilderException` on Rancher Desktop and k3d/k3s Kubernetes
97+
Skipping workflow reconciliation altogether is possible with the explicit invocation feature since v5.
98+
You can read more about this in [v5 release notes](https://javaoperatorsdk.io/blog/2025/01/06/version-5-released/#explicit-workflow-invocation).
99+
100+
However, what if you want to avoid reconciling a single dependent resource based on some state?
101+
First of all, remember that the dependent resource won't be modified if the desired state and the actual state match.
102+
Moreover, it is generally a good practice to reconcile all your resources, JOSDK taking care of only processing the
103+
resources which state doesn't match the desired one.
104+
However, in some corner cases (for example, if it is expensive to compute the desired state or compare it to the actual
105+
state), it is somtimes useful to be able to only skip the reconcilation of some resources but not all, if it is known
106+
that they don't need to be processed based for example on the status of the custom resource.
107+
108+
A common mistake is to use `ReconcilePrecondition`, if the condition does not hold it will delete the resources.
109+
This is by design (although it's true that the name of this condition might be misleading), but not what we want in this
110+
case.
111+
112+
The way to go is to override the matcher in the dependent resource:
113+
114+
```java
115+
public Result<R> match(R actualResource, R desired, P primary, Context<P> context) {
116+
if (alreadyIsCertainState(primary.getStatus())) {
117+
return true;
118+
} else {
119+
return super.match(actual, desired, primary, context);
120+
}
121+
}
122+
```
123+
124+
This will make sure that the dependent resource is not updated if the primary resource is in certain state.
125+
126+
### How to fix `sun.security.provider.certpath.SunCertPathBuilderException` on Rancher Desktop and k3d/k3s Kubernetes
96127

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

@@ -111,4 +142,4 @@ the following dependency on the classpath:
111142
<groupId>org.bouncycastle</groupId>
112143
<artifactId>bcpkix-jdk15on</artifactId>
113144
</dependency>
114-
```
145+
```

0 commit comments

Comments
 (0)