Skip to content

refactor: Extract apply and update status steps - #872

Open
maltesander wants to merge 3 commits into
mainfrom
refactor/apply-and-status-steps
Open

refactor: Extract apply and update status steps#872
maltesander wants to merge 3 commits into
mainfrom
refactor/apply-and-status-steps

Conversation

@maltesander

Copy link
Copy Markdown
Member

Description

  • extracts an apply step (controller/apply.rs) with an Applier, which owns the ClusterResources, applies every resource kind and deletes orphaned resources
  • extracts an update status step (controller/update_status.rs), which computes the OpaClusterStatus from the applied resources
  • adds a type state marker to KubernetesResources (Prepared, Applied), so update_status can only be called with resources that were actually applied, not merely built. Applier::apply destructures KubernetesResources without a rest pattern, so a new resource kind fails to compile instead of silently never being applied.
  • moves the legacy "opacluster" field manager patch (Automatically migrate container name 23.1 -> 23.4 #444) into a private method on the Applier, running against the applied DaemonSets. Only the name and namespace are read from those objects, so this is equivalent to the previous behaviour.

Definition of Done Checklist

  • Not all of these items are applicable to all PRs, the author should update this template to only leave the boxes in that are relevant
  • Please make sure all these things are done and tick the boxes

Author

  • Changes are OpenShift compatible
  • CRD changes approved
  • CRD documentation for all fields, following the style guide.
  • Helm chart can be installed and deployed operator works
  • Integration tests passed (for non trivial changes)
  • Changes need to be "offline" compatible
  • Links to generated (nightly) docs added
  • Release note snippet added

Reviewer

  • Code contains useful comments
  • Code contains useful logging statements
  • (Integration-)Test cases added
  • Documentation added or updated. Follows the style guide.
  • Changelog updated
  • Cargo.toml only contains references to git tags (not specific commits or branches)

Acceptance

  • Feature Tracker has been updated
  • Proper release label has been added
  • Links to generated (nightly) docs added
  • Release note snippet added
  • Add type/deprecation label & add to the deprecation schedule
  • Add type/experimental label & add to the experimental features tracker

Moves resource application and status computation out of the reconcile
function and into dedicated controller/apply.rs and
controller/update_status.rs modules, following the same shape as the
airflow (#828) and hbase (#787) operators. reconcile_opa is now just
validate, build, apply, update_status.

KubernetesResources gains a type-state marker (Prepared, Applied), so
update_status can only be called with resources that were actually
applied, not merely built. Applier::apply destructures
KubernetesResources without a rest pattern, so a new resource kind
fails to compile instead of silently never being applied.

The legacy "opacluster" field manager patch (see #444) becomes a
private method on the Applier, running against the applied DaemonSets.
Only the name and namespace are read from those objects, so this is
equivalent to the previous behaviour.

Note that delete_orphaned_resources now runs before the status patch
instead of after it, matching the template operators.
@maltesander maltesander self-assigned this Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant