Skip to content

Conversation

@davidgrun
Copy link

@davidgrun davidgrun commented Sep 16, 2025

Added BMCSettingsSetReconciler to manage BMCSettingsSet resources.

fixes: #419

Comment on lines 355 to 360
//avoid unnecessary updates
if r.refsAreEqual(bmcSettingsCopy.Spec.ServerMaintenanceRefs, mergedRefs) &&
r.templatesAreEqual(&bmcSettingsCopy.Spec.BMCSettingsTemplate, bmcSettingsTemplate) {
log.V(2).Info("No changes needed for BMCSettings", "BMCSettings", bmcSettingsCopy.Name)
return nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

isnt this duplicate?
the method CreateOrPatch already checks before updating/patching the resources.

Copy link
Author

Choose a reason for hiding this comment

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

correct removed the duplicate check and the unnecessary functions for check this in the new pr

- Added BMCSettingsSetReconciler to manage BMCSettingsSet resources.
- Implemented reconciliation logic for creating, updating, and deleting BMCSettings based on BMC resources.
- Introduced finalizer handling for BMCSettingsSet to manage cleanup during deletion.
- Added methods to handle owned BMCSettings and update their status based on the reconciliation state.
- Implemented logic to create missing BMCSettings and delete orphaned ones.
- Added tests for BMCSettingsSet controller to ensure correct reconciliation behavior.

test: Add unit tests for BMCSettingsSet controller

- Created comprehensive tests for BMCSettingsSet controller to validate reconciliation logic.
- Ensured correct behavior when BMC resources are created, updated, or deleted.
- Verified that BMCSettings are generated correctly based on BMC labels.
- Added tests for updating BMCSettingsSet and ensuring status updates are reflected.

chore: Update test suite to include BMCSettingsSet reconciler

- Modified suite_test.go to register BMCSettingsSetReconciler with the test manager.
- Ensured all resources are cleaned up after tests, including BMCSettingsSet.

fix: Update BMCSettings webhook to include BMCSettingsTemplate

- Refactored BMCSettingsSpec to include BMCSettingsTemplate for better structure.
- Updated webhook tests to validate the new structure of BMCSettings resources.
…cumentation and tests. To ensure make and lint works
…enanceRefs filtering logic with clientutils.ListAndFilter
@davidgrun davidgrun self-assigned this Nov 10, 2025
…prove server state handling. For this use the new server claim handling

Update biossettings_controller_test: add const for bar variable that go lint works correctly
Comment on lines +632 to +643
Eventually(Update(serverClaim02, func() {
metautils.SetAnnotation(serverClaim02, metalv1alpha1.ServerMaintenanceApprovalKey, "true")
})).Should(Succeed())

Eventually(Object(bmcSettings02)).Should(SatisfyAny(
HaveField("Status.State", metalv1alpha1.BMCSettingsStateInProgress),
HaveField("Status.State", metalv1alpha1.BMCSettingsStateApplied),
))

Eventually(Object(bmcSettings02)).Should(SatisfyAll(
HaveField("Status.State", metalv1alpha1.BMCSettingsStateApplied),
))
Copy link
Contributor

Choose a reason for hiding this comment

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

duplicate code?

RunSpecs(t, "Controller Suite")
}

func DeleteAllMetalResources(ctx context.Context, namespace string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this was removed recently, can we switch to have the newer method and remove this code?

Copy link
Contributor

@Nuckal777 Nuckal777 left a comment

Choose a reason for hiding this comment

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

Thanks. 👍 PR needs a rebase and the test need to be adjusted due to the removal of DeleteAllMetalResources(). Also, I would consider removing support for ServerMaintenanceRefs on the BMCSettingsSet. It complicates the code a lot and for practical uses I would imagine most people would just like to apply the set and have ServerMaintenances be automatically managed, instead of micro-managing them.

Comment on lines +13 to +14
foo: bar
foo2: bar2
Copy link
Contributor

Choose a reason for hiding this comment

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

Indentation is off. Newline at the end of the file would also be appreciated.

Comment on lines +24 to +28
// added const field for go linting
const (
testBarValue = "bar"
)

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably, we should not run the goconst (?) linter on the test files, instead of introducing an inconsistently used constant.

Comment on lines +103 to +108
if bmcSettings.Status.State != metalv1alpha1.BMCSettingsStateInProgress {
delTableBMCSettings[bmcSettings.Name] = struct{}{}
} else if len(bmcSettings.Spec.ServerMaintenanceRefs) == 0 {
// If no ServerMaintenanceRefs is set, the BMCSettings is not actively being processed
delTableBMCSettings[bmcSettings.Name] = struct{}{}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please unify both checks in a single if block.

Comment on lines +362 to +363
var serverMaintenanceRefsMerged []metalv1alpha1.ServerMaintenanceRefItem
if len(serverMaintenancesRefsCreated) > 0 && len(serverMaintenanceRefsProvided) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't both list contain non-overlapping sets of maintenances (serverMaintenanceRefsCreated = refsOnBMCSettingsObject - refsProvidedOnBMCSettingsSet)? If yes, the special handling for merging these can be removed.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Nuckal777 I do not think that is always the case, user might end up providing a new maintenanceRef after child object has created one... ?


serverMaintenanceRefs := []metalv1alpha1.ServerMaintenanceRefItem{}
for _, serverMaintenance := range serverMaintenanceList.Items {
if ref, exists := serverMaintenanceRefMap[serverMaintenance.Name]; exists {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is a negation missing here by chance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-change area/metal-automation documentation Improvements or additions to documentation size/XXL

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Add BMCSettingSet type and controller

4 participants