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?

Copy link
Author

Choose a reason for hiding this comment

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

Not in this case. During testing, there were sometimes problems when the transition from InProgress to StateApplied took too long. Therefore, the first step checks that the status is either InProgress or Applied, and then in the second step, we ensure that it actually lands on StateApplied. This makes the test process somewhat more stable.

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.

@afritzler afritzler changed the title feat: Implement BMCSettingsSet controller with reconciliation logic Add BMCSettingsSet type and controller Dec 2, 2025
@afritzler afritzler added the enhancement New feature or request label Dec 2, 2025
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, just some comments regarding cosmetics from my side.

Comment on lines +322 to +325
bmcNameMap := make(map[string]metalv1alpha1.BMC)
for _, bmc := range bmcList.Items {
bmcNameMap[bmc.Name] = bmc
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems to be unused.

Name: bmcSettingsSet.Name + "-" + bmc02.Name,
},
}
Consistently(Get(bmcSettings02)).Should(MatchError(ContainSubstring("not found")))
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: Should(Satisfy(apierrors.IsNotFound)) would avoid matching the error message.

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 enhancement New feature or request size/XXL

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Add BMCSettingSet type and controller

5 participants