longhorn / longhorn

Cloud-Native distributed storage built on and for Kubernetes
https://longhorn.io
Apache License 2.0
6.06k stars 596 forks source link

[TASK] Check and refactor the controllers which could change to use controller leader election mechanism #2636

Open jenting opened 3 years ago

jenting commented 3 years ago

What's the task? Please describe.

Currently, only the upgrade procedure enables the controller leader election https://github.com/longhorn/longhorn-manager/blob/ceb3982/upgrade/upgrade.go#L92-L135.

However, some of the controllers' functions could leverage the controller leader election mechanism that only needs to run on a process to handle it (for example, kubernetes_secret_controller). After that, we probably could remove the ownerID check logic inside the controller. This would make the controller code logic easier to understand.

Describe the items of the task (DoD, definition of done) you'd like.

Additional context Add any other context or screenshots about the task request here.

PhanLe1010 commented 3 years ago

Good idea!

This could also help the Longhorn opt-in telemetry since we only need 1 node in the cluster to report metrics to the telemetry server.