Description
Is your feature request related to a problem?
We are currently in the middle of migrating from JOSDK 4 to JOSDK 5.
For us it's always crucial that the CustomResource status passed to the main reconciliation loop is the most up-to-date one.
As a best practice, our operator does not manipulate/modify anything in the CustomResource other than the status, which is afterwards used in the next reconciliations to potentially trigger a particular action to act upon based on that status (such as rolling restart of the pods for example).
So what we have just noticed is that when migrating from the JOSDK 4 to JOSDK 5, this is no longer the case as we have experienced so far that sometimes this CustomResource status is outdated. Apparently there might be some informers that triggered the reconciliation loop with an old version of the CustomResource status in the cache.
And it seems that this was handled and cached internally in the JOSDK 4 here, but got removed in the JOSDK 5.
Describe the solution you'd like
I guess, there might be a couple of possible options here:
- JOSDK 5 to provide with an new API option so we can for instance decide whether we want to update the underlying primary cache with the most up-to-date CustomResource status. For example
UpdateControl.forceCacheUpdate().patchStatus(platform); <-- only updates the status in cache
UpdateControl.forceCacheUpdate().patchResource(platform); <-- only updates the spec in cache
UpdateControl.forceCacheUpdate().patchResourceAndStatus(platform) <-- updates both in cache
- An option to enable an internal caching mechanism similarly to what was done in the JOSDK 4.
Describe alternatives you've considered
Since our operator only modify the CustomResource status, at the moment we are just updating the primary cache with the CustomResource status change in every reconciliation loop (nothing else, no Metadata, no Spec change updated in this cache).
private static void updateCache(
MyCustomResource primary,
Context<MyCustomResource> context) {
final var cache = context.getPrimaryCache();
cache.get(new ResourceID(primary.getMetadata().getName(), primary.getMetadata().getNamespace()))
.ifPresent(r -> r.setStatus(primary.getStatus()));
}
Additional context
N/A.