-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add jitter and resync to polling (#3151)
Don't poll all GitRepos at once, within ms. If gitrepos are lost from the requeueAfter polling, resync should add them again. * Add jitter to the pollingInterval of GitRepos * Gitops controller uses shorter resync interval * GenerationChangedPredicate prevented Cache Sync to Trigger Reconciler
- Loading branch information
Showing
8 changed files
with
97 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package reconciler | ||
|
||
import ( | ||
"reflect" | ||
|
||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"sigs.k8s.io/controller-runtime/pkg/event" | ||
"sigs.k8s.io/controller-runtime/pkg/predicate" | ||
) | ||
|
||
// TypedResourceVersionUnchangedPredicate implements a update predicate to | ||
// allow syncPeriod to trigger the reconciler | ||
type TypedResourceVersionUnchangedPredicate[T metav1.Object] struct { | ||
predicate.TypedFuncs[T] | ||
} | ||
|
||
func isNil(arg any) bool { | ||
if v := reflect.ValueOf(arg); !v.IsValid() || ((v.Kind() == reflect.Ptr || | ||
v.Kind() == reflect.Interface || | ||
v.Kind() == reflect.Slice || | ||
v.Kind() == reflect.Map || | ||
v.Kind() == reflect.Chan || | ||
v.Kind() == reflect.Func) && v.IsNil()) { | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
func (TypedResourceVersionUnchangedPredicate[T]) Create(e event.CreateEvent) bool { | ||
return false | ||
} | ||
|
||
func (TypedResourceVersionUnchangedPredicate[T]) Delete(e event.DeleteEvent) bool { | ||
return false | ||
} | ||
|
||
// Update implements default UpdateEvent filter for validating resource version change. | ||
func (TypedResourceVersionUnchangedPredicate[T]) Update(e event.TypedUpdateEvent[T]) bool { | ||
if isNil(e.ObjectOld) { | ||
return false | ||
} | ||
if isNil(e.ObjectNew) { | ||
return false | ||
} | ||
|
||
return e.ObjectNew.GetResourceVersion() == e.ObjectOld.GetResourceVersion() | ||
} | ||
|
||
func (TypedResourceVersionUnchangedPredicate[T]) Generic(e event.GenericEvent) bool { | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters