Skip to content

refactor: Extract apply and update_status steps - #923

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

refactor: Extract apply and update_status steps#923
maltesander wants to merge 4 commits into
mainfrom
refactor/extract-apply-and-status-steps

Conversation

@maltesander

Copy link
Copy Markdown
Member

Description

Completes the dereference -> validate -> build -> apply -> update_status pipeline.

  • KubernetesResources is now generic over a Prepared/Applied marker, so the
    compiler enforces that the cluster status is derived from the resources the API
    server acknowledged
  • new controller::apply with an Applier, which also takes over
    ensure_random_secrets (a read-or-create client operation, deliberately kept out
    of ClusterResources so orphan deletion never removes it)
  • new controller::update_status

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

Makes `KubernetesResources` generic over a marker type that records how far
the resources have travelled through the reconcile pipeline. The build step
now returns `KubernetesResources<Prepared>`.

This prepares the extraction of the apply and update_status steps: once an
`Applied` marker exists, the type system can enforce that the cluster status
is derived from the resources the API server returned, and not from the ones
that were merely built.
Moves the resource application out of `reconcile_trino` into a dedicated
`controller::apply` module. The `Applier` owns the `ClusterResources` and
turns `KubernetesResources<Prepared>` into `KubernetesResources<Applied>`,
so later steps can require resources that Kubernetes actually acknowledged.

`ensure_random_secrets` moves along, since it is a read-or-create client
operation that cannot live in the client free build step. It stays outside
`ClusterResources` on purpose, so orphan deletion never removes it and an
existing Secret is never overwritten.

The apply order is unchanged. Orphaned resources are now deleted before the
status is patched instead of after, which matches the sibling operators.
Moves the cluster status computation out of `reconcile_trino` into a
dedicated `controller::update_status` module. It accepts only
`KubernetesResources<Applied>`, so the type system enforces that the
conditions are derived from the resources the API server acknowledged and
not from the ones that were merely built.
@maltesander maltesander self-assigned this Aug 5, 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