Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only trigger lbm update on generation changed #141

Merged
merged 7 commits into from
Mar 29, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/predicate"
)

const (
// ServiceFinalizer Name of finalizer for controller4
ServiceFinalizer = "yawol.stackit.cloud/controller4"
DefaultRequeueTime = 10 * time.Millisecond
OpenstackRequeueTime = 1 * time.Minute
breuerfelix marked this conversation as resolved.
Show resolved Hide resolved
ServiceAccountNameAnnotation = "kubernetes.io/service-account.name"
)

Expand Down Expand Up @@ -173,7 +175,7 @@ func (r *LoadBalancerMachineReconciler) Reconcile(ctx context.Context, req ctrl.

// check if reconcile is needed
if !helper.LoadBalancerMachineOpenstackReconcileIsNeeded(loadBalancerMachine) {
return ctrl.Result{}, nil
return ctrl.Result{RequeueAfter: OpenstackRequeueTime}, nil
}

if err := r.reconcilePort(ctx, osClient, req, loadBalancerMachine, loadbalancer); err != nil {
Expand Down Expand Up @@ -201,7 +203,7 @@ func (r *LoadBalancerMachineReconciler) Reconcile(ctx context.Context, req ctrl.
return ctrl.Result{}, err
}

return ctrl.Result{}, nil
return ctrl.Result{RequeueAfter: OpenstackRequeueTime}, nil
}

// SetupWithManager is used by kubebuilder to init the controller loop
Expand All @@ -222,6 +224,7 @@ func (r *LoadBalancerMachineReconciler) SetupWithManager(mgr ctrl.Manager) error
WithOptions(controller.Options{
MaxConcurrentReconciles: r.WorkerCount,
}).
WithEventFilter(predicate.GenerationChangedPredicate{}).
Complete(r)
}

Expand Down