operator-sdk icon indicating copy to clipboard operation
operator-sdk copied to clipboard

SyncPeriod does not work if controller is created WithEventFilter(predicate.GenerationChangedPredicate{})

Open akashjain971 opened this issue 2 years ago • 2 comments

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

akashjain971 avatar Aug 18 '22 14:08 akashjain971

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.

varshaprasad96 avatar Aug 22 '22 18:08 varshaprasad96

Created an issue in controller-runtime https://github.com/kubernetes-sigs/controller-runtime/issues/1990

akashjain971 avatar Aug 29 '22 07:08 akashjain971

Hey, I see this issue is in backlog, and not yet fixed. do we have any workaround for this.

ASinha24 avatar Nov 03 '22 07:11 ASinha24

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

openshift-bot avatar Feb 01 '23 09:02 openshift-bot

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

openshift-bot avatar Mar 04 '23 00:03 openshift-bot

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 avatar Apr 03 '23 08:04 openshift-bot

@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.

openshift-ci[bot] avatar Apr 03 '23 08:04 openshift-ci[bot]