Skip to content

Commit

Permalink
Merge pull request kubernetes-csi#17 from bertinatto/leader_election
Browse files Browse the repository at this point in the history
Bug: 1747020: UPSTREAM: 296: disable duplicate LE in provisioner lib; add lock namespacing
  • Loading branch information
openshift-merge-robot authored Aug 30, 2019
2 parents 4c24cfa + 70732f2 commit 11d8a71
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cmd/csi-provisioner/csi-provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ var (
operationTimeout = flag.Duration("timeout", 10*time.Second, "Timeout for waiting for creation or deletion of a volume")
_ = deprecatedflags.Add("provisioner")

enableLeaderElection = flag.Bool("enable-leader-election", false, "Enables leader election. If leader election is enabled, additional RBAC rules are required. Please refer to the Kubernetes CSI documentation for instructions on setting up these RBAC rules.")
leaderElectionType = flag.String("leader-election-type", "endpoints", "the type of leader election, options are 'endpoints' (default) or 'leases' (strongly recommended). The 'endpoints' option is deprecated in favor of 'leases'.")
enableLeaderElection = flag.Bool("enable-leader-election", false, "Enables leader election. If leader election is enabled, additional RBAC rules are required. Please refer to the Kubernetes CSI documentation for instructions on setting up these RBAC rules.")
leaderElectionType = flag.String("leader-election-type", "endpoints", "the type of leader election, options are 'endpoints' (default) or 'leases' (strongly recommended). The 'endpoints' option is deprecated in favor of 'leases'.")
leaderElectionNamespace = flag.String("leader-election-namespace", "", "Namespace where the leader election resource lives. Defaults to the pod namespace if not set.")

featureGates map[string]bool
provisionController *controller.ProvisionController
Expand All @@ -70,6 +71,7 @@ var (

type leaderElection interface {
Run() error
WithNamespace(namespace string)
}

func main() {
Expand Down Expand Up @@ -158,7 +160,7 @@ func main() {
identity := strconv.FormatInt(timeStamp, 10) + "-" + strconv.Itoa(rand.Intn(10000)) + "-" + provisionerName

provisionerOptions := []func(*controller.ProvisionController) error{
controller.LeaderElection(*enableLeaderElection),
controller.LeaderElection(false), // Always disable leader election in provisioner lib. Leader election should be done here in the CSI provisioner level instead.
controller.FailedProvisionThreshold(0),
controller.FailedDeleteThreshold(0),
controller.RateLimiter(workqueue.NewItemExponentialFailureRateLimiter(*retryIntervalStart, *retryIntervalMax)),
Expand Down Expand Up @@ -209,6 +211,10 @@ func main() {
os.Exit(1)
}

if *leaderElectionNamespace != "" {
le.WithNamespace(*leaderElectionNamespace)
}

if err := le.Run(); err != nil {
klog.Fatalf("failed to initialize leader election: %v", err)
}
Expand Down

0 comments on commit 11d8a71

Please sign in to comment.