mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #3030 from yichengq/fix-fallback-case
etcdmain: fix the check in fallback-to-proxy case
This commit is contained in:
commit
88b69a5979
@ -271,7 +271,10 @@ func (cfg *config) Parse(arguments []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// when etcd runs in member mode user needs to set -advertise-client-urls if -listen-client-urls is set.
|
// when etcd runs in member mode user needs to set -advertise-client-urls if -listen-client-urls is set.
|
||||||
if cfg.proxy.String() != proxyFlagOn {
|
// TODO(yichengq): check this for joining through discovery service case
|
||||||
|
mayFallbackToProxy := flags.IsSet(cfg.FlagSet, "discovery") && cfg.fallback.String() == fallbackFlagProxy
|
||||||
|
mayBeProxy := cfg.proxy.String() != proxyFlagOff || mayFallbackToProxy
|
||||||
|
if !mayBeProxy {
|
||||||
if flags.IsSet(cfg.FlagSet, "listen-client-urls") && !flags.IsSet(cfg.FlagSet, "advertise-client-urls") {
|
if flags.IsSet(cfg.FlagSet, "listen-client-urls") && !flags.IsSet(cfg.FlagSet, "advertise-client-urls") {
|
||||||
return errUnsetAdvertiseClientURLsFlag
|
return errUnsetAdvertiseClientURLsFlag
|
||||||
}
|
}
|
||||||
|
@ -212,6 +212,71 @@ func TestConfigParsingConflictClusteringFlags(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestConfigParsingMissedAdvertiseClientURLsFlag(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
args []string
|
||||||
|
werr error
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
[]string{
|
||||||
|
"-initial-cluster=infra1=http://127.0.0.1:2380",
|
||||||
|
"-listen-client-urls=http://127.0.0.1:2379",
|
||||||
|
},
|
||||||
|
errUnsetAdvertiseClientURLsFlag,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
[]string{
|
||||||
|
"-discovery-srv=example.com",
|
||||||
|
"-listen-client-urls=http://127.0.0.1:2379",
|
||||||
|
},
|
||||||
|
errUnsetAdvertiseClientURLsFlag,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
[]string{
|
||||||
|
"-discovery=http://example.com/abc",
|
||||||
|
"-discovery-fallback=exit",
|
||||||
|
"-listen-client-urls=http://127.0.0.1:2379",
|
||||||
|
},
|
||||||
|
errUnsetAdvertiseClientURLsFlag,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
[]string{
|
||||||
|
"-listen-client-urls=http://127.0.0.1:2379",
|
||||||
|
},
|
||||||
|
errUnsetAdvertiseClientURLsFlag,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
[]string{
|
||||||
|
"-discovery=http://example.com/abc",
|
||||||
|
"-listen-client-urls=http://127.0.0.1:2379",
|
||||||
|
},
|
||||||
|
nil,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
[]string{
|
||||||
|
"-proxy=on",
|
||||||
|
"-listen-client-urls=http://127.0.0.1:2379",
|
||||||
|
},
|
||||||
|
nil,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
[]string{
|
||||||
|
"-proxy=readonly",
|
||||||
|
"-listen-client-urls=http://127.0.0.1:2379",
|
||||||
|
},
|
||||||
|
nil,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, tt := range tests {
|
||||||
|
cfg := NewConfig()
|
||||||
|
err := cfg.Parse(tt.args)
|
||||||
|
if err != tt.werr {
|
||||||
|
t.Errorf("%d: err = %v, want %v", i, err, tt.werr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestConfigIsNewCluster(t *testing.T) {
|
func TestConfigIsNewCluster(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
state string
|
state string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user