From fc99f3cf1813aaa0860b753f313ad5df3b1f0282 Mon Sep 17 00:00:00 2001 From: Hanyue Liang Date: Tue, 8 Aug 2023 14:16:43 +0000 Subject: [PATCH] volume-modifier sidecar elects the same leader as external-resizer sidecar Signed-off-by: Hanyue Liang --- cmd/main.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 0ee0def..059fb79 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -142,12 +142,14 @@ func main() { if !*enableLeaderElection { run(context.TODO()) } else { - lockName := "volume-modifier-for-k8s-" + util.SanitizeName(modifierName) + // Ensure volume-modifier-for-k8s and external-resizer sidecars always elect the same leader + // by putting them on the same lease that is identified by the lock name. + externalResizerLockName := "external-resizer-" + util.SanitizeName(driverName) leKubeClient, err := kubernetes.NewForConfig(config) if err != nil { klog.Fatal(err.Error()) } - le := leaderelection.NewLeaderElection(leKubeClient, lockName, run) + le := leaderelection.NewLeaderElection(leKubeClient, externalResizerLockName, run) if *httpEndpoint != "" { le.PrepareHealthCheck(mux, leaderelection.DefaultHealthCheckTimeout) }