@@ -28,25 +28,22 @@ import (
2828// DeprecatedCommonPredicates returns the predicate which filter out the changes done to any field except for spec (e.g. status)
2929// Also we should reconcile if finalizers have changed (see https://blog.openshift.com/kubernetes-operators-best-practices/)
3030// This will be phased out gradually to be replaced by DefaultPredicates
31- func DeprecatedCommonPredicates () predicate.Funcs {
32- return predicate.Funcs {
33- UpdateFunc : func (e event.UpdateEvent ) bool {
34- if e .ObjectOld .GetResourceVersion () == e .ObjectNew .GetResourceVersion () {
35- // resource version didn't change, so this is a resync, allow reconciliation.
36- return true
37- }
38-
39- if customresource .ReconciliationShouldBeSkipped (e .ObjectOld ) &&
40- ! customresource .ReconciliationShouldBeSkipped (e .ObjectNew ) {
31+ func DeprecatedCommonPredicates [T metav1.Object ]() predicate.TypedPredicate [T ] {
32+ return predicate .Or (
33+ SkipAnnotationRemovedPredicate [T ](),
34+ predicate.TypedFuncs [T ]{
35+ UpdateFunc : func (e event.TypedUpdateEvent [T ]) bool {
36+ if e .ObjectOld .GetResourceVersion () == e .ObjectNew .GetResourceVersion () {
37+ // resource version didn't change, so this is a resync, allow reconciliation.
38+ return true
39+ }
40+
41+ if e .ObjectOld .GetGeneration () == e .ObjectNew .GetGeneration () && reflect .DeepEqual (e .ObjectNew .GetFinalizers (), e .ObjectOld .GetFinalizers ()) {
42+ return false
43+ }
4144 return true
42- }
43-
44- if e .ObjectOld .GetGeneration () == e .ObjectNew .GetGeneration () && reflect .DeepEqual (e .ObjectNew .GetFinalizers (), e .ObjectOld .GetFinalizers ()) {
45- return false
46- }
47- return true
48- },
49- }
45+ },
46+ })
5047}
5148
5249func SelectNamespacesPredicate (namespaces []string ) predicate.Funcs {
@@ -65,9 +62,9 @@ func SelectNamespacesPredicate(namespaces []string) predicate.Funcs {
6562 })
6663}
6764
68- // ReconcileAgainPredicate reconciles on updates when the skip reconcile
65+ // SkipAnnotationRemovedPredicate reconciles on updates when the skip reconcile
6966// annotation is removed or changed
70- func ReconcileAgainPredicate [T metav1.Object ]() predicate.TypedPredicate [T ] {
67+ func SkipAnnotationRemovedPredicate [T metav1.Object ]() predicate.TypedPredicate [T ] {
7168 return predicate.TypedFuncs [T ]{
7269 UpdateFunc : func (e event.TypedUpdateEvent [T ]) bool {
7370 if customresource .ReconciliationShouldBeSkipped (e .ObjectOld ) &&
@@ -103,7 +100,7 @@ func DefaultPredicates[T metav1.Object]() predicate.TypedPredicate[T] {
103100 return predicate .And ( // or the generation changed or timed out (except for deletions)
104101 predicate .Or (
105102 GlobalResyncAwareGenerationChangePredicate [T ](),
106- ReconcileAgainPredicate [T ](),
103+ SkipAnnotationRemovedPredicate [T ](),
107104 ),
108105 IgnoreDeletedPredicate [T ](),
109106 )
0 commit comments