Skip to content

fix: desired state aspects - #3667

Closed
csviri wants to merge 2 commits into
nextfrom
fix/desired-state-aspects
Closed

csviri wants to merge 2 commits into
nextfrom
fix/desired-state-aspects

Conversation

@csviri

@csviri csviri commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes in how the desired state aspects are applied, found while reviewing the virtual thread support PR (#3664) and extracted from it.

1. No more Recursive update when an aspect looks up the actual resource

DefaultContext#getOrComputeDesiredStateFor applied the aspects inside ConcurrentHashMap.computeIfAbsent. A DesiredStateAspect that looks up the actual resource of its dependent asks for the desired state that is being computed, which re-entered the map on the same key. Looking up the actual resource of another dependent could do the same when its key landed in the same bin. Both failed with IllegalStateException: Recursive update.

The desired state is now computed outside of the map:

  • a lock per dependent makes sure it is computed once, also when several threads ask for it
  • the thread that is computing a desired state is handed the state as it is so far when it asks for it again, instead of re-entering the computation

2. Aspects of a bulk dependent receive the dependent the user configured

For a bulk dependent resource the framework creates a stand-in dependent per resource, and that stand-in was handed to the aspects. The aspects now receive the bulk dependent the user configured, through a new getOrComputeDesiredStateFor(dependentResource, aspectTarget, desiredStateComputer) overload used by BulkDependentResourceReconciler.

3. A missing controller configuration is tolerated

The aspects are skipped when the context has no controller configuration, instead of failing with a NullPointerException, which is the case for contexts created outside of a controller, for example in unit tests.

Tests

  • DesiredStateAspectReentrancyTest: an aspect looking up the actual resource of its own dependent and of another dependent, and the desired state being computed once.
  • DesiredStateAspectAuditTest: the bulk dependent receiving the user's bulk dependent resource, the lookup of the actual resource, and computing the desired state without an aspect configuration.

csviri and others added 2 commits October 28, 2026 10:30
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>
…er configuration

Hand the user's bulk dependent, rather than the stand-in the framework creates per resource, to the
desired state aspects, and skip the aspects if the context has no controller configuration.
@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 29, 2026
@coderabbitai

coderabbitai Bot commented Oct 29, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@csviri csviri changed the title Fix/desired state aspects fix: desired state aspects Oct 30, 2026
@csviri csviri closed this Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant