From 94238a86d9d7f2e6485bcf40d1fd1f8ce6b27d8c Mon Sep 17 00:00:00 2001 From: zhucan Date: Wed, 19 Jun 2019 15:00:07 +0800 Subject: [PATCH 1/2] Leader election lock name should include driver name --- cmd/csi-snapshotter/main.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cmd/csi-snapshotter/main.go b/cmd/csi-snapshotter/main.go index 880320c0..5f68fb33 100644 --- a/cmd/csi-snapshotter/main.go +++ b/cmd/csi-snapshotter/main.go @@ -73,8 +73,8 @@ var ( ) var ( - version = "unknown" - leaderElectionLockName = "external-snapshotter-leader-election" + version = "unknown" + prefix = "external-snapshotter-leader" ) func main() { @@ -214,7 +214,8 @@ func main() { if !*leaderElection { run(context.TODO()) } else { - le := leaderelection.NewLeaderElection(kubeClient, leaderElectionLockName, run) + lockName := fmt.Sprintf("%s-%s", prefix, strings.Replace(*snapshotterName, "/", "-", -1)) + le := leaderelection.NewLeaderElection(kubeClient, lockName, run) if *leaderElectionNamespace != "" { le.WithNamespace(*leaderElectionNamespace) } From e2506521ac0b048b0d9557e85066237e334c9d6d Mon Sep 17 00:00:00 2001 From: zhucan Date: Wed, 19 Jun 2019 15:08:36 +0800 Subject: [PATCH 2/2] failed unit test --- cmd/csi-snapshotter/main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/csi-snapshotter/main.go b/cmd/csi-snapshotter/main.go index 5f68fb33..6ab470c2 100644 --- a/cmd/csi-snapshotter/main.go +++ b/cmd/csi-snapshotter/main.go @@ -22,6 +22,7 @@ import ( "fmt" "os" "os/signal" + "strings" "time" "google.golang.org/grpc"