From e61012da1440b65979d0336d0feac9fb2dae2857 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Mon, 11 Apr 2022 13:30:08 +0530 Subject: [PATCH] rbd: use leases for leader election use leases for leader election instead of the deprecated configmap based leader election. This PR is making leases as default leader election refer https://github.com/kubernetes-sigs/ controller-runtime/pull/1773, default from configmap to configmap leases was done with https://github.com/kubernetes-sigs/ controller-runtime/pull/1144. Release notes https://github.com/kubernetes-sigs/ controller-runtime/releases/tag/v0.7.0 Signed-off-by: Madhu Rajanna (cherry picked from commit d886ab0d6634bca5a5b055bb7783138a2e3e5ded) --- internal/controller/controller.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/controller/controller.go b/internal/controller/controller.go index 518ff0271..5f1cc2fe2 100644 --- a/internal/controller/controller.go +++ b/internal/controller/controller.go @@ -20,6 +20,7 @@ import ( "github.com/ceph/ceph-csi/internal/util/log" + "k8s.io/client-go/tools/leaderelection/resourcelock" clientConfig "sigs.k8s.io/controller-runtime/pkg/client/config" "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/manager/signals" @@ -59,9 +60,10 @@ func Start(config Config) error { opts := manager.Options{ LeaderElection: true, // disable metrics - MetricsBindAddress: "0", - LeaderElectionNamespace: config.Namespace, - LeaderElectionID: electionID, + MetricsBindAddress: "0", + LeaderElectionNamespace: config.Namespace, + LeaderElectionResourceLock: resourcelock.LeasesResourceLock, + LeaderElectionID: electionID, } mgr, err := manager.New(clientConfig.GetConfigOrDie(), opts) if err != nil {