You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/en/docs/documentation/reconciler.md
+9-85Lines changed: 9 additions & 85 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -182,16 +182,12 @@ require the latest status version possible, for example, if the status subresour
182
182
See [Representing Allocated Values](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#representing-allocated-values)
183
183
from the Kubernetes docs for more details.
184
184
185
-
The framework provides utilities to help with these use cases with
185
+
The framework provides utilities to help with these use cases:
var updatedResource =PrimaryUpdateAndCacheUtils.ssaPatchStatusAndCacheResourceWithLock(resource, freshCopy, context);
203
+
var updatedResource =PrimaryUpdateAndCacheUtils.ssaPatchStatusAndCacheResource(resource, freshCopy, context);
208
204
209
205
returnUpdateControl.noUpdate();
210
206
}
211
207
```
212
208
213
-
After the update `PrimaryUpdateAndCacheUtils.ssaPatchStatusAndCacheResourceWithLock` puts the result of the update into an internal
214
-
cache and will the framework will make sure that the next reconciliation will contain the most recent version of the resource.
209
+
After the update `PrimaryUpdateAndCacheUtils.ssaPatchStatusAndCacheResource` puts the response of the update into an internal
210
+
cache and the framework will make sure that the next reconciliation will contain the most recent version of the resource.
215
211
Note that it is not necessarily the version of the resource you got as response from the update, it can be newer since other parties
216
-
can do additional updates meanwhile, but if not explicitly modified, it will contain the up-to-date status.
217
-
218
-
See related integration test [here](https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/statuscache/internalwithlock).
219
-
220
-
This approach works with the default configuration of the framework and should be good to go in most of the cases.
221
-
222
-
Without going further into the details, a bit more experimental way we provide overloaded methods without optimistic locking,
223
-
to use those you have to set `ConfigurationService.parseResourceVersionsForEventFilteringAndCaching`
224
-
to `true`. This in practice would mean that request won't fail on optimistic locking, but requires bending a bit
225
-
the rules regarding Kubernetes API contract. This might be needed only if you have multiple resources frequently
226
-
writing the resource.
227
-
228
-
#### Fallback approach: using `PrimaryResourceCache` cache
229
-
230
-
For the sake of completeness, we also provide a more explicit approach to manage the cache yourself.
231
-
This approach has the advantage that you don't have to do neither optimistic locking nor
232
-
setting the `parseResourceVersionsForEventFilteringAndCaching` to `true`:
233
-
234
-
```java
235
-
236
-
// We on purpose don't use the provided predicate to show what a custom one could look like.
is designed for this purpose. As shown in the example above, it is up to you to provide a predicate to determine if the
277
-
resource is more recent than the one available. In other words, when to evict the resource from the cache. Typically, as
278
-
shown in
279
-
the [integration test](https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/statuscache/primarycache)
280
-
you can have a counter in status to check on that.
281
-
282
-
Since all of this happens explicitly, you cannot use this approach for managed dependent resources and workflows and
283
-
will need to use the unmanaged approach instead. This is due to the fact that managed dependent resources always get
284
-
their associated primary resource from the underlying informer event source cache.
212
+
can do additional updates meanwhile. However, if not explicitly modified, it will contain the up-to-date resource.
285
213
286
-
#### Additional remarks
214
+
See related integration test [here](https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/statuscache).
287
215
288
-
As shown in the last two cases, there is no optimistic locking used when updating the
(in other words `metadata.resourceVersion` is set to `null`). This has nice property the request will be successful.
291
-
However, it might be desirable to configure retry on [Fabric8 client](https://github.com/fabric8io/kubernetes-client?tab=readme-ov-file#configuring-the-client).
0 commit comments