Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions controllers/azurecluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func (r *AzureClusterReconciler) SetupWithManager(ctx context.Context, mgr ctrl.
&source.Kind{Type: &clusterv1.Cluster{}},
handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(infrav1.GroupVersion.WithKind("AzureCluster"))),
predicates.ClusterUnpaused(log),
predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue),
); err != nil {
return errors.Wrap(err, "failed adding a watch for ready clusters")
}
Expand Down
1 change: 1 addition & 0 deletions controllers/azureidentity_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func (r *AzureIdentityReconciler) SetupWithManager(ctx context.Context, mgr ctrl
&source.Kind{Type: &clusterv1.Cluster{}},
handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(infrav1.GroupVersion.WithKind("AzureCluster"))),
predicates.ClusterUnpaused(log),
predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue),
); err != nil {
return errors.Wrap(err, "failed adding a watch for ready clusters")
}
Expand Down
3 changes: 3 additions & 0 deletions controllers/azurejson_machine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha4"
"sigs.k8s.io/cluster-api/util"
"sigs.k8s.io/cluster-api/util/annotations"
"sigs.k8s.io/cluster-api/util/predicates"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
Expand All @@ -52,13 +53,15 @@ type AzureJSONMachineReconciler struct {
Log logr.Logger
Recorder record.EventRecorder
ReconcileTimeout time.Duration
WatchFilterValue string
}

// SetupWithManager initializes this controller with a manager.
func (r *AzureJSONMachineReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error {
return ctrl.NewControllerManagedBy(mgr).
For(&infrav1.AzureMachine{}).
WithEventFilter(filterUnclonedMachinesPredicate{log: r.Log}).
WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue)).
Owns(&corev1.Secret{}).
Complete(r)
}
Expand Down
3 changes: 3 additions & 0 deletions controllers/azurejson_machinepool_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/tools/record"
"sigs.k8s.io/cluster-api/util"
"sigs.k8s.io/cluster-api/util/predicates"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
Expand All @@ -49,12 +50,14 @@ type AzureJSONMachinePoolReconciler struct {
Log logr.Logger
Recorder record.EventRecorder
ReconcileTimeout time.Duration
WatchFilterValue string
}

// SetupWithManager initializes this controller with a manager.
func (r *AzureJSONMachinePoolReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error {
return ctrl.NewControllerManagedBy(mgr).
For(&expv1.AzureMachinePool{}).
WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue)).
Owns(&corev1.Secret{}).
Complete(r)
}
Expand Down
3 changes: 3 additions & 0 deletions controllers/azurejson_machinetemplate_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"k8s.io/client-go/tools/record"
"sigs.k8s.io/cluster-api/util"
"sigs.k8s.io/cluster-api/util/annotations"
"sigs.k8s.io/cluster-api/util/predicates"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
Expand All @@ -49,13 +50,15 @@ type AzureJSONTemplateReconciler struct {
Log logr.Logger
Recorder record.EventRecorder
ReconcileTimeout time.Duration
WatchFilterValue string
}

// SetupWithManager initializes this controller with a manager.
func (r *AzureJSONTemplateReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error {
return ctrl.NewControllerManagedBy(mgr).
WithOptions(options).
For(&infrav1.AzureMachineTemplate{}).
WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue)).
Owns(&corev1.Secret{}).
Complete(r)
}
Expand Down
1 change: 1 addition & 0 deletions controllers/azuremachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ func (r *AzureMachineReconciler) SetupWithManager(ctx context.Context, mgr ctrl.
&source.Kind{Type: &clusterv1.Cluster{}},
handler.EnqueueRequestsFromMapFunc(azureMachineMapper),
predicates.ClusterUnpausedAndInfrastructureReady(log),
predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue),
); err != nil {
return errors.Wrap(err, "failed adding a watch for ready clusters")
}
Expand Down
2 changes: 2 additions & 0 deletions exp/controllers/azuremachinepool_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ func (ampr *AzureMachinePoolReconciler) SetupWithManager(ctx context.Context, mg
&source.Kind{Type: &infrav1exp.AzureMachinePoolMachine{}},
handler.EnqueueRequestsFromMapFunc(AzureMachinePoolMachineMapper(mgr.GetScheme(), log)),
MachinePoolMachineHasStateOrVersionChange(log),
predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), ampr.WatchFilterValue),
); err != nil {
return errors.Wrap(err, "failed adding a watch for AzureMachinePoolMachine")
}
Expand All @@ -140,6 +141,7 @@ func (ampr *AzureMachinePoolReconciler) SetupWithManager(ctx context.Context, mg
&source.Kind{Type: &clusterv1.Cluster{}},
handler.EnqueueRequestsFromMapFunc(azureMachinePoolMapper),
predicates.ClusterUnpausedAndInfrastructureReady(log),
predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), ampr.WatchFilterValue),
); err != nil {
return errors.Wrap(err, "failed adding a watch for ready clusters")
}
Expand Down
3 changes: 2 additions & 1 deletion exp/controllers/azuremachinepoolmachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (ampmr *AzureMachinePoolMachineController) SetupWithManager(ctx context.Con
c, err := ctrl.NewControllerManagedBy(mgr).
WithOptions(options.Options).
For(&infrav1exp.AzureMachinePoolMachine{}).
WithEventFilter(predicates.ResourceNotPaused(log)). // don't queue reconcile if resource is paused
WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), ampmr.WatchFilterValue)).
Build(r)
if err != nil {
return errors.Wrapf(err, "error creating controller")
Expand All @@ -109,6 +109,7 @@ func (ampmr *AzureMachinePoolMachineController) SetupWithManager(ctx context.Con
&source.Kind{Type: &infrav1exp.AzureMachinePool{}},
handler.EnqueueRequestsFromMapFunc(AzureMachinePoolToAzureMachinePoolMachines(ctx, mgr.GetClient(), log)),
MachinePoolModelHasChanged(log),
predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), ampmr.WatchFilterValue),
); err != nil {
return errors.Wrapf(err, "failed adding a watch for AzureMachinePool model changes")
}
Expand Down
1 change: 1 addition & 0 deletions exp/controllers/azuremanagedcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func (r *AzureManagedClusterReconciler) SetupWithManager(ctx context.Context, mg
&source.Kind{Type: &clusterv1.Cluster{}},
handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(infrav1exp.GroupVersion.WithKind("AzureManagedCluster"))),
predicates.ClusterUnpaused(log),
predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue),
); err != nil {
return errors.Wrap(err, "failed adding a watch for ready clusters")
}
Expand Down
1 change: 1 addition & 0 deletions exp/controllers/azuremanagedcontrolplane_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func (r *AzureManagedControlPlaneReconciler) SetupWithManager(ctx context.Contex
&source.Kind{Type: &clusterv1.Cluster{}},
handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(infrav1exp.GroupVersion.WithKind("AzureManagedControlPlane"))),
predicates.ClusterUnpausedAndInfrastructureReady(log),
predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue),
); err != nil {
return errors.Wrap(err, "failed adding a watch for ready clusters")
}
Expand Down
1 change: 1 addition & 0 deletions exp/controllers/azuremanagedmachinepool_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ func (r *AzureManagedMachinePoolReconciler) SetupWithManager(ctx context.Context
&source.Kind{Type: &clusterv1.Cluster{}},
handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(infrav1exp.GroupVersion.WithKind("AzureManagedMachinePool"))),
predicates.ClusterUnpausedAndInfrastructureReady(log),
predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue),
); err != nil {
return errors.Wrap(err, "failed adding a watch for ready clusters")
}
Expand Down
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ func registerControllers(ctx context.Context, mgr manager.Manager) {
Log: ctrl.Log.WithName("controllers").WithName("AzureJSONTemplate"),
Recorder: mgr.GetEventRecorderFor("azurejsontemplate-reconciler"),
ReconcileTimeout: reconcileTimeout,
WatchFilterValue: watchFilterValue,
}).SetupWithManager(ctx, mgr, controller.Options{MaxConcurrentReconciles: azureMachineConcurrency}); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "AzureJSONTemplate")
os.Exit(1)
Expand All @@ -352,6 +353,7 @@ func registerControllers(ctx context.Context, mgr manager.Manager) {
Log: ctrl.Log.WithName("controllers").WithName("AzureJSONMachine"),
Recorder: mgr.GetEventRecorderFor("azurejsonmachine-reconciler"),
ReconcileTimeout: reconcileTimeout,
WatchFilterValue: watchFilterValue,
}).SetupWithManager(ctx, mgr, controller.Options{MaxConcurrentReconciles: azureMachineConcurrency}); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "AzureJSONMachine")
os.Exit(1)
Expand Down Expand Up @@ -408,6 +410,7 @@ func registerControllers(ctx context.Context, mgr manager.Manager) {
Log: ctrl.Log.WithName("controllers").WithName("AzureJSONMachinePool"),
Recorder: mgr.GetEventRecorderFor("azurejsonmachinepool-reconciler"),
ReconcileTimeout: reconcileTimeout,
WatchFilterValue: watchFilterValue,
}).SetupWithManager(ctx, mgr, controller.Options{MaxConcurrentReconciles: azureMachinePoolConcurrency}); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "AzureJSONMachinePool")
os.Exit(1)
Expand Down