Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
ODLM supportConcurrent Reconciling
Signed-off-by: YuChen <[email protected]>
  • Loading branch information
YuChen committed Aug 28, 2023
commit ce8a0eb2b932fe9b8f4df9d9a12dc152e74d6a9f
5 changes: 5 additions & 0 deletions controllers/operandrequest/operandrequest_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/predicate"
Expand Down Expand Up @@ -300,7 +301,11 @@ func (r *Reconciler) getConfigToRequestMapper() handler.MapFunc {

// SetupWithManager adds OperandRequest controller to the manager.
func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error {
options := controller.Options{
MaxConcurrentReconciles: r.MaxConcurrentReconciles, // Set the desired value for max concurrent reconciles.
}
return ctrl.NewControllerManagedBy(mgr).
WithOptions(options).
For(&operatorv1alpha1.OperandRequest{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
Watches(&source.Kind{Type: &olmv1alpha1.Subscription{}}, handler.EnqueueRequestsFromMapFunc(r.getSubToRequestMapper()), builder.WithPredicates(predicate.Funcs{
UpdateFunc: func(e event.UpdateEvent) bool {
Expand Down
16 changes: 9 additions & 7 deletions controllers/operator/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,20 @@ type ODLMOperator struct {
client.Client
client.Reader
*rest.Config
Recorder record.EventRecorder
Scheme *runtime.Scheme
Recorder record.EventRecorder
Scheme *runtime.Scheme
MaxConcurrentReconciles int
}

// NewODLMOperator is the method to initialize an Operator struct
func NewODLMOperator(mgr manager.Manager, name string) *ODLMOperator {
return &ODLMOperator{
Client: mgr.GetClient(),
Reader: mgr.GetAPIReader(),
Config: mgr.GetConfig(),
Recorder: mgr.GetEventRecorderFor(name),
Scheme: mgr.GetScheme(),
Client: mgr.GetClient(),
Reader: mgr.GetAPIReader(),
Config: mgr.GetConfig(),
Recorder: mgr.GetEventRecorderFor(name),
Scheme: mgr.GetScheme(),
MaxConcurrentReconciles: 5,
}
}

Expand Down