diff --git a/cmd/csi-snapshotter/main.go b/cmd/csi-snapshotter/main.go index 048ebcaf9..df1b11663 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" @@ -73,8 +74,8 @@ var ( ) var ( - version = "unknown" - leaderElectionLockName = "external-snapshotter-leader-election" + version = "unknown" + prefix = "external-snapshotter-leader" ) func main() { @@ -214,7 +215,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) }