Skip to content

Migrate HypervisorMaintenanceController to SSA (status + eviction creation)#339

Open
fwiesel wants to merge 2 commits into
ssa-conditions-helpersfrom
ssa-hypervisor-maintenance
Open

Migrate HypervisorMaintenanceController to SSA (status + eviction creation)#339
fwiesel wants to merge 2 commits into
ssa-conditions-helpersfrom
ssa-hypervisor-maintenance

Conversation

@fwiesel

@fwiesel fwiesel commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Two commits, both for HypervisorMaintenanceController:

1. Migrate HypervisorMaintenanceController to SSA status updates

Replace PatchHypervisorStatusWithRetry with Status().Apply() for ConditionTypeHypervisorDisabled, ConditionTypeEvicting, and the Evicted scalar. ConditionTypeEvicting is removed by omitting it from the apply — SSA prunes map-list entries no longer claimed by the sole owner.

The status config is built once in Reconcile and passed to reconcileComputeService and reconcileEviction which mutate it directly. This eliminates intermediate condition return values and makes the single-apply-per-reconcile explicit. The early-return guard for already-enabled/disabled state is inlined into each branch.

Seed only the conditions owned by this controller so SSA does not claim ownership over conditions written by others. For the delete-by-omission case, owned conditions are seeded selectively so the target condition is simply absent from the payload.

Also clear the forced_down flag when enabling a compute service so an earlier HA event that set forced_down=true does not leave the service reachable but treated as down.

SetupWithManager now delegates to registerWithManager instead of inlining the same ctrl.NewControllerManagedBy call, which had left registerWithManager unreachable.

2. Migrate HypervisorMaintenanceController Eviction creation to SSA

Replace Create + SetControllerReference with Apply for the Eviction CR. The owner reference and labels are set in the apply configuration metadata, and SSA handles the upsert. A Get is still performed after the apply to read the current eviction status conditions.

Depends on #335 (ssa-conditions-helpers).

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7bdbcfd0-1560-49c5-a108-b2075d80cb57

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ssa-hypervisor-maintenance

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@fwiesel

fwiesel commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@fwiesel fwiesel force-pushed the ssa-hypervisor-maintenance branch from b0ce964 to 1468c0b Compare July 13, 2026 14:52
fwiesel added 2 commits July 13, 2026 21:54
Replace PatchHypervisorStatusWithRetry with Status().Apply() for
ConditionTypeHypervisorDisabled, ConditionTypeEvicting, and the
Evicted scalar. ConditionTypeEvicting is removed by omitting it from
the apply — SSA prunes map-list entries no longer claimed by the sole
owner.

The status config is built once in Reconcile and passed to
reconcileComputeService and reconcileEviction which mutate it
directly. This eliminates intermediate condition return values and
makes the single-apply-per-reconcile explicit. The early-return guard
for already-enabled/disabled state is inlined into each branch.

Seed only the conditions owned by this controller so SSA does not
claim ownership over conditions written by others. For the
delete-by-omission case, owned conditions are seeded selectively so
the target condition is simply absent from the payload.

Also clear the forced_down flag when enabling a compute service so an
earlier HA event that set forced_down=true does not leave the service
reachable but treated as down.

SetupWithManager now delegates to registerWithManager instead of
inlining the same ctrl.NewControllerManagedBy call, which had left
registerWithManager unreachable.
Replace Create + SetControllerReference with Apply for the Eviction CR.
The owner reference and labels are set in the apply configuration
metadata, and SSA handles the upsert. A Get is still performed after
the apply to read the current eviction status conditions.

The apply configuration constructor for the cluster-scoped Eviction
resource takes only a name (no namespace).
@fwiesel fwiesel force-pushed the ssa-conditions-helpers branch from 181d69b to 7d13627 Compare July 13, 2026 19:59
@fwiesel fwiesel force-pushed the ssa-hypervisor-maintenance branch from 1468c0b to 1adbd01 Compare July 13, 2026 19:59
@github-actions

Copy link
Copy Markdown

⚠️ Note: Baseline coverage from ssa-conditions-helpers branch is not available (artifact may be expired). Showing current coverage for changed files only.

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/controller 68.96% (+68.96%) 🌟

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/controller/hypervisor_maintenance_controller.go 80.00% (+80.00%) 80 (+80) 64 (+64) 16 (+16) 🌟

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/controller/hypervisor_maintenance_controller_test.go

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