operator-sdk
operator-sdk copied to clipboard
SyncPeriod does not work if controller is created WithEventFilter(predicate.GenerationChangedPredicate{})
Bug Report
What did you do?
Create a manager with SyncPeriod.
s := time.Second * 10
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
// other manager fields
SyncPeriod: &s,
})
and setup the reconciler with this manager
func (r *MyReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&package.MyKind{}).
WithEventFilter(predicate.GenerationChangedPredicate{}).
Complete(r)
}
and created an object of type MyKind.
What did you expect to see?
The reconciler should run every 10 seconds.
What did you see instead? Under which circumstances?
The reconciler does not run periodically.
But, if WithEventFilter(predicate.GenerationChangedPredicate{})
is commented, then the reconciler runs every 10 seconds.
Environment
Operator type:
Kubernetes cluster type: Rancher Desktop 1.5.1 Kubernetes version 1.24.3
$ operator-sdk version
sigs.k8s.io/controller-runtime v0.12.3
$ go version
(if language is Go)
go version go1.19 darwin/amd64
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.3", GitCommit:"816c97ab8cff8a1c72eccca1026f7820e93e0d25", GitTreeState:"clean", BuildDate:"2022-01-25T21:25:17Z", GoVersion:"go1.17.6", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"24", GitVersion:"v1.24.3+k3s1", GitCommit:"990ba0e88c90f8ed8b50e0ccd375937b841b176e", GitTreeState:"clean", BuildDate:"2022-07-19T01:10:03Z", GoVersion:"go1.18.1", Compiler:"gc", Platform:"linux/amd64"}
Possible Solution
Additional context
This seems to be an issue related with controller-runtime. IMO though predicates filter the specific events getting queued for the controller to act on, SyncPeriod
should still be respected. @akashjain971 Can you please also create an issue in https://github.com/kubernetes-sigs/controller-runtime too? Please feel free to also bring this up in the k8s #controller-runtime slack channel.
Created an issue in controller-runtime https://github.com/kubernetes-sigs/controller-runtime/issues/1990
Hey, I see this issue is in backlog, and not yet fixed. do we have any workaround for this.
Issues go stale after 90d of inactivity.
Mark the issue as fresh by commenting /remove-lifecycle stale
.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen
.
If this issue is safe to close now please do so with /close
.
/lifecycle stale
Stale issues rot after 30d of inactivity.
Mark the issue as fresh by commenting /remove-lifecycle rotten
.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen
.
If this issue is safe to close now please do so with /close
.
/lifecycle rotten /remove-lifecycle stale
Rotten issues close after 30d of inactivity.
Reopen the issue by commenting /reopen
.
Mark the issue as fresh by commenting /remove-lifecycle rotten
.
Exclude this issue from closing again by commenting /lifecycle frozen
.
/close
@openshift-bot: Closing this issue.
In response to this:
Rotten issues close after 30d of inactivity.
Reopen the issue by commenting
/reopen
. Mark the issue as fresh by commenting/remove-lifecycle rotten
. Exclude this issue from closing again by commenting/lifecycle frozen
./close
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.