Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
leon-inf committed Feb 28, 2024
1 parent de228d3 commit c8b33eb
Show file tree
Hide file tree
Showing 28 changed files with 43 additions and 85 deletions.
4 changes: 1 addition & 3 deletions controllers/apps/backuppolicytemplate_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
Expand Down Expand Up @@ -67,8 +66,7 @@ func (r *BackupPolicyTemplateReconciler) Reconcile(ctx context.Context, req reco

// SetupWithManager sets up the controller with the Manager.
func (r *BackupPolicyTemplateReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
For(&appsv1alpha1.BackupPolicyTemplate{}).
WithEventFilter(predicate.NewPredicateFuncs(intctrlutil.NamespacePredicateFilter)).
Complete(r)
}
4 changes: 1 addition & 3 deletions controllers/apps/class_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
Expand Down Expand Up @@ -137,8 +136,7 @@ func (r *ComponentClassReconciler) Reconcile(ctx context.Context, req reconcile.

// SetupWithManager sets up the controller with the Manager.
func (r *ComponentClassReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
For(&appsv1alpha1.ComponentClassDefinition{}).
WithEventFilter(predicate.NewPredicateFuncs(intctrlutil.NamespacePredicateFilter)).
Complete(r)
}
4 changes: 1 addition & 3 deletions controllers/apps/cluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"

appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
dpv1alpha1 "github.com/apecloud/kubeblocks/apis/dataprotection/v1alpha1"
Expand Down Expand Up @@ -166,13 +165,12 @@ func (r *ClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct

// SetupWithManager sets up the controller with the Manager.
func (r *ClusterReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
For(&appsv1alpha1.Cluster{}).
Owns(&appsv1alpha1.Component{}).
Owns(&corev1.Service{}). // cluster services
Owns(&corev1.Secret{}). // cluster conn-credential secret
Owns(&dpv1alpha1.BackupPolicy{}).
Owns(&dpv1alpha1.BackupSchedule{}).
WithEventFilter(predicate.NewPredicateFuncs(intctrlutil.NamespacePredicateFilter)).
Complete(r)
}
4 changes: 1 addition & 3 deletions controllers/apps/clusterdefinition_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"

appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
appsconfig "github.com/apecloud/kubeblocks/controllers/apps/configuration"
Expand Down Expand Up @@ -112,9 +111,8 @@ func (r *ClusterDefinitionReconciler) Reconcile(ctx context.Context, req ctrl.Re

// SetupWithManager sets up the controller with the Manager.
func (r *ClusterDefinitionReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
For(&appsv1alpha1.ClusterDefinition{}).
WithEventFilter(predicate.NewPredicateFuncs(intctrlutil.NamespacePredicateFilter)).
Complete(r)
}

Expand Down
4 changes: 1 addition & 3 deletions controllers/apps/clusterversion_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"

appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
appsconfig "github.com/apecloud/kubeblocks/controllers/apps/configuration"
Expand Down Expand Up @@ -145,9 +144,8 @@ func (r *ClusterVersionReconciler) Reconcile(ctx context.Context, req ctrl.Reque

// SetupWithManager sets up the controller with the Manager.
func (r *ClusterVersionReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
For(&appsv1alpha1.ClusterVersion{}).
WithEventFilter(predicate.NewPredicateFuncs(intctrlutil.NamespacePredicateFilter)).
Complete(r)
}

Expand Down
5 changes: 2 additions & 3 deletions controllers/apps/component_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
Expand Down Expand Up @@ -182,7 +181,7 @@ func (r *ComponentReconciler) SetupWithManager(mgr ctrl.Manager) error {
if retryDurationMS != 0 {
requeueDuration = time.Millisecond * time.Duration(retryDurationMS)
}
b := ctrl.NewControllerManagedBy(mgr).
b := intctrlutil.NewNamespacedControllerManagedBy(mgr).
For(&appsv1alpha1.Component{}).
Watches(&workloads.ReplicatedStateMachine{}, handler.EnqueueRequestsFromMapFunc(r.filterComponentResources)).
Owns(&corev1.Service{}).
Expand All @@ -205,7 +204,7 @@ func (r *ComponentReconciler) SetupWithManager(mgr ctrl.Manager) error {
Watches(&corev1.ServiceAccount{}, handler.EnqueueRequestsFromMapFunc(r.filterComponentResources))
}

return b.WithEventFilter(predicate.NewPredicateFuncs(intctrlutil.NamespacePredicateFilter)).Complete(r)
return b.Complete(r)
}

func (r *ComponentReconciler) filterComponentResources(ctx context.Context, obj client.Object) []reconcile.Request {
Expand Down
4 changes: 1 addition & 3 deletions controllers/apps/componentdefinition_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"

appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
"github.com/apecloud/kubeblocks/pkg/constant"
Expand Down Expand Up @@ -75,9 +74,8 @@ func (r *ComponentDefinitionReconciler) Reconcile(ctx context.Context, req ctrl.

// SetupWithManager sets up the controller with the Manager.
func (r *ComponentDefinitionReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
For(&appsv1alpha1.ComponentDefinition{}).
WithEventFilter(predicate.NewPredicateFuncs(intctrlutil.NamespacePredicateFilter)).
Complete(r)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"

appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
cfgcore "github.com/apecloud/kubeblocks/pkg/configuration/core"
Expand Down Expand Up @@ -118,10 +117,9 @@ func (r *ConfigConstraintReconciler) Reconcile(ctx context.Context, req ctrl.Req

// SetupWithManager sets up the controller with the Manager.
func (r *ConfigConstraintReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
For(&appsv1alpha1.ConfigConstraint{}).
// for other resource
Owns(&corev1.ConfigMap{}).
WithEventFilter(predicate.NewPredicateFuncs(intctrlutil.NamespacePredicateFilter)).
Complete(r)
}
4 changes: 1 addition & 3 deletions controllers/apps/configuration/configuration_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"

appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
"github.com/apecloud/kubeblocks/pkg/controller/component"
Expand Down Expand Up @@ -186,10 +185,9 @@ func (r *ConfigurationReconciler) runTasks(taskCtx TaskContext, tasks []Task) (e

// SetupWithManager sets up the controller with the Manager.
func (r *ConfigurationReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
For(&appsv1alpha1.Configuration{}).
Owns(&corev1.ConfigMap{}).
WithEventFilter(predicate.NewPredicateFuncs(intctrlutil.NamespacePredicateFilter)).
Complete(r)
}

Expand Down
4 changes: 2 additions & 2 deletions controllers/apps/configuration/reconfigure_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ func (r *ReconfigureReconciler) Reconcile(ctx context.Context, req ctrl.Request)

// SetupWithManager sets up the controller with the Manager.
func (r *ReconfigureReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
For(&corev1.ConfigMap{}).
WithEventFilter(predicate.And(predicate.NewPredicateFuncs(intctrlutil.NamespacePredicateFilter), predicate.NewPredicateFuncs(checkConfigurationObject))).
WithEventFilter(predicate.NewPredicateFuncs(checkConfigurationObject)).
Complete(r)
}

Expand Down
4 changes: 1 addition & 3 deletions controllers/apps/opsdefinition_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"

appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
intctrlutil "github.com/apecloud/kubeblocks/pkg/controllerutil"
Expand Down Expand Up @@ -103,8 +102,7 @@ func (r *OpsDefinitionReconciler) updateStatusUnavailable(reqCtx intctrlutil.Req

// SetupWithManager sets up the controller with the Manager.
func (r *OpsDefinitionReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
For(&appsv1alpha1.OpsDefinition{}).
WithEventFilter(predicate.NewPredicateFuncs(intctrlutil.NamespacePredicateFilter)).
Complete(r)
}
4 changes: 1 addition & 3 deletions controllers/apps/opsrequest_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
Expand Down Expand Up @@ -84,14 +83,13 @@ func (r *OpsRequestReconciler) Reconcile(ctx context.Context, req ctrl.Request)

// SetupWithManager sets up the controller with the Manager.
func (r *OpsRequestReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
For(&appsv1alpha1.OpsRequest{}).
Watches(&appsv1alpha1.Cluster{}, handler.EnqueueRequestsFromMapFunc(r.parseFirstOpsRequest)).
Watches(&workloadsv1alpha1.ReplicatedStateMachine{}, handler.EnqueueRequestsFromMapFunc(r.parseFirstOpsRequestForRSM)).
Watches(&dpv1alpha1.Backup{}, handler.EnqueueRequestsFromMapFunc(r.parseBackupOpsRequest)).
Watches(&corev1.PersistentVolumeClaim{}, handler.EnqueueRequestsFromMapFunc(r.parseVolumeExpansionOpsRequest)).
Owns(&batchv1.Job{}).
WithEventFilter(predicate.NewPredicateFuncs(intctrlutil.NamespacePredicateFilter)).
Complete(r)
}

Expand Down
4 changes: 1 addition & 3 deletions controllers/apps/servicedescriptor_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"

appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
"github.com/apecloud/kubeblocks/pkg/constant"
Expand Down Expand Up @@ -108,9 +107,8 @@ func (r *ServiceDescriptorReconciler) Reconcile(ctx context.Context, req ctrl.Re

// SetupWithManager sets up the controller with the Manager.
func (r *ServiceDescriptorReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
For(&appsv1alpha1.ServiceDescriptor{}).
WithEventFilter(predicate.NewPredicateFuncs(intctrlutil.NamespacePredicateFilter)).
Complete(r)
}

Expand Down
4 changes: 1 addition & 3 deletions controllers/apps/systemaccount_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"

appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
opsutil "github.com/apecloud/kubeblocks/controllers/apps/operations/util"
Expand Down Expand Up @@ -296,11 +295,10 @@ func (r *SystemAccountReconciler) Reconcile(ctx context.Context, req ctrl.Reques

// SetupWithManager sets up the controller with the Manager.
func (r *SystemAccountReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
For(&appsv1alpha1.Cluster{}).
Owns(&corev1.Secret{}).
Watches(&batchv1.Job{}, r.jobCompletionHandler()).
WithEventFilter(predicate.NewPredicateFuncs(intctrlutil.NamespacePredicateFilter)).
Complete(r)
}

Expand Down
4 changes: 1 addition & 3 deletions controllers/dataprotection/actionset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"

dpv1alpha1 "github.com/apecloud/kubeblocks/apis/dataprotection/v1alpha1"
intctrlutil "github.com/apecloud/kubeblocks/pkg/controllerutil"
Expand Down Expand Up @@ -93,9 +92,8 @@ func (r *ActionSetReconciler) Reconcile(ctx context.Context, req ctrl.Request) (

// SetupWithManager sets up the controller with the Manager.
func (r *ActionSetReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
For(&dpv1alpha1.ActionSet{}).
WithEventFilter(predicate.NewPredicateFuncs(intctrlutil.NamespacePredicateFilter)).
Complete(r)
}

Expand Down
6 changes: 2 additions & 4 deletions controllers/dataprotection/backup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
Expand Down Expand Up @@ -127,7 +126,7 @@ func (r *BackupReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr

// SetupWithManager sets up the controller with the Manager.
func (r *BackupReconciler) SetupWithManager(mgr ctrl.Manager) error {
b := ctrl.NewControllerManagedBy(mgr).
b := intctrlutil.NewNamespacedControllerManagedBy(mgr).
For(&dpv1alpha1.Backup{}).
WithOptions(controller.Options{
MaxConcurrentReconciles: viper.GetInt(maxConcurDataProtectionReconKey),
Expand All @@ -140,8 +139,7 @@ func (r *BackupReconciler) SetupWithManager(mgr ctrl.Manager) error {
} else {
b.Owns(&vsv1beta1.VolumeSnapshot{}, builder.Predicates{})
}
return b.WithEventFilter(predicate.NewPredicateFuncs(intctrlutil.NamespacePredicateFilter)).
Complete(r)
return b.Complete(r)
}

func (r *BackupReconciler) parseBackupJob(_ context.Context, object client.Object) []reconcile.Request {
Expand Down
4 changes: 1 addition & 3 deletions controllers/dataprotection/backuppolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"

dpv1alpha1 "github.com/apecloud/kubeblocks/apis/dataprotection/v1alpha1"
intctrlutil "github.com/apecloud/kubeblocks/pkg/controllerutil"
Expand Down Expand Up @@ -93,9 +92,8 @@ func (r *BackupPolicyReconciler) Reconcile(ctx context.Context, req ctrl.Request

// SetupWithManager sets up the controller with the Manager.
func (r *BackupPolicyReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
For(&dpv1alpha1.BackupPolicy{}).
WithEventFilter(predicate.NewPredicateFuncs(intctrlutil.NamespacePredicateFilter)).
Complete(r)
}

Expand Down
4 changes: 1 addition & 3 deletions controllers/dataprotection/backuprepo_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

dpv1alpha1 "github.com/apecloud/kubeblocks/apis/dataprotection/v1alpha1"
Expand Down Expand Up @@ -1365,15 +1364,14 @@ func (r *BackupRepoReconciler) SetupWithManager(mgr ctrl.Manager) error {
}); err != nil {
return err
}
return ctrl.NewControllerManagedBy(mgr).
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
For(&dpv1alpha1.BackupRepo{}).
Watches(&storagev1alpha1.StorageProvider{}, handler.EnqueueRequestsFromMapFunc(r.mapProviderToRepos)).
Watches(&dpv1alpha1.Backup{}, handler.EnqueueRequestsFromMapFunc(r.mapBackupToRepo)).
Watches(&corev1.Secret{}, handler.EnqueueRequestsFromMapFunc(r.mapSecretToRepos)).
Owns(&storagev1.StorageClass{}).
Owns(&corev1.PersistentVolumeClaim{}).
Owns(&batchv1.Job{}).
WithEventFilter(predicate.NewPredicateFuncs(intctrlutil.NamespacePredicateFilter)).
Complete(r)
}

Expand Down
6 changes: 2 additions & 4 deletions controllers/dataprotection/backupschedule_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"

dpv1alpha1 "github.com/apecloud/kubeblocks/apis/dataprotection/v1alpha1"
intctrlutil "github.com/apecloud/kubeblocks/pkg/controllerutil"
Expand Down Expand Up @@ -93,7 +92,7 @@ func (r *BackupScheduleReconciler) Reconcile(ctx context.Context, req ctrl.Reque

// SetupWithManager sets up the controller with the Manager.
func (r *BackupScheduleReconciler) SetupWithManager(mgr ctrl.Manager) error {
b := ctrl.NewControllerManagedBy(mgr).
b := intctrlutil.NewNamespacedControllerManagedBy(mgr).
For(&dpv1alpha1.BackupSchedule{})

// Compatible with kubernetes versions prior to K8s 1.21, only supports batch v1beta1.
Expand All @@ -102,8 +101,7 @@ func (r *BackupScheduleReconciler) SetupWithManager(mgr ctrl.Manager) error {
} else {
b.Owns(&batchv1beta1.CronJob{})
}
return b.WithEventFilter(predicate.NewPredicateFuncs(intctrlutil.NamespacePredicateFilter)).
Complete(r)
return b.Complete(r)
}

func (r *BackupScheduleReconciler) deleteExternalResources(
Expand Down
Loading

0 comments on commit c8b33eb

Please sign in to comment.