execution controller only foucs on generation changed event (#105)

Signed-off-by: RainbowMango <renhongcai@huawei.com>
This commit is contained in:
Hongcai Ren 2021-01-05 12:00:52 +08:00 committed by GitHub
parent 729d867036
commit e794857320
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -15,6 +15,7 @@ import (
controllerruntime "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"github.com/karmada-io/karmada/pkg/apis/membercluster/v1alpha1"
propagationstrategy "github.com/karmada-io/karmada/pkg/apis/propagationstrategy/v1alpha1"
@ -69,7 +70,10 @@ func (c *Controller) Reconcile(req controllerruntime.Request) (controllerruntime
// SetupWithManager creates a controller and register to controller manager.
func (c *Controller) SetupWithManager(mgr controllerruntime.Manager) error {
return controllerruntime.NewControllerManagedBy(mgr).For(&propagationstrategy.PropagationWork{}).Complete(c)
return controllerruntime.NewControllerManagedBy(mgr).
For(&propagationstrategy.PropagationWork{}).
WithEventFilter(predicate.GenerationChangedPredicate{}).
Complete(c)
}
func (c *Controller) syncWork(propagationWork *propagationstrategy.PropagationWork) (controllerruntime.Result, error) {