Skip to content

Only AggregatesController modifies aggregates and exposes Aggregates UUIDs#247

Closed
fwiesel wants to merge 2 commits intomainfrom
cortex-aggregates
Closed

Only AggregatesController modifies aggregates and exposes Aggregates UUIDs#247
fwiesel wants to merge 2 commits intomainfrom
cortex-aggregates

Conversation

@fwiesel
Copy link
Contributor

@fwiesel fwiesel commented Feb 26, 2026

  • Consolidated all openstack api calls into a single ApplyAggregates function with unit-tests
  • Modified that function to return the uuids
  • AggregateController now "knows" about onboarding and offboarding and sets aggregates accordingly.
  • On/Off-boarding controllers wait for the aggregate controller to do its thing

@fwiesel fwiesel force-pushed the cortex-aggregates branch 3 times, most recently from 2042fca to 5611895 Compare February 27, 2026 10:57
@fwiesel fwiesel marked this pull request as ready for review March 3, 2026 11:36
@fwiesel fwiesel changed the title Cortex aggregates Only AggregatesController modifies aggregates and exposes Aggregates UUIDs Mar 3, 2026

// +kubebuilder:default:={}
// The UUIDs of the aggregates are used to apply aggregates to the hypervisor.
AggregateUUIDs []string `json:"aggregateUUIDs,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

It would make much more sense to change the type of Aggregates to an array of tuples containing the aggregate name and id. Or alternatively, a map that uses uuid as a key.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would be a breaking change though.

Copy link
Contributor Author

@fwiesel fwiesel Mar 4, 2026

Choose a reason for hiding this comment

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

Okay, not only would it be a breaking change, but also would mean, we cannot simply compare .Status.Aggregates vs .Spec.Aggregates, but first collect all the values.

Cortex would have to do something similar. It is only interested in the uuids.

While I agree, that they are not independent values, and uuids and names belong together, I am not sure if that change would be net positive.

Copy link
Contributor Author

@fwiesel fwiesel Mar 4, 2026

Choose a reason for hiding this comment

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

I've opened #251, which changes aggregates in the status to be a struct with both name and uuid.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah although I get it because of backwards compatibility (but not so important), I think it's just better to bite the sour apple.

@fwiesel fwiesel force-pushed the cortex-aggregates branch 2 times, most recently from 67a8581 to 800ed63 Compare March 4, 2026 09:06
@fwiesel fwiesel requested a review from notandy March 4, 2026 09:10
fwiesel added 2 commits March 4, 2026 13:58
Almost the same logic code was used in the aggregates and the onboarding
controller, with the variation that the onboarding controller was also
creating the zone aggregate, and the aggregates controller kept
aggregates modified outside of the controller untouched.

Let's drop that functionality and expect that all aggregates are somehow
created externally (i.e. by another controller), and then we can
combine that logic in one function, that also can be called by the
offboarding controller.

Cortex wants to rely on the aggregates in the status, so we keeping
extra aggregates is unsupported either way.
For Cortex, we want the uuids in addition to the names, so
keep track of them in the status.

Let's keep only the aggregates controller changing aggregates.
@fwiesel fwiesel force-pushed the cortex-aggregates branch from 800ed63 to e063f6f Compare March 4, 2026 12:58
@github-actions
Copy link

github-actions bot commented Mar 4, 2026

Merging this branch changes the coverage (1 decrease, 1 increase)

Impacted Packages Coverage Δ 🤖
github.com/cobaltcore-dev/openstack-hypervisor-operator/api/v1 0.00% (ø)
github.com/cobaltcore-dev/openstack-hypervisor-operator/applyconfigurations/api/v1 0.00% (ø)
github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/controller 60.74% (-0.63%) 👎
github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/openstack 77.44% (+5.67%) 👍

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/cobaltcore-dev/openstack-hypervisor-operator/api/v1/hypervisor_types.go 0.00% (ø) 0 0 0
github.com/cobaltcore-dev/openstack-hypervisor-operator/api/v1/zz_generated.deepcopy.go 0.00% (ø) 0 0 0
github.com/cobaltcore-dev/openstack-hypervisor-operator/applyconfigurations/api/v1/hypervisorstatus.go 0.00% (ø) 0 0 0
github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/controller/aggregates_controller.go 72.50% (-3.01%) 40 (-9) 29 (-8) 11 (-1) 👎
github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/controller/constants.go 0.00% (ø) 0 0 0
github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/controller/decomission_controller.go 70.00% (-3.13%) 60 (-7) 42 (-7) 18 👎
github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/controller/onboarding_controller.go 54.66% (-0.38%) 247 (-11) 135 (-7) 112 (-4) 👎
github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/openstack/aggregates.go 98.11% (+11.75%) 53 (+9) 52 (+14) 1 (-5) 🎉

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/aggregates_controller_test.go
  • github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/controller/decomission_controller_test.go
  • github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/controller/onboarding_controller_test.go
  • github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/openstack/aggregates_test.go

@fwiesel
Copy link
Contributor Author

fwiesel commented Mar 5, 2026

Closed in favor of #251.

@fwiesel fwiesel closed this Mar 5, 2026
@fwiesel fwiesel deleted the cortex-aggregates branch March 5, 2026 09:06
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