Repository navigation
Conversation
Applying the desired state aspects inside computeIfAbsent failed with "Recursive update" when an aspect looked up the actual resource of the dependent (same key) or of another dependent whose key landed in the same bin. Compute with a lock per dependent instead, and hand the thread already computing a desired state the state as it is so far. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
There was a problem hiding this comment.
🟡 Changes recommended
Concurrent reciprocal resource lookups can deadlock on per-dependent locks, causing reconciliation to hang indefinitely.
1 open issue
What changed in this PR
This PR addresses recursive-update failures when desired-state aspects look up dependent resources during reconciliation.
Changes:
- Moves desired-state computation outside
ConcurrentHashMap.computeIfAbsent, using per-dependent locks. - Returns the in-progress desired state for same-thread aspect re-entry.
- Adds tests for self-lookups, cross-dependent lookups with colliding hashes, and cached desired-state reuse.
| File | Description |
|---|---|
operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/dependent/DesiredStateAspectReentrancyTest.java |
Adds reentrancy and desired-state caching regression tests. |
operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/DefaultContext.java |
Introduces per-dependent locking and in-progress desired-state tracking. |
Review effort: Balanced
| final var lock = | ||
| desiredStateLocks.computeIfAbsent(dependentResource, ignored -> new ReentrantLock()); | ||
| lock.lock(); |

Applying the desired state aspects inside computeIfAbsent failed with
"Recursive update" when an aspect looked up the actual resource of the
dependent (same key) or of another dependent whose key landed in the same
bin. Compute with a lock per dependent instead, and hand the thread already
computing a desired state the state as it is so far.
Co-Authored-By: Claude Sonnet 5.5 noreply@anthropic.com