From 5e09ec46c331a539b65a14b5ab52c68de4b4bcd2 Mon Sep 17 00:00:00 2001 From: Alexey Makhov Date: Thu, 25 Apr 2024 15:55:39 +0300 Subject: [PATCH] Fix leaderElectionID issue: different controllers get same id which leads to the error Signed-off-by: Alexey Makhov --- cmd/main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/main.go b/cmd/main.go index 82f739500..88a9f3e75 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -17,7 +17,9 @@ limitations under the License. package main import ( + "crypto/md5" "flag" + "fmt" "os" // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.) @@ -110,7 +112,7 @@ func main() { }, HealthProbeBindAddress: probeAddr, LeaderElection: enableLeaderElection, - LeaderElectionID: "639dd9c3.k0smotron.io", + LeaderElectionID: fmt.Sprintf("%x.k0smotron.io", md5.Sum([]byte(enabledController))), // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily // when the Manager ends. This requires the binary to immediately end when the // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly