Skip to content

Commit

Permalink
[watches] Fix watches declarations for CR update
Browse files Browse the repository at this point in the history
This change fixes the Watches declarations to comply with the new
controller-runtime standards.

Signed-off-by: Brendan Shephard <[email protected]>
  • Loading branch information
bshephar committed Feb 14, 2024
1 parent 5546f1e commit b81e342
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions controllers/openstackbaremetalset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"

"github.com/go-logr/logr"
metal3v1 "github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1"
Expand Down Expand Up @@ -159,7 +158,7 @@ func (r *OpenStackBaremetalSetReconciler) Reconcile(ctx context.Context, req ctr
func (r *OpenStackBaremetalSetReconciler) SetupWithManager(mgr ctrl.Manager) error {
groupLabel := labels.GetGroupLabel(baremetalv1.ServiceName)

openshiftMachineAPIBareMetalHostsFn := handler.EnqueueRequestsFromMapFunc(func(o client.Object) []reconcile.Request {
openshiftMachineAPIBareMetalHostsFn := handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, o client.Object) []reconcile.Request {
result := []reconcile.Request{}
label := o.GetLabels()
// verify object has ownerUIDLabelSelector
Expand All @@ -182,7 +181,7 @@ func (r *OpenStackBaremetalSetReconciler) SetupWithManager(mgr ctrl.Manager) err
return ctrl.NewControllerManagedBy(mgr).
For(&baremetalv1.OpenStackBaremetalSet{}).
Owns(&baremetalv1.OpenStackBaremetalSet{}).
Watches(&source.Kind{Type: &metal3v1.BareMetalHost{}}, openshiftMachineAPIBareMetalHostsFn).
Watches(&metal3v1.BareMetalHost{}, openshiftMachineAPIBareMetalHostsFn).
Complete(r)
}

Expand Down Expand Up @@ -497,7 +496,6 @@ func (r *OpenStackBaremetalSetReconciler) provisionServerCreateOrUpdate(

return nil
})

if err != nil {
return provisionServer, err
}
Expand Down Expand Up @@ -571,7 +569,6 @@ func (r *OpenStackBaremetalSetReconciler) ensureBaremetalHosts(
bmhLabels map[string]string,
envVars *map[string]env.Setter,
) error {

// Get all BaremetalHosts (and, optionally, only those that match instance.Spec.BmhLabelSelector if there is one)
baremetalHostsList, err := baremetalv1.GetBaremetalHosts(
ctx,
Expand All @@ -591,7 +588,6 @@ func (r *OpenStackBaremetalSetReconciler) ensureBaremetalHosts(

// Verify that we have enough hosts with the right hardware reqs available for scaling-up
availableBaremetalHosts, err := baremetalv1.VerifyBaremetalSetScaleUp(log.FromContext(ctx), instance, baremetalHostsList, existingBaremetalHosts)

if err != nil {
return err
}
Expand Down Expand Up @@ -633,7 +629,6 @@ func (r *OpenStackBaremetalSetReconciler) ensureBaremetalHosts(
passwordSecret,
envVars,
)

if err != nil {
return err
}
Expand Down

0 comments on commit b81e342

Please sign in to comment.