Why Reconcile
function is called many times in controller_test.go
?
#2836
-
Hello. I am new to kubebuilder. Now I am implementing a controller_test that verifies the mock function called But the Is it possible to call |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Hi @LittleWat, By using the Operators, it’s possible not only to provide all expected resources but also to manage them dynamically, programmatically, and at runtime. To illustrate this idea, imagine if someone accidentally changed a configuration or removed a resource by mistake; in this case, the Operator could fix it without any human intervention. Therefore, the goal is to always ensure a desired state on the cluster via idempotent solutions, and because of this, we "watch" the required resources on the cluster and when something changes we reconcile.
Regards your question:
Not sure how you are doing this implementation but a good example can be found in the scaffold done by the new plugin deploy.image/v1-alpha, see: https://github.com/kubernetes-sigs/kubebuilder/blob/master/testdata/project-v3-with-deploy-image/controllers/busybox_controller_test.go#L36-L125
Again not sure how you are doing that. If it is called more than once or it is returning errors which will make the reconciliation begin again or the resources which are watched have been changed and then are calling the reconciliation again. Also, see the blog: https://dev4devs.com/2020/08/16/how-to-getting-started-develop-go-operators-from-scratch-with-sdk-1-0/ it has good info about getting started and describes the returns for the reconcile. |
Beta Was this translation helpful? Give feedback.
-
Closing since it is answered. |
Beta Was this translation helpful? Give feedback.
Hi @LittleWat,
By using the Operators, it’s possible not only to provide all expected resources but also to manage them dynamically, programmatically, and at runtime. To illustrate this idea, imagine if someone accidentally changed a configuration or removed a resource by mistake; in this case, the Operator could fix it without any human intervention.
Therefore, the goal is to always ensure a desired state on the cluster via idempotent solutions, and because of this, we "watch" the required resources on the cluster and when something changes we reconcile.