Skip to content

Commit

Permalink
fix: cannot start without specify initial cluster (#656)
Browse files Browse the repository at this point in the history
* fix: cannot start without specify initial cluster

* Update pkg/option/option.go

Co-authored-by: SU Chen <[email protected]>

* fix typo

Co-authored-by: SU Chen <[email protected]>
Co-authored-by: chen <[email protected]>
  • Loading branch information
3 people committed Jun 15, 2022
1 parent 84fc70a commit 7126f58
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions pkg/option/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,9 @@ func addClusterVars(opt *Options) {
opt.flags.StringSliceVar(&opt.Cluster.ListenPeerURLs, "listen-peer-urls", []string{"http:https://localhost:2380"}, "List of URLs to listen on for cluster peer traffic.")
opt.flags.StringSliceVar(&opt.Cluster.AdvertiseClientURLs, "advertise-client-urls", []string{"http:https://localhost:2379"}, "List of this member's client URLs to advertise to the rest of the cluster.")
opt.flags.StringSliceVar(&opt.Cluster.InitialAdvertisePeerURLs, "initial-advertise-peer-urls", []string{"http:https://localhost:2380"}, "List of this member's peer URLs to advertise to the rest of the cluster.")
opt.flags.StringToStringVarP(&opt.Cluster.InitialCluster, "initial-cluster", "", nil,
"List of (member name, URL) pairs that will form the cluster. E.g. primary-1=http:https://localhost:2380.")
opt.flags.StringToStringVarP(&opt.Cluster.InitialCluster, "initial-cluster", "", nil, "List of (member name, URL) pairs that will form the cluster. E.g. primary-1=http:https://localhost:2380.")
opt.flags.StringVar(&opt.Cluster.StateFlag, "state-flag", "new", "Cluster state (new, existing)")
opt.flags.StringSliceVar(&opt.Cluster.PrimaryListenPeerURLs,
"primary-listen-peer-urls",
[]string{"http:https://localhost:2380"},
"List of peer URLs of primary members. Define this only, when cluster-role is secondary.")
opt.flags.StringSliceVar(&opt.Cluster.PrimaryListenPeerURLs, "primary-listen-peer-urls", []string{"http:https://localhost:2380"}, "List of peer URLs of primary members. Define this only, when cluster-role is secondary.")
opt.flags.IntVar(&opt.Cluster.MaxCallSendMsgSize, "max-call-send-msg-size", 10*1024*1024, "Maximum size in bytes for cluster synchronization messages.")
}

Expand Down Expand Up @@ -238,6 +234,9 @@ func (opt *Options) Parse() (string, error) {
if opt.UseStandaloneEtcd {
opt.ClusterRole = "secondary" // when using external standalone etcd, the cluster role cannot be "primary"
}
if opt.ClusterRole == "primary" && len(opt.Cluster.InitialCluster) == 0 {
opt.Cluster.InitialCluster = map[string]string{opt.Name: opt.Cluster.InitialAdvertisePeerURLs[0]}
}

err = opt.validate()
if err != nil {
Expand Down

0 comments on commit 7126f58

Please sign in to comment.