GoogleCloudPlatform / metacontroller

Lightweight Kubernetes controllers as a service
https://metacontroller.app/
Apache License 2.0
792 stars 105 forks source link

System rapidly making calls to sync hook #197

Open kevinjdolan opened 4 years ago

kevinjdolan commented 4 years ago

I followed the guide here for building an example controller, using all of the provided sources and commands: https://metacontroller.app/guide/create/

I am working on a fairly fresh cluster running 1.15.9-gke.22 in GKE.

According to these docs, https://metacontroller.app/api/compositecontroller/, the following quote:

By default, your sync hook will only be called when something changes in one of the resources you’re watching, or when the local cache is flushed.

Because no resync period is defined for the controller in the example, my expectation would be that the sync hook would only be called once. However, I am seeing it called approximately once per second.

Running kubectl -n hello describe helloworld your-name, I see the following fields changing:

Looking at the logs for metacontroller, it doesn't seem like it is actually sending updates to the children resources unless the output actually changes.

I am concerned for performance reasons about the frequent calls to sync. My expectation is that the resyncPeriodSeconds paramater, as well as the resyncAfterSeconds response parameter could be used to tune the performance of these items; but I am suspicious that there is a problem with the implementation since these parameters seem to be ignored.

saip92 commented 4 years ago

Ran into this too... Looks like the solution is to add a status sub-resource as mentioned here.