@@ -28,6 +28,7 @@ import (
2828 "github.com/petar/GoLLRB/llrb"
2929 "github.com/pkg/errors"
3030 "github.com/sirupsen/logrus"
31+ corev1api "k8s.io/api/core/v1"
3132 apierrors "k8s.io/apimachinery/pkg/api/errors"
3233 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3334 "k8s.io/apimachinery/pkg/labels"
@@ -38,8 +39,6 @@ import (
3839 "sigs.k8s.io/controller-runtime/pkg/client"
3940 "sigs.k8s.io/controller-runtime/pkg/reconcile"
4041
41- corev1api "k8s.io/api/core/v1"
42-
4342 velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
4443 "github.com/vmware-tanzu/velero/pkg/constant"
4544 "github.com/vmware-tanzu/velero/pkg/label"
@@ -119,7 +118,22 @@ func (r *BackupRepoReconciler) SetupWithManager(mgr ctrl.Manager) error {
119118 // BSL may be recreated after deleting, so also include the create event
120119 & velerov1api.BackupStorageLocation {},
121120 kube .EnqueueRequestsFromMapUpdateFunc (r .invalidateBackupReposForBSL ),
122- builder .WithPredicates (kube .NewUpdateEventPredicate (r .needInvalidBackupRepo )),
121+ builder .WithPredicates (
122+ // Combine three predicates together to guarantee
123+ // only BSL's Delete Event and Update Event can enqueue.
124+ // We don't care about BSL's Generic Event and Create Event,
125+ // because BSL's periodical enqueue triggers Generic Event,
126+ // and the BackupRepository controller restart will triggers BSL create event.
127+ kube .NewUpdateEventPredicate (
128+ r .needInvalidBackupRepo ,
129+ ),
130+ kube .NewGenericEventPredicate (
131+ func (client.Object ) bool { return false },
132+ ),
133+ kube .NewCreateEventPredicate (
134+ func (client.Object ) bool { return false },
135+ ),
136+ ),
123137 ).
124138 Complete (r )
125139}
0 commit comments