From bff17d74354c336375815119486818568df204ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20M=C3=A9sz=C3=A1ros?= Date: Wed, 29 Jul 2026 18:18:25 +0200 Subject: [PATCH] fix: use the cached desired state when selecting an external secondary resource `AbstractExternalDependentResource.selectTargetSecondaryResource` called `desired(primary, context)` directly instead of going through `getOrComputeDesired(context)`. `getOrComputeDesired` exists precisely so that `desired` is invoked at most once per reconciliation; its javadoc states that the SDK should call it exclusively and that `desired` should never be called directly, because this "supports scenarios where idempotent computation of the desired state is not feasible". Calling `desired` directly here means it is computed an extra time on every reconciliation of an external dependent resource: once to pick the target secondary and again from `match`/`reconcile` via the cache. That is wasted work in all cases, and produces an inconsistent desired state for any implementation whose `desired` is not idempotent - exactly the case the cache is there to support. `KubernetesDependentResource` already routes through `getOrComputeDesired` via `targetSecondaryResourceID`; this brings the external variant in line. No unit test is added: the code path is only covered by the external dependent integration tests under `operator-framework`, which need a cluster. --- .../processing/dependent/AbstractExternalDependentResource.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/AbstractExternalDependentResource.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/AbstractExternalDependentResource.java index c391092422..9a2847bcc0 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/AbstractExternalDependentResource.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/AbstractExternalDependentResource.java @@ -126,7 +126,7 @@ protected InformerEventSource getExternalStateEventSource() { @Override protected Optional selectTargetSecondaryResource( Set secondaryResources, P primary, Context

context) { - R desired = desired(primary, context); + R desired = getOrComputeDesired(context); List targetResources; var desiredID = resourceIDMapper.idFor(desired); targetResources =