mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #2761 from yichengq/344
etcdmain: advertise-client-urls must be set if listen-client-urls is set
This commit is contained in:
commit
33febb979c
@ -61,6 +61,7 @@ var (
|
|||||||
|
|
||||||
ErrConflictBootstrapFlags = fmt.Errorf("multiple discovery or bootstrap flags are set" +
|
ErrConflictBootstrapFlags = fmt.Errorf("multiple discovery or bootstrap flags are set" +
|
||||||
"Choose one of \"initial-cluster\", \"discovery\" or \"discovery-srv\"")
|
"Choose one of \"initial-cluster\", \"discovery\" or \"discovery-srv\"")
|
||||||
|
errUnsetAdvertiseClientURLsFlag = fmt.Errorf("-advertise-client-urls is required when -listen-client-urls is set explicitly")
|
||||||
)
|
)
|
||||||
|
|
||||||
type config struct {
|
type config struct {
|
||||||
@ -264,6 +265,9 @@ func (cfg *config) Parse(arguments []string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if flags.IsSet(cfg.FlagSet, "listen-client-urls") && !flags.IsSet(cfg.FlagSet, "advertise-client-urls") {
|
||||||
|
return errUnsetAdvertiseClientURLsFlag
|
||||||
|
}
|
||||||
|
|
||||||
if 5*cfg.TickMs > cfg.ElectionMs {
|
if 5*cfg.TickMs > cfg.ElectionMs {
|
||||||
return fmt.Errorf("-election-timeout[%vms] should be at least as 5 times as -heartbeat-interval[%vms]", cfg.ElectionMs, cfg.TickMs)
|
return fmt.Errorf("-election-timeout[%vms] should be at least as 5 times as -heartbeat-interval[%vms]", cfg.ElectionMs, cfg.TickMs)
|
||||||
|
@ -29,6 +29,8 @@ func TestConfigParsingMemberFlags(t *testing.T) {
|
|||||||
"-snapshot-count=10",
|
"-snapshot-count=10",
|
||||||
"-listen-peer-urls=http://localhost:8000,https://localhost:8001",
|
"-listen-peer-urls=http://localhost:8000,https://localhost:8001",
|
||||||
"-listen-client-urls=http://localhost:7000,https://localhost:7001",
|
"-listen-client-urls=http://localhost:7000,https://localhost:7001",
|
||||||
|
// it should be set if -listen-client-urls is set
|
||||||
|
"-advertise-client-urls=http://localhost:7000,https://localhost:7001",
|
||||||
}
|
}
|
||||||
wcfg := &config{
|
wcfg := &config{
|
||||||
dir: "testdir",
|
dir: "testdir",
|
||||||
|
@ -60,7 +60,12 @@ func Main() {
|
|||||||
cfg := NewConfig()
|
cfg := NewConfig()
|
||||||
err := cfg.Parse(os.Args[1:])
|
err := cfg.Parse(os.Args[1:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("error verifying flags, %v. See 'etcd -help'.", err)
|
log.Printf("error verifying flags, %v. See 'etcd -help'.", err)
|
||||||
|
switch err {
|
||||||
|
case errUnsetAdvertiseClientURLsFlag:
|
||||||
|
log.Printf("When listening on specific address(es), this etcd process must advertise accessible url(s) to each connected client.")
|
||||||
|
}
|
||||||
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
setupLogging(cfg)
|
setupLogging(cfg)
|
||||||
|
|
||||||
|
@ -56,7 +56,8 @@ clustering flags:
|
|||||||
--initial-cluster-token 'etcd-cluster'
|
--initial-cluster-token 'etcd-cluster'
|
||||||
initial cluster token for the etcd cluster during bootstrap.
|
initial cluster token for the etcd cluster during bootstrap.
|
||||||
--advertise-client-urls 'http://localhost:2379,http://localhost:4001'
|
--advertise-client-urls 'http://localhost:2379,http://localhost:4001'
|
||||||
list of this member's client URLs to advertise to the rest of the cluster.
|
list of this member's client URLs to advertise to the public.
|
||||||
|
The client URLs advertised should be accessible to machines that talk to etcd cluster. etcd client libraries parse these URLs to connect to the cluster.
|
||||||
--discovery ''
|
--discovery ''
|
||||||
discovery URL used to bootstrap the cluster.
|
discovery URL used to bootstrap the cluster.
|
||||||
--discovery-fallback 'proxy'
|
--discovery-fallback 'proxy'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user