Skip to content

Eviction: Only reconcile on spec changes - #172

Closed
fwiesel wants to merge 1 commit into
mainfrom
GenerationChangedPredicateEviction
Closed

Eviction: Only reconcile on spec changes#172
fwiesel wants to merge 1 commit into
mainfrom
GenerationChangedPredicateEviction

Conversation

@fwiesel

@fwiesel fwiesel commented Oct 29, 2025

Copy link
Copy Markdown
Contributor

No description provided.

@fwiesel

fwiesel commented Oct 29, 2025

Copy link
Copy Markdown
Contributor Author

Draft, as it is untested.

@fwiesel
fwiesel marked this pull request as ready for review October 30, 2025 15:27
Comment thread internal/controller/eviction_controller.go Outdated
Comment thread internal/controller/eviction_controller.go Outdated
WithValues("reason", statusCondition.Reason).
WithValues("msg", statusCondition.Message).
Info("unknown status condition")
return ctrl.Result{}, nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hrm, instead returning inside the default branch, I would move it out again and remove the line 116.

Comment thread internal/controller/eviction_controller.go Outdated

if expectHypervisor {
// Abort eviction
// Retry eviction

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It says retry, but the next reconciliation will just exit.
Also, line 204/206, where the eviction is also aborted, doesn't bubble up the error - thus introducing inconsistency. I don't see a reason to have further reconciliation via error when we don't need a backoff.

Comment thread internal/controller/eviction_controller.go Outdated
log := logger.FromContext(ctx)

hypervisor, err := openstack.GetHypervisorByName(ctx, r.computeClient, eviction.Spec.Hypervisor, false)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

just visually, the previous line is related to the error check which makes sense to put together. But it's not super important to me.

Comment thread internal/controller/eviction_controller.go Outdated
Comment on lines +517 to +520
err := r.Patch(ctx, eviction, client.MergeFromWithOptions(evictionBase, client.MergeFromWithOptimisticLock{}))
if err != nil {
return err
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this will work. We can either update the status subresource, or the metadata (finalizer), skipping the return here will almost always cause an error.

@fwiesel fwiesel Oct 31, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

True, I fear the rewrite will need to be more extensive then.

Comment thread internal/controller/eviction_controller.go Outdated
@fwiesel
fwiesel force-pushed the GenerationChangedPredicateEviction branch from 105b0a2 to 6097c6e Compare October 31, 2025 15:51
@fwiesel
fwiesel force-pushed the GenerationChangedPredicateEviction branch from 6097c6e to 3d62209 Compare October 31, 2025 16:15
@github-actions

Copy link
Copy Markdown

Merging this branch will increase overall coverage

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

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/controller/eviction_controller.go 34.67% (-1.62%) 225 (-1) 78 (-4) 147 (+3) 👎
github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/controller/utils.go 32.61% (ø) 46 15 31

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/eviction_controller_test.go

@fwiesel

fwiesel commented Nov 20, 2025

Copy link
Copy Markdown
Contributor Author

Closing it, as we will have to revisit this one later anyway with more wide-ranging changes.

@fwiesel fwiesel closed this Nov 20, 2025
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