Skip to content

Commit 1ea4e90

Browse files
committed
Watch HFC/HFS spec changes to trigger BMH reconciliation
When a user clears firmware specs to abort a failed servicing operation, the BMH controller may be in exponential backoff due to the servicing error. Without a watch, the BMH won't notice the spec change until the next backoff-delayed reconciliation, which can take a long time. Add watches on HostFirmwareSettings and HostFirmwareComponents with GenerationChangedPredicate, mapping events back to the BMH with the same name/namespace. This ensures the BMH controller reconciles promptly when specs are modified, enabling the fast-path abort to trigger without delay. Assisted-By: Claude Opus 4.6
1 parent 4a38509 commit 1ea4e90

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

internal/controller/metal3.io/baremetalhost_controller.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import (
4646
"sigs.k8s.io/controller-runtime/pkg/controller"
4747
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
4848
"sigs.k8s.io/controller-runtime/pkg/event"
49+
"sigs.k8s.io/controller-runtime/pkg/handler"
4950
"sigs.k8s.io/controller-runtime/pkg/predicate"
5051
)
5152

@@ -2510,6 +2511,22 @@ func (r *BareMetalHostReconciler) SetupWithManager(mgr ctrl.Manager, preprovImgE
25102511
controller.Owns(&metal3api.PreprovisioningImage{})
25112512
}
25122513

2514+
// Watch HFC/HFS for spec changes (generation bumps) so that the BMH
2515+
// controller reconciles promptly when a user clears firmware specs,
2516+
// rather than waiting for error-state exponential backoff to expire.
2517+
firmwareEventHandler := handler.EnqueueRequestsFromMapFunc(
2518+
func(_ context.Context, obj client.Object) []ctrl.Request {
2519+
return []ctrl.Request{{NamespacedName: client.ObjectKey{
2520+
Name: obj.GetName(),
2521+
Namespace: obj.GetNamespace(),
2522+
}}}
2523+
},
2524+
)
2525+
controller.Watches(&metal3api.HostFirmwareSettings{}, firmwareEventHandler,
2526+
builder.WithPredicates(predicate.GenerationChangedPredicate{}))
2527+
controller.Watches(&metal3api.HostFirmwareComponents{}, firmwareEventHandler,
2528+
builder.WithPredicates(predicate.GenerationChangedPredicate{}))
2529+
25132530
return controller.Complete(r)
25142531
}
25152532

0 commit comments

Comments
 (0)