Skip to content

refactor: Extract apply and update_status steps - #923

Merged
maltesander merged 6 commits into
mainfrom
refactor/extract-apply-and-status-steps
Aug 12, 2026
Merged

refactor: Extract apply and update_status steps#923
maltesander merged 6 commits into
mainfrom
refactor/extract-apply-and-status-steps

Conversation

@maltesander

@maltesander maltesander commented Aug 5, 2026

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
adwk67
adwk67 previously approved these changes Aug 12, 2026

@adwk67 adwk67 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - just 2 minor things which I'll leave up to you.

--- PASS: kuttl (1167.79s)
    --- PASS: kuttl/harness (0.00s)
        --- PASS: kuttl/harness/smoke_trino-481_hive-4.2.0_opa-latest-1.16.2_hdfs-3.5.0_zookeeper-3.9.5_openshift-false (1167.78s)
PASS

Comment thread rust/operator-binary/src/controller/apply.rs
Comment thread rust/operator-binary/src/controller/update_status.rs Outdated
Use a dedicated CreateSpoolingSecret error variant instead of reusing
CreateInternalSecret for both shared secrets, and let update_status
consume the applied resources to avoid cloning the StatefulSets and to
signal that it is the end of the reconciliation pipeline.
@maltesander
maltesander added this pull request to the merge queue Aug 12, 2026
Merged via the queue into main with commit 0ed1bc6 Aug 12, 2026
18 checks passed
@maltesander
maltesander deleted the refactor/extract-apply-and-status-steps branch August 12, 2026 11:56
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.

2 participants