Skip to content

Commit

Permalink
Merge pull request #144 from mlmhl/leader-electino-type
Browse files Browse the repository at this point in the history
fix default leader election type
  • Loading branch information
k8s-ci-robot authored Apr 25, 2019
2 parents 1efaaf8 + a53ef38 commit e18bd66
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions cmd/csi-attacher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ const (

// Name of CSI plugin for dummy operation
dummyAttacherName = "csi/dummy"

leaderElectionTypeLeases = "leases"
leaderElectionTypeConfigMaps = "configmaps"
)

// Command line flags
Expand All @@ -66,7 +69,7 @@ var (
retryIntervalMax = flag.Duration("retry-interval-max", 5*time.Minute, "Maximum retry interval of failed create volume or deletion.")

enableLeaderElection = flag.Bool("leader-election", false, "Enable leader election.")
leaderElectionType = flag.String("leader-election-type", "configmap", "the type of leader election, options are 'configmaps' (default) or 'leases' (recommended). The 'configmaps' option is deprecated in favor of 'leases'.")
leaderElectionType = flag.String("leader-election-type", leaderElectionTypeConfigMaps, "the type of leader election, options are 'configmaps' (default) or 'leases' (recommended). The 'configmaps' 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.")
_ = deprecatedflags.Add("leader-election-identity")
)
Expand Down Expand Up @@ -197,13 +200,13 @@ func main() {

// Name of config map with leader election lock
lockName := "external-attacher-leader-" + csiAttacher
if *leaderElectionType == "configmaps" {
klog.Warning("The 'configmaps' leader election type is deprecated and will be removed in a future release. Use '--leader-election-type=leases' instead.")
if *leaderElectionType == leaderElectionTypeConfigMaps {
klog.Warningf("The '%s' leader election type is deprecated and will be removed in a future release. Use '--leader-election-type=%s' instead.", leaderElectionTypeConfigMaps, leaderElectionTypeLeases)
le = leaderelection.NewLeaderElectionWithConfigMaps(clientset, lockName, run)
} else if *leaderElectionType == "leases" {
} else if *leaderElectionType == leaderElectionTypeLeases {
le = leaderelection.NewLeaderElection(clientset, lockName, run)
} else {
klog.Error("--leader-election-type must be either 'configmap' or 'lease'")
klog.Errorf("--leader-election-type must be either '%s' or '%s'", leaderElectionTypeConfigMaps, leaderElectionTypeLeases)
os.Exit(1)
}

Expand Down

0 comments on commit e18bd66

Please sign in to comment.