mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #15453 from serathius/refactor-url-names
Refactor url names
This commit is contained in:
commit
7f37b3630f
@ -211,12 +211,12 @@ type Config struct {
|
||||
// streams that each client can open at a time.
|
||||
MaxConcurrentStreams uint32 `json:"max-concurrent-streams"`
|
||||
|
||||
LPUrls, LCUrls []url.URL
|
||||
APUrls, ACUrls []url.URL
|
||||
ClientTLSInfo transport.TLSInfo
|
||||
ClientAutoTLS bool
|
||||
PeerTLSInfo transport.TLSInfo
|
||||
PeerAutoTLS bool
|
||||
ListenPeerUrls, ListenClientUrls []url.URL
|
||||
AdvertisePeerUrls, AdvertiseClientUrls []url.URL
|
||||
ClientTLSInfo transport.TLSInfo
|
||||
ClientAutoTLS bool
|
||||
PeerTLSInfo transport.TLSInfo
|
||||
PeerAutoTLS bool
|
||||
// SelfSignedCertValidity specifies the validity period of the client and peer certificates
|
||||
// that are automatically generated by etcd when you specify ClientAutoTLS and PeerAutoTLS,
|
||||
// the unit is year, and the default is 1
|
||||
@ -439,10 +439,10 @@ type configYAML struct {
|
||||
|
||||
// configJSON has file options that are translated into Config options
|
||||
type configJSON struct {
|
||||
LPUrlsJSON string `json:"listen-peer-urls"`
|
||||
LCUrlsJSON string `json:"listen-client-urls"`
|
||||
APUrlsJSON string `json:"initial-advertise-peer-urls"`
|
||||
ACUrlsJSON string `json:"advertise-client-urls"`
|
||||
ListenPeerUrls string `json:"listen-peer-urls"`
|
||||
ListenClientUrls string `json:"listen-client-urls"`
|
||||
AdvertisePeerUrls string `json:"initial-advertise-peer-urls"`
|
||||
AdvertiseClientUrls string `json:"advertise-client-urls"`
|
||||
|
||||
CORSJSON string `json:"cors"`
|
||||
HostWhitelistJSON string `json:"host-whitelist"`
|
||||
@ -494,10 +494,10 @@ func NewConfig() *Config {
|
||||
ElectionMs: 1000,
|
||||
InitialElectionTickAdvance: true,
|
||||
|
||||
LPUrls: []url.URL{*lpurl},
|
||||
LCUrls: []url.URL{*lcurl},
|
||||
APUrls: []url.URL{*apurl},
|
||||
ACUrls: []url.URL{*acurl},
|
||||
ListenPeerUrls: []url.URL{*lpurl},
|
||||
ListenClientUrls: []url.URL{*lcurl},
|
||||
AdvertisePeerUrls: []url.URL{*apurl},
|
||||
AdvertiseClientUrls: []url.URL{*acurl},
|
||||
|
||||
ClusterState: ClusterStateFlagNew,
|
||||
InitialClusterToken: "etcd-cluster",
|
||||
@ -571,40 +571,40 @@ func (cfg *configYAML) configFromFile(path string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if cfg.LPUrlsJSON != "" {
|
||||
u, err := types.NewURLs(strings.Split(cfg.LPUrlsJSON, ","))
|
||||
if cfg.configJSON.ListenPeerUrls != "" {
|
||||
u, err := types.NewURLs(strings.Split(cfg.configJSON.ListenPeerUrls, ","))
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "unexpected error setting up listen-peer-urls: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
cfg.LPUrls = u
|
||||
cfg.Config.ListenPeerUrls = u
|
||||
}
|
||||
|
||||
if cfg.LCUrlsJSON != "" {
|
||||
u, err := types.NewURLs(strings.Split(cfg.LCUrlsJSON, ","))
|
||||
if cfg.configJSON.ListenClientUrls != "" {
|
||||
u, err := types.NewURLs(strings.Split(cfg.configJSON.ListenClientUrls, ","))
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "unexpected error setting up listen-client-urls: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
cfg.LCUrls = u
|
||||
cfg.Config.ListenClientUrls = u
|
||||
}
|
||||
|
||||
if cfg.APUrlsJSON != "" {
|
||||
u, err := types.NewURLs(strings.Split(cfg.APUrlsJSON, ","))
|
||||
if cfg.configJSON.AdvertisePeerUrls != "" {
|
||||
u, err := types.NewURLs(strings.Split(cfg.configJSON.AdvertisePeerUrls, ","))
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "unexpected error setting up initial-advertise-peer-urls: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
cfg.APUrls = u
|
||||
cfg.Config.AdvertisePeerUrls = u
|
||||
}
|
||||
|
||||
if cfg.ACUrlsJSON != "" {
|
||||
u, err := types.NewURLs(strings.Split(cfg.ACUrlsJSON, ","))
|
||||
if cfg.configJSON.AdvertiseClientUrls != "" {
|
||||
u, err := types.NewURLs(strings.Split(cfg.configJSON.AdvertiseClientUrls, ","))
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "unexpected error setting up advertise-peer-urls: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
cfg.ACUrls = u
|
||||
cfg.Config.AdvertiseClientUrls = u
|
||||
}
|
||||
|
||||
if cfg.ListenMetricsUrlsJSON != "" {
|
||||
@ -682,21 +682,21 @@ func (cfg *Config) Validate() error {
|
||||
if err := cfg.setupLogging(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := checkBindURLs(cfg.LPUrls); err != nil {
|
||||
if err := checkBindURLs(cfg.ListenPeerUrls); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := checkBindURLs(cfg.LCUrls); err != nil {
|
||||
if err := checkBindURLs(cfg.ListenClientUrls); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := checkBindURLs(cfg.ListenMetricsUrls); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := checkHostURLs(cfg.APUrls); err != nil {
|
||||
addrs := cfg.getAPURLs()
|
||||
if err := checkHostURLs(cfg.AdvertisePeerUrls); err != nil {
|
||||
addrs := cfg.getAdvertisePeerUrls()
|
||||
return fmt.Errorf(`--initial-advertise-peer-urls %q must be "host:port" (%v)`, strings.Join(addrs, ","), err)
|
||||
}
|
||||
if err := checkHostURLs(cfg.ACUrls); err != nil {
|
||||
addrs := cfg.getACURLs()
|
||||
if err := checkHostURLs(cfg.AdvertiseClientUrls); err != nil {
|
||||
addrs := cfg.getAdvertiseClientUrls()
|
||||
return fmt.Errorf(`--advertise-client-urls %q must be "host:port" (%v)`, strings.Join(addrs, ","), err)
|
||||
}
|
||||
// Check if conflicting flags are passed.
|
||||
@ -751,7 +751,7 @@ func (cfg *Config) Validate() error {
|
||||
}
|
||||
|
||||
// check this last since proxying in etcdmain may make this OK
|
||||
if cfg.LCUrls != nil && cfg.ACUrls == nil {
|
||||
if cfg.ListenClientUrls != nil && cfg.AdvertiseClientUrls == nil {
|
||||
return ErrUnsetAdvertiseClientURLsFlag
|
||||
}
|
||||
|
||||
@ -823,14 +823,14 @@ func (cfg *Config) PeerURLsMapAndToken(which string) (urlsmap types.URLsMap, tok
|
||||
urlsmap = types.URLsMap{}
|
||||
// If using v2 discovery, generate a temporary cluster based on
|
||||
// self's advertised peer URLs
|
||||
urlsmap[cfg.Name] = cfg.APUrls
|
||||
urlsmap[cfg.Name] = cfg.AdvertisePeerUrls
|
||||
token = cfg.Durl
|
||||
|
||||
case len(cfg.DiscoveryCfg.Endpoints) > 0:
|
||||
urlsmap = types.URLsMap{}
|
||||
// If using v3 discovery, generate a temporary cluster based on
|
||||
// self's advertised peer URLs
|
||||
urlsmap[cfg.Name] = cfg.APUrls
|
||||
urlsmap[cfg.Name] = cfg.AdvertisePeerUrls
|
||||
token = cfg.DiscoveryCfg.Token
|
||||
|
||||
case cfg.DNSCluster != "":
|
||||
@ -884,7 +884,7 @@ func (cfg *Config) GetDNSClusterNames() ([]string, error) {
|
||||
|
||||
// Use both etcd-server-ssl and etcd-server for discovery.
|
||||
// Combine the results if both are available.
|
||||
clusterStrs, cerr = getCluster("https", "etcd-server-ssl"+serviceNameSuffix, cfg.Name, cfg.DNSCluster, cfg.APUrls)
|
||||
clusterStrs, cerr = getCluster("https", "etcd-server-ssl"+serviceNameSuffix, cfg.Name, cfg.DNSCluster, cfg.AdvertisePeerUrls)
|
||||
if cerr != nil {
|
||||
clusterStrs = make([]string, 0)
|
||||
}
|
||||
@ -894,12 +894,12 @@ func (cfg *Config) GetDNSClusterNames() ([]string, error) {
|
||||
zap.String("service-name", "etcd-server-ssl"+serviceNameSuffix),
|
||||
zap.String("server-name", cfg.Name),
|
||||
zap.String("discovery-srv", cfg.DNSCluster),
|
||||
zap.Strings("advertise-peer-urls", cfg.getAPURLs()),
|
||||
zap.Strings("advertise-peer-urls", cfg.getAdvertisePeerUrls()),
|
||||
zap.Strings("found-cluster", clusterStrs),
|
||||
zap.Error(cerr),
|
||||
)
|
||||
|
||||
defaultHTTPClusterStrs, httpCerr := getCluster("http", "etcd-server"+serviceNameSuffix, cfg.Name, cfg.DNSCluster, cfg.APUrls)
|
||||
defaultHTTPClusterStrs, httpCerr := getCluster("http", "etcd-server"+serviceNameSuffix, cfg.Name, cfg.DNSCluster, cfg.AdvertisePeerUrls)
|
||||
if httpCerr == nil {
|
||||
clusterStrs = append(clusterStrs, defaultHTTPClusterStrs...)
|
||||
}
|
||||
@ -909,7 +909,7 @@ func (cfg *Config) GetDNSClusterNames() ([]string, error) {
|
||||
zap.String("service-name", "etcd-server"+serviceNameSuffix),
|
||||
zap.String("server-name", cfg.Name),
|
||||
zap.String("discovery-srv", cfg.DNSCluster),
|
||||
zap.Strings("advertise-peer-urls", cfg.getAPURLs()),
|
||||
zap.Strings("advertise-peer-urls", cfg.getAdvertisePeerUrls()),
|
||||
zap.Strings("found-cluster", clusterStrs),
|
||||
zap.Error(httpCerr),
|
||||
)
|
||||
@ -918,15 +918,15 @@ func (cfg *Config) GetDNSClusterNames() ([]string, error) {
|
||||
}
|
||||
|
||||
func (cfg Config) InitialClusterFromName(name string) (ret string) {
|
||||
if len(cfg.APUrls) == 0 {
|
||||
if len(cfg.AdvertisePeerUrls) == 0 {
|
||||
return ""
|
||||
}
|
||||
n := name
|
||||
if name == "" {
|
||||
n = DefaultName
|
||||
}
|
||||
for i := range cfg.APUrls {
|
||||
ret = ret + "," + n + "=" + cfg.APUrls[i].String()
|
||||
for i := range cfg.AdvertisePeerUrls {
|
||||
ret = ret + "," + n + "=" + cfg.AdvertisePeerUrls[i].String()
|
||||
}
|
||||
return ret[1:]
|
||||
}
|
||||
@ -942,11 +942,11 @@ func (cfg Config) V2DeprecationEffective() config.V2DeprecationEnum {
|
||||
}
|
||||
|
||||
func (cfg Config) defaultPeerHost() bool {
|
||||
return len(cfg.APUrls) == 1 && cfg.APUrls[0].String() == DefaultInitialAdvertisePeerURLs
|
||||
return len(cfg.AdvertisePeerUrls) == 1 && cfg.AdvertisePeerUrls[0].String() == DefaultInitialAdvertisePeerURLs
|
||||
}
|
||||
|
||||
func (cfg Config) defaultClientHost() bool {
|
||||
return len(cfg.ACUrls) == 1 && cfg.ACUrls[0].String() == DefaultAdvertiseClientURLs
|
||||
return len(cfg.AdvertiseClientUrls) == 1 && cfg.AdvertiseClientUrls[0].String() == DefaultAdvertiseClientURLs
|
||||
}
|
||||
|
||||
func (cfg *Config) ClientSelfCert() (err error) {
|
||||
@ -957,8 +957,8 @@ func (cfg *Config) ClientSelfCert() (err error) {
|
||||
cfg.logger.Warn("ignoring client auto TLS since certs given")
|
||||
return nil
|
||||
}
|
||||
chosts := make([]string, len(cfg.LCUrls))
|
||||
for i, u := range cfg.LCUrls {
|
||||
chosts := make([]string, len(cfg.ListenClientUrls))
|
||||
for i, u := range cfg.ListenClientUrls {
|
||||
chosts[i] = u.Host
|
||||
}
|
||||
cfg.ClientTLSInfo, err = transport.SelfCert(cfg.logger, filepath.Join(cfg.Dir, "fixtures", "client"), chosts, cfg.SelfSignedCertValidity)
|
||||
@ -976,8 +976,8 @@ func (cfg *Config) PeerSelfCert() (err error) {
|
||||
cfg.logger.Warn("ignoring peer auto TLS since certs given")
|
||||
return nil
|
||||
}
|
||||
phosts := make([]string, len(cfg.LPUrls))
|
||||
for i, u := range cfg.LPUrls {
|
||||
phosts := make([]string, len(cfg.ListenPeerUrls))
|
||||
for i, u := range cfg.ListenPeerUrls {
|
||||
phosts[i] = u.Host
|
||||
}
|
||||
cfg.PeerTLSInfo, err = transport.SelfCert(cfg.logger, filepath.Join(cfg.Dir, "fixtures", "peer"), phosts, cfg.SelfSignedCertValidity)
|
||||
@ -1005,9 +1005,9 @@ func (cfg *Config) UpdateDefaultClusterFromName(defaultInitialCluster string) (s
|
||||
}
|
||||
|
||||
used := false
|
||||
pip, pport := cfg.LPUrls[0].Hostname(), cfg.LPUrls[0].Port()
|
||||
pip, pport := cfg.ListenPeerUrls[0].Hostname(), cfg.ListenPeerUrls[0].Port()
|
||||
if cfg.defaultPeerHost() && pip == "0.0.0.0" {
|
||||
cfg.APUrls[0] = url.URL{Scheme: cfg.APUrls[0].Scheme, Host: fmt.Sprintf("%s:%s", defaultHostname, pport)}
|
||||
cfg.AdvertisePeerUrls[0] = url.URL{Scheme: cfg.AdvertisePeerUrls[0].Scheme, Host: fmt.Sprintf("%s:%s", defaultHostname, pport)}
|
||||
used = true
|
||||
}
|
||||
// update 'initial-cluster' when only the name is specified (e.g. 'etcd --name=abc')
|
||||
@ -1015,9 +1015,9 @@ func (cfg *Config) UpdateDefaultClusterFromName(defaultInitialCluster string) (s
|
||||
cfg.InitialCluster = cfg.InitialClusterFromName(cfg.Name)
|
||||
}
|
||||
|
||||
cip, cport := cfg.LCUrls[0].Hostname(), cfg.LCUrls[0].Port()
|
||||
cip, cport := cfg.ListenClientUrls[0].Hostname(), cfg.ListenClientUrls[0].Port()
|
||||
if cfg.defaultClientHost() && cip == "0.0.0.0" {
|
||||
cfg.ACUrls[0] = url.URL{Scheme: cfg.ACUrls[0].Scheme, Host: fmt.Sprintf("%s:%s", defaultHostname, cport)}
|
||||
cfg.AdvertiseClientUrls[0] = url.URL{Scheme: cfg.AdvertiseClientUrls[0].Scheme, Host: fmt.Sprintf("%s:%s", defaultHostname, cport)}
|
||||
used = true
|
||||
}
|
||||
dhost := defaultHostname
|
||||
@ -1062,34 +1062,34 @@ func checkHostURLs(urls []url.URL) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cfg *Config) getAPURLs() (ss []string) {
|
||||
ss = make([]string, len(cfg.APUrls))
|
||||
for i := range cfg.APUrls {
|
||||
ss[i] = cfg.APUrls[i].String()
|
||||
func (cfg *Config) getAdvertisePeerUrls() (ss []string) {
|
||||
ss = make([]string, len(cfg.AdvertisePeerUrls))
|
||||
for i := range cfg.AdvertisePeerUrls {
|
||||
ss[i] = cfg.AdvertisePeerUrls[i].String()
|
||||
}
|
||||
return ss
|
||||
}
|
||||
|
||||
func (cfg *Config) getLPURLs() (ss []string) {
|
||||
ss = make([]string, len(cfg.LPUrls))
|
||||
for i := range cfg.LPUrls {
|
||||
ss[i] = cfg.LPUrls[i].String()
|
||||
func (cfg *Config) getListenPeerUrls() (ss []string) {
|
||||
ss = make([]string, len(cfg.ListenPeerUrls))
|
||||
for i := range cfg.ListenPeerUrls {
|
||||
ss[i] = cfg.ListenPeerUrls[i].String()
|
||||
}
|
||||
return ss
|
||||
}
|
||||
|
||||
func (cfg *Config) getACURLs() (ss []string) {
|
||||
ss = make([]string, len(cfg.ACUrls))
|
||||
for i := range cfg.ACUrls {
|
||||
ss[i] = cfg.ACUrls[i].String()
|
||||
func (cfg *Config) getAdvertiseClientUrls() (ss []string) {
|
||||
ss = make([]string, len(cfg.AdvertiseClientUrls))
|
||||
for i := range cfg.AdvertiseClientUrls {
|
||||
ss[i] = cfg.AdvertiseClientUrls[i].String()
|
||||
}
|
||||
return ss
|
||||
}
|
||||
|
||||
func (cfg *Config) getLCURLs() (ss []string) {
|
||||
ss = make([]string, len(cfg.LCUrls))
|
||||
for i := range cfg.LCUrls {
|
||||
ss[i] = cfg.LCUrls[i].String()
|
||||
func (cfg *Config) getListenClientUrls() (ss []string) {
|
||||
ss = make([]string, len(cfg.ListenClientUrls))
|
||||
for i := range cfg.ListenClientUrls {
|
||||
ss[i] = cfg.ListenClientUrls[i].String()
|
||||
}
|
||||
return ss
|
||||
}
|
||||
|
@ -92,12 +92,12 @@ func TestConfigFileOtherFields(t *testing.T) {
|
||||
func TestUpdateDefaultClusterFromName(t *testing.T) {
|
||||
cfg := NewConfig()
|
||||
defaultInitialCluster := cfg.InitialCluster
|
||||
oldscheme := cfg.APUrls[0].Scheme
|
||||
origpeer := cfg.APUrls[0].String()
|
||||
origadvc := cfg.ACUrls[0].String()
|
||||
oldscheme := cfg.AdvertisePeerUrls[0].Scheme
|
||||
origpeer := cfg.AdvertisePeerUrls[0].String()
|
||||
origadvc := cfg.AdvertiseClientUrls[0].String()
|
||||
|
||||
cfg.Name = "abc"
|
||||
lpport := cfg.LPUrls[0].Port()
|
||||
lpport := cfg.ListenPeerUrls[0].Port()
|
||||
|
||||
// in case of 'etcd --name=abc'
|
||||
exp := fmt.Sprintf("%s=%s://localhost:%s", cfg.Name, oldscheme, lpport)
|
||||
@ -106,12 +106,12 @@ func TestUpdateDefaultClusterFromName(t *testing.T) {
|
||||
t.Fatalf("initial-cluster expected %q, got %q", exp, cfg.InitialCluster)
|
||||
}
|
||||
// advertise peer URL should not be affected
|
||||
if origpeer != cfg.APUrls[0].String() {
|
||||
t.Fatalf("advertise peer url expected %q, got %q", origadvc, cfg.APUrls[0].String())
|
||||
if origpeer != cfg.AdvertisePeerUrls[0].String() {
|
||||
t.Fatalf("advertise peer url expected %q, got %q", origadvc, cfg.AdvertisePeerUrls[0].String())
|
||||
}
|
||||
// advertise client URL should not be affected
|
||||
if origadvc != cfg.ACUrls[0].String() {
|
||||
t.Fatalf("advertise client url expected %q, got %q", origadvc, cfg.ACUrls[0].String())
|
||||
if origadvc != cfg.AdvertiseClientUrls[0].String() {
|
||||
t.Fatalf("advertise client url expected %q, got %q", origadvc, cfg.AdvertiseClientUrls[0].String())
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,17 +124,17 @@ func TestUpdateDefaultClusterFromNameOverwrite(t *testing.T) {
|
||||
|
||||
cfg := NewConfig()
|
||||
defaultInitialCluster := cfg.InitialCluster
|
||||
oldscheme := cfg.APUrls[0].Scheme
|
||||
origadvc := cfg.ACUrls[0].String()
|
||||
oldscheme := cfg.AdvertisePeerUrls[0].Scheme
|
||||
origadvc := cfg.AdvertiseClientUrls[0].String()
|
||||
|
||||
cfg.Name = "abc"
|
||||
lpport := cfg.LPUrls[0].Port()
|
||||
cfg.LPUrls[0] = url.URL{Scheme: cfg.LPUrls[0].Scheme, Host: fmt.Sprintf("0.0.0.0:%s", lpport)}
|
||||
lpport := cfg.ListenPeerUrls[0].Port()
|
||||
cfg.ListenPeerUrls[0] = url.URL{Scheme: cfg.ListenPeerUrls[0].Scheme, Host: fmt.Sprintf("0.0.0.0:%s", lpport)}
|
||||
dhost, _ := cfg.UpdateDefaultClusterFromName(defaultInitialCluster)
|
||||
if dhost != defaultHostname {
|
||||
t.Fatalf("expected default host %q, got %q", defaultHostname, dhost)
|
||||
}
|
||||
aphost, apport := cfg.APUrls[0].Hostname(), cfg.APUrls[0].Port()
|
||||
aphost, apport := cfg.AdvertisePeerUrls[0].Hostname(), cfg.AdvertisePeerUrls[0].Port()
|
||||
if apport != lpport {
|
||||
t.Fatalf("advertise peer url got different port %s, expected %s", apport, lpport)
|
||||
}
|
||||
@ -147,8 +147,8 @@ func TestUpdateDefaultClusterFromNameOverwrite(t *testing.T) {
|
||||
}
|
||||
|
||||
// advertise client URL should not be affected
|
||||
if origadvc != cfg.ACUrls[0].String() {
|
||||
t.Fatalf("advertise-client-url expected %q, got %q", origadvc, cfg.ACUrls[0].String())
|
||||
if origadvc != cfg.AdvertiseClientUrls[0].String() {
|
||||
t.Fatalf("advertise-client-url expected %q, got %q", origadvc, cfg.AdvertiseClientUrls[0].String())
|
||||
}
|
||||
}
|
||||
|
||||
@ -282,7 +282,7 @@ func TestPeerURLsMapAndTokenFromSRV(t *testing.T) {
|
||||
cfg.InitialCluster = ""
|
||||
cfg.InitialClusterToken = ""
|
||||
cfg.DNSCluster = "example.com"
|
||||
cfg.APUrls = types.MustNewURLs(tt.apurls)
|
||||
cfg.AdvertisePeerUrls = types.MustNewURLs(tt.apurls)
|
||||
|
||||
if err := cfg.Validate(); err != nil {
|
||||
t.Errorf("#%d: failed to validate test Config: %v", i, err)
|
||||
|
@ -120,7 +120,7 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {
|
||||
}
|
||||
e.cfg.logger.Info(
|
||||
"configuring peer listeners",
|
||||
zap.Strings("listen-peer-urls", e.cfg.getLPURLs()),
|
||||
zap.Strings("listen-peer-urls", e.cfg.getListenPeerUrls()),
|
||||
)
|
||||
if e.Peers, err = configurePeerListeners(cfg); err != nil {
|
||||
return e, err
|
||||
@ -128,7 +128,7 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {
|
||||
|
||||
e.cfg.logger.Info(
|
||||
"configuring client listeners",
|
||||
zap.Strings("listen-client-urls", e.cfg.getLCURLs()),
|
||||
zap.Strings("listen-client-urls", e.cfg.getListenClientUrls()),
|
||||
)
|
||||
if e.sctxs, err = configureClientListeners(cfg); err != nil {
|
||||
return e, err
|
||||
@ -164,8 +164,8 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {
|
||||
|
||||
srvcfg := config.ServerConfig{
|
||||
Name: cfg.Name,
|
||||
ClientURLs: cfg.ACUrls,
|
||||
PeerURLs: cfg.APUrls,
|
||||
ClientURLs: cfg.AdvertiseClientUrls,
|
||||
PeerURLs: cfg.AdvertisePeerUrls,
|
||||
DataDir: cfg.Dir,
|
||||
DedicatedWALDir: cfg.WalDir,
|
||||
SnapshotCount: cfg.SnapshotCount,
|
||||
@ -278,10 +278,10 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {
|
||||
e.cfg.logger.Info(
|
||||
"now serving peer/client/metrics",
|
||||
zap.String("local-member-id", e.Server.MemberId().String()),
|
||||
zap.Strings("initial-advertise-peer-urls", e.cfg.getAPURLs()),
|
||||
zap.Strings("listen-peer-urls", e.cfg.getLPURLs()),
|
||||
zap.Strings("advertise-client-urls", e.cfg.getACURLs()),
|
||||
zap.Strings("listen-client-urls", e.cfg.getLCURLs()),
|
||||
zap.Strings("initial-advertise-peer-urls", e.cfg.getAdvertisePeerUrls()),
|
||||
zap.Strings("listen-peer-urls", e.cfg.getListenPeerUrls()),
|
||||
zap.Strings("advertise-client-urls", e.cfg.getAdvertiseClientUrls()),
|
||||
zap.Strings("listen-client-urls", e.cfg.getListenClientUrls()),
|
||||
zap.Strings("listen-metrics-urls", e.cfg.getMetricsURLs()),
|
||||
)
|
||||
serving = true
|
||||
@ -330,10 +330,10 @@ func print(lg *zap.Logger, ec Config, sc config.ServerConfig, memberInitialized
|
||||
zap.Uint("max-wals", sc.MaxWALFiles),
|
||||
zap.Uint("max-snapshots", sc.MaxSnapFiles),
|
||||
zap.Uint64("snapshot-catchup-entries", sc.SnapshotCatchUpEntries),
|
||||
zap.Strings("initial-advertise-peer-urls", ec.getAPURLs()),
|
||||
zap.Strings("listen-peer-urls", ec.getLPURLs()),
|
||||
zap.Strings("advertise-client-urls", ec.getACURLs()),
|
||||
zap.Strings("listen-client-urls", ec.getLCURLs()),
|
||||
zap.Strings("initial-advertise-peer-urls", ec.getAdvertisePeerUrls()),
|
||||
zap.Strings("listen-peer-urls", ec.getListenPeerUrls()),
|
||||
zap.Strings("advertise-client-urls", ec.getAdvertiseClientUrls()),
|
||||
zap.Strings("listen-client-urls", ec.getListenClientUrls()),
|
||||
zap.Strings("listen-metrics-urls", ec.getMetricsURLs()),
|
||||
zap.Strings("cors", cors),
|
||||
zap.Strings("host-whitelist", hss),
|
||||
@ -385,8 +385,8 @@ func (e *Etcd) Close() {
|
||||
fields := []zap.Field{
|
||||
zap.String("name", e.cfg.Name),
|
||||
zap.String("data-dir", e.cfg.Dir),
|
||||
zap.Strings("advertise-peer-urls", e.cfg.getAPURLs()),
|
||||
zap.Strings("advertise-client-urls", e.cfg.getACURLs()),
|
||||
zap.Strings("advertise-peer-urls", e.cfg.getAdvertisePeerUrls()),
|
||||
zap.Strings("advertise-client-urls", e.cfg.getAdvertiseClientUrls()),
|
||||
}
|
||||
lg := e.GetLogger()
|
||||
lg.Info("closing etcd server", fields...)
|
||||
@ -508,7 +508,7 @@ func configurePeerListeners(cfg *Config) (peers []*peerListener, err error) {
|
||||
)
|
||||
}
|
||||
|
||||
peers = make([]*peerListener, len(cfg.LPUrls))
|
||||
peers = make([]*peerListener, len(cfg.ListenPeerUrls))
|
||||
defer func() {
|
||||
if err == nil {
|
||||
return
|
||||
@ -517,7 +517,7 @@ func configurePeerListeners(cfg *Config) (peers []*peerListener, err error) {
|
||||
if peers[i] != nil && peers[i].close != nil {
|
||||
cfg.logger.Warn(
|
||||
"closing peer listener",
|
||||
zap.String("address", cfg.LPUrls[i].String()),
|
||||
zap.String("address", cfg.ListenPeerUrls[i].String()),
|
||||
zap.Error(err),
|
||||
)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
@ -527,7 +527,7 @@ func configurePeerListeners(cfg *Config) (peers []*peerListener, err error) {
|
||||
}
|
||||
}()
|
||||
|
||||
for i, u := range cfg.LPUrls {
|
||||
for i, u := range cfg.ListenPeerUrls {
|
||||
if u.Scheme == "http" {
|
||||
if !cfg.PeerTLSInfo.Empty() {
|
||||
cfg.logger.Warn("scheme is HTTP while key and cert files are present; ignoring key and cert files", zap.String("peer-url", u.String()))
|
||||
@ -618,7 +618,7 @@ func configureClientListeners(cfg *Config) (sctxs map[string]*serveCtx, err erro
|
||||
}
|
||||
|
||||
sctxs = make(map[string]*serveCtx)
|
||||
for _, u := range cfg.LCUrls {
|
||||
for _, u := range cfg.ListenClientUrls {
|
||||
sctx := newServeCtx(cfg.logger)
|
||||
if u.Scheme == "http" || u.Scheme == "unix" {
|
||||
if !cfg.ClientTLSInfo.Empty() {
|
||||
|
@ -33,8 +33,8 @@ func TestStartEtcdWrongToken(t *testing.T) {
|
||||
urls := newEmbedURLs(2)
|
||||
curls := []url.URL{urls[0]}
|
||||
purls := []url.URL{urls[1]}
|
||||
cfg.LCUrls, cfg.ACUrls = curls, curls
|
||||
cfg.LPUrls, cfg.APUrls = purls, purls
|
||||
cfg.ListenClientUrls, cfg.AdvertiseClientUrls = curls, curls
|
||||
cfg.ListenPeerUrls, cfg.AdvertisePeerUrls = purls, purls
|
||||
cfg.InitialCluster = ""
|
||||
for i := range purls {
|
||||
cfg.InitialCluster += ",default=" + purls[i].String()
|
||||
|
@ -383,10 +383,10 @@ func (cfg *config) configFromCmdLine() error {
|
||||
lg.Info(fmt.Sprintf("raft-write-timeout increased to minimum value: %v", rafthttp.DefaultConnWriteTimeout))
|
||||
}
|
||||
|
||||
cfg.ec.LPUrls = flags.UniqueURLsFromFlag(cfg.cf.flagSet, "listen-peer-urls")
|
||||
cfg.ec.APUrls = flags.UniqueURLsFromFlag(cfg.cf.flagSet, "initial-advertise-peer-urls")
|
||||
cfg.ec.LCUrls = flags.UniqueURLsFromFlag(cfg.cf.flagSet, "listen-client-urls")
|
||||
cfg.ec.ACUrls = flags.UniqueURLsFromFlag(cfg.cf.flagSet, "advertise-client-urls")
|
||||
cfg.ec.ListenPeerUrls = flags.UniqueURLsFromFlag(cfg.cf.flagSet, "listen-peer-urls")
|
||||
cfg.ec.AdvertisePeerUrls = flags.UniqueURLsFromFlag(cfg.cf.flagSet, "initial-advertise-peer-urls")
|
||||
cfg.ec.ListenClientUrls = flags.UniqueURLsFromFlag(cfg.cf.flagSet, "listen-client-urls")
|
||||
cfg.ec.AdvertiseClientUrls = flags.UniqueURLsFromFlag(cfg.cf.flagSet, "advertise-client-urls")
|
||||
cfg.ec.ListenMetricsUrls = flags.UniqueURLsFromFlag(cfg.cf.flagSet, "listen-metrics-urls")
|
||||
|
||||
cfg.ec.DiscoveryCfg.Endpoints = flags.UniqueStringsFromFlag(cfg.cf.flagSet, "discovery-endpoints")
|
||||
@ -407,7 +407,7 @@ func (cfg *config) configFromCmdLine() error {
|
||||
// disable default advertise-client-urls if lcurls is set
|
||||
missingAC := flags.IsSet(cfg.cf.flagSet, "listen-client-urls") && !flags.IsSet(cfg.cf.flagSet, "advertise-client-urls")
|
||||
if missingAC {
|
||||
cfg.ec.ACUrls = nil
|
||||
cfg.ec.AdvertiseClientUrls = nil
|
||||
}
|
||||
|
||||
// disable default initial-cluster if discovery is set
|
||||
|
@ -58,9 +58,9 @@ func TestConfigFileMemberFields(t *testing.T) {
|
||||
Name string `json:"name"`
|
||||
SnapshotCount uint64 `json:"snapshot-count"`
|
||||
SnapshotCatchUpEntries uint64 `json:"experimental-snapshot-catch-up-entries"`
|
||||
LPUrls string `json:"listen-peer-urls"`
|
||||
LCUrls string `json:"listen-client-urls"`
|
||||
AcurlsCfgFile string `json:"advertise-client-urls"`
|
||||
ListenPeerUrls string `json:"listen-peer-urls"`
|
||||
ListenClientUrls string `json:"listen-client-urls"`
|
||||
AdvertiseClientUrls string `json:"advertise-client-urls"`
|
||||
}{
|
||||
"testdir",
|
||||
10,
|
||||
@ -396,8 +396,8 @@ func mustCreateCfgFile(t *testing.T, b []byte) *os.File {
|
||||
func validateMemberFlags(t *testing.T, cfg *config) {
|
||||
wcfg := &embed.Config{
|
||||
Dir: "testdir",
|
||||
LPUrls: []url.URL{{Scheme: "http", Host: "localhost:8000"}, {Scheme: "https", Host: "localhost:8001"}},
|
||||
LCUrls: []url.URL{{Scheme: "http", Host: "localhost:7000"}, {Scheme: "https", Host: "localhost:7001"}},
|
||||
ListenPeerUrls: []url.URL{{Scheme: "http", Host: "localhost:8000"}, {Scheme: "https", Host: "localhost:8001"}},
|
||||
ListenClientUrls: []url.URL{{Scheme: "http", Host: "localhost:7000"}, {Scheme: "https", Host: "localhost:7001"}},
|
||||
MaxSnapFiles: 10,
|
||||
MaxWalFiles: 10,
|
||||
Name: "testname",
|
||||
@ -423,18 +423,18 @@ func validateMemberFlags(t *testing.T, cfg *config) {
|
||||
if cfg.ec.SnapshotCatchUpEntries != wcfg.SnapshotCatchUpEntries {
|
||||
t.Errorf("snapshot catch up entries = %v, want %v", cfg.ec.SnapshotCatchUpEntries, wcfg.SnapshotCatchUpEntries)
|
||||
}
|
||||
if !reflect.DeepEqual(cfg.ec.LPUrls, wcfg.LPUrls) {
|
||||
t.Errorf("listen-peer-urls = %v, want %v", cfg.ec.LPUrls, wcfg.LPUrls)
|
||||
if !reflect.DeepEqual(cfg.ec.ListenPeerUrls, wcfg.ListenPeerUrls) {
|
||||
t.Errorf("listen-peer-urls = %v, want %v", cfg.ec.ListenPeerUrls, wcfg.ListenPeerUrls)
|
||||
}
|
||||
if !reflect.DeepEqual(cfg.ec.LCUrls, wcfg.LCUrls) {
|
||||
t.Errorf("listen-client-urls = %v, want %v", cfg.ec.LCUrls, wcfg.LCUrls)
|
||||
if !reflect.DeepEqual(cfg.ec.ListenClientUrls, wcfg.ListenClientUrls) {
|
||||
t.Errorf("listen-client-urls = %v, want %v", cfg.ec.ListenClientUrls, wcfg.ListenClientUrls)
|
||||
}
|
||||
}
|
||||
|
||||
func validateClusteringFlags(t *testing.T, cfg *config) {
|
||||
wcfg := newConfig()
|
||||
wcfg.ec.APUrls = []url.URL{{Scheme: "http", Host: "localhost:8000"}, {Scheme: "https", Host: "localhost:8001"}}
|
||||
wcfg.ec.ACUrls = []url.URL{{Scheme: "http", Host: "localhost:7000"}, {Scheme: "https", Host: "localhost:7001"}}
|
||||
wcfg.ec.AdvertisePeerUrls = []url.URL{{Scheme: "http", Host: "localhost:8000"}, {Scheme: "https", Host: "localhost:8001"}}
|
||||
wcfg.ec.AdvertiseClientUrls = []url.URL{{Scheme: "http", Host: "localhost:7000"}, {Scheme: "https", Host: "localhost:7001"}}
|
||||
wcfg.ec.ClusterState = embed.ClusterStateFlagExisting
|
||||
wcfg.ec.InitialCluster = "0=http://localhost:8000"
|
||||
wcfg.ec.InitialClusterToken = "etcdtest"
|
||||
@ -448,10 +448,10 @@ func validateClusteringFlags(t *testing.T, cfg *config) {
|
||||
if cfg.ec.InitialClusterToken != wcfg.ec.InitialClusterToken {
|
||||
t.Errorf("initialClusterToken = %v, want %v", cfg.ec.InitialClusterToken, wcfg.ec.InitialClusterToken)
|
||||
}
|
||||
if !reflect.DeepEqual(cfg.ec.APUrls, wcfg.ec.APUrls) {
|
||||
t.Errorf("initial-advertise-peer-urls = %v, want %v", cfg.ec.APUrls, wcfg.ec.APUrls)
|
||||
if !reflect.DeepEqual(cfg.ec.AdvertisePeerUrls, wcfg.ec.AdvertisePeerUrls) {
|
||||
t.Errorf("initial-advertise-peer-urls = %v, want %v", cfg.ec.AdvertisePeerUrls, wcfg.ec.AdvertisePeerUrls)
|
||||
}
|
||||
if !reflect.DeepEqual(cfg.ec.ACUrls, wcfg.ec.ACUrls) {
|
||||
t.Errorf("advertise-client-urls = %v, want %v", cfg.ec.ACUrls, wcfg.ec.ACUrls)
|
||||
if !reflect.DeepEqual(cfg.ec.AdvertiseClientUrls, wcfg.ec.AdvertiseClientUrls) {
|
||||
t.Errorf("advertise-client-urls = %v, want %v", cfg.ec.AdvertiseClientUrls, wcfg.ec.AdvertiseClientUrls)
|
||||
}
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ func startEtcdOrProxyV2(args []string) {
|
||||
if cfg.ec.InitialCluster == cfg.ec.InitialClusterFromName(cfg.ec.Name) {
|
||||
lg.Warn("forgot to set --initial-cluster?")
|
||||
}
|
||||
if types.URLs(cfg.ec.APUrls).String() == embed.DefaultInitialAdvertisePeerURLs {
|
||||
if types.URLs(cfg.ec.AdvertisePeerUrls).String() == embed.DefaultInitialAdvertisePeerURLs {
|
||||
lg.Warn("forgot to set --initial-advertise-peer-urls?")
|
||||
}
|
||||
if cfg.ec.InitialCluster == cfg.ec.InitialClusterFromName(cfg.ec.Name) && len(cfg.ec.Durl) == 0 && len(cfg.ec.DiscoveryCfg.Endpoints) == 0 {
|
||||
|
@ -80,8 +80,8 @@ func newEmbedConfig(t *testing.T) *embed.Config {
|
||||
cURLs, pURLs := urls[:clusterN], urls[clusterN:]
|
||||
cfg := integration2.NewEmbedConfig(t, "default")
|
||||
cfg.ClusterState = "new"
|
||||
cfg.LCUrls, cfg.ACUrls = cURLs, cURLs
|
||||
cfg.LPUrls, cfg.APUrls = pURLs, pURLs
|
||||
cfg.ListenClientUrls, cfg.AdvertiseClientUrls = cURLs, cURLs
|
||||
cfg.ListenPeerUrls, cfg.AdvertisePeerUrls = pURLs, pURLs
|
||||
cfg.InitialCluster = fmt.Sprintf("%s=%s", cfg.Name, pURLs[0].String())
|
||||
return cfg
|
||||
}
|
||||
@ -104,7 +104,7 @@ func createSnapshotFile(t *testing.T, cfg *embed.Config, kvs []kv) (version stri
|
||||
t.Fatalf("failed to start embed.Etcd for creating snapshots")
|
||||
}
|
||||
|
||||
ccfg := clientv3.Config{Endpoints: []string{cfg.ACUrls[0].String()}}
|
||||
ccfg := clientv3.Config{Endpoints: []string{cfg.AdvertiseClientUrls[0].String()}}
|
||||
cli, err := integration2.NewClient(t, ccfg)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
@ -78,7 +78,7 @@ func TestEmbedEtcd(t *testing.T) {
|
||||
|
||||
tests[0].cfg.Durl = "abc"
|
||||
setupEmbedCfg(&tests[1].cfg, []url.URL{urls[0]}, []url.URL{urls[1]})
|
||||
tests[1].cfg.ACUrls = nil
|
||||
tests[1].cfg.AdvertiseClientUrls = nil
|
||||
tests[2].cfg.TickMs = tests[2].cfg.ElectionMs - 1
|
||||
tests[3].cfg.ElectionMs = 999999
|
||||
setupEmbedCfg(&tests[4].cfg, []url.URL{urls[2]}, []url.URL{urls[3]})
|
||||
@ -86,8 +86,8 @@ func TestEmbedEtcd(t *testing.T) {
|
||||
setupEmbedCfg(&tests[6].cfg, []url.URL{urls[7], urls[8]}, []url.URL{urls[9]})
|
||||
|
||||
dnsURL, _ := url.Parse("http://whatever.test:12345")
|
||||
tests[7].cfg.LCUrls = []url.URL{*dnsURL}
|
||||
tests[8].cfg.LPUrls = []url.URL{*dnsURL}
|
||||
tests[7].cfg.ListenClientUrls = []url.URL{*dnsURL}
|
||||
tests[8].cfg.ListenPeerUrls = []url.URL{*dnsURL}
|
||||
|
||||
dir := filepath.Join(t.TempDir(), "embed-etcd")
|
||||
|
||||
@ -202,8 +202,8 @@ func setupEmbedCfg(cfg *embed.Config, curls []url.URL, purls []url.URL) {
|
||||
cfg.LogOutputs = []string{"/dev/null"}
|
||||
|
||||
cfg.ClusterState = "new"
|
||||
cfg.LCUrls, cfg.ACUrls = curls, curls
|
||||
cfg.LPUrls, cfg.APUrls = purls, purls
|
||||
cfg.ListenClientUrls, cfg.AdvertiseClientUrls = curls, curls
|
||||
cfg.ListenPeerUrls, cfg.AdvertisePeerUrls = purls, purls
|
||||
cfg.InitialCluster = ""
|
||||
for i := range purls {
|
||||
cfg.InitialCluster += ",default=" + purls[i].String()
|
||||
|
@ -66,8 +66,8 @@ func TestSnapshotV3RestoreMultiMemberAdd(t *testing.T) {
|
||||
cfg := integration2.NewEmbedConfig(t, "3")
|
||||
cfg.InitialClusterToken = testClusterTkn
|
||||
cfg.ClusterState = "existing"
|
||||
cfg.LCUrls, cfg.ACUrls = newCURLs, newCURLs
|
||||
cfg.LPUrls, cfg.APUrls = newPURLs, newPURLs
|
||||
cfg.ListenClientUrls, cfg.AdvertiseClientUrls = newCURLs, newCURLs
|
||||
cfg.ListenPeerUrls, cfg.AdvertisePeerUrls = newPURLs, newPURLs
|
||||
cfg.InitialCluster = ""
|
||||
for i := 0; i < clusterN; i++ {
|
||||
cfg.InitialCluster += fmt.Sprintf(",%d=%s", i, pURLs[i].String())
|
||||
|
@ -48,8 +48,8 @@ func TestSnapshotV3RestoreSingle(t *testing.T) {
|
||||
cfg := integration2.NewEmbedConfig(t, "s1")
|
||||
cfg.InitialClusterToken = testClusterTkn
|
||||
cfg.ClusterState = "existing"
|
||||
cfg.LCUrls, cfg.ACUrls = cURLs, cURLs
|
||||
cfg.LPUrls, cfg.APUrls = pURLs, pURLs
|
||||
cfg.ListenClientUrls, cfg.AdvertiseClientUrls = cURLs, cURLs
|
||||
cfg.ListenPeerUrls, cfg.AdvertisePeerUrls = pURLs, pURLs
|
||||
cfg.InitialCluster = fmt.Sprintf("%s=%s", cfg.Name, pURLs[0].String())
|
||||
|
||||
sp := snapshot.NewV3(zaptest.NewLogger(t))
|
||||
@ -82,7 +82,7 @@ func TestSnapshotV3RestoreSingle(t *testing.T) {
|
||||
}
|
||||
|
||||
var cli *clientv3.Client
|
||||
cli, err = integration2.NewClient(t, clientv3.Config{Endpoints: []string{cfg.ACUrls[0].String()}})
|
||||
cli, err = integration2.NewClient(t, clientv3.Config{Endpoints: []string{cfg.AdvertiseClientUrls[0].String()}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -177,8 +177,8 @@ func createSnapshotFile(t *testing.T, kvs []kv) string {
|
||||
|
||||
cfg := integration2.NewEmbedConfig(t, "default")
|
||||
cfg.ClusterState = "new"
|
||||
cfg.LCUrls, cfg.ACUrls = cURLs, cURLs
|
||||
cfg.LPUrls, cfg.APUrls = pURLs, pURLs
|
||||
cfg.ListenClientUrls, cfg.AdvertiseClientUrls = cURLs, cURLs
|
||||
cfg.ListenPeerUrls, cfg.AdvertisePeerUrls = pURLs, pURLs
|
||||
cfg.InitialCluster = fmt.Sprintf("%s=%s", cfg.Name, pURLs[0].String())
|
||||
srv, err := embed.StartEtcd(cfg)
|
||||
if err != nil {
|
||||
@ -193,7 +193,7 @@ func createSnapshotFile(t *testing.T, kvs []kv) string {
|
||||
t.Fatalf("failed to start embed.Etcd for creating snapshots")
|
||||
}
|
||||
|
||||
ccfg := clientv3.Config{Endpoints: []string{cfg.ACUrls[0].String()}}
|
||||
ccfg := clientv3.Config{Endpoints: []string{cfg.AdvertiseClientUrls[0].String()}}
|
||||
cli, err := integration2.NewClient(t, ccfg)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@ -237,8 +237,8 @@ func restoreCluster(t *testing.T, clusterN int, dbPath string) (
|
||||
cfg := integration2.NewEmbedConfig(t, fmt.Sprintf("m%d", i))
|
||||
cfg.InitialClusterToken = testClusterTkn
|
||||
cfg.ClusterState = "existing"
|
||||
cfg.LCUrls, cfg.ACUrls = []url.URL{cURLs[i]}, []url.URL{cURLs[i]}
|
||||
cfg.LPUrls, cfg.APUrls = []url.URL{pURLs[i]}, []url.URL{pURLs[i]}
|
||||
cfg.ListenClientUrls, cfg.AdvertiseClientUrls = []url.URL{cURLs[i]}, []url.URL{cURLs[i]}
|
||||
cfg.ListenPeerUrls, cfg.AdvertisePeerUrls = []url.URL{pURLs[i]}, []url.URL{pURLs[i]}
|
||||
cfg.InitialCluster = ics
|
||||
|
||||
sp := snapshot.NewV3(
|
||||
|
@ -91,7 +91,7 @@ func TestTracing(t *testing.T) {
|
||||
dialOptions := []grpc.DialOption{
|
||||
grpc.WithUnaryInterceptor(otelgrpc.UnaryClientInterceptor(tracingOpts...)),
|
||||
grpc.WithStreamInterceptor(otelgrpc.StreamClientInterceptor(tracingOpts...))}
|
||||
ccfg := clientv3.Config{DialOptions: dialOptions, Endpoints: []string{cfg.ACUrls[0].String()}}
|
||||
ccfg := clientv3.Config{DialOptions: dialOptions, Endpoints: []string{cfg.AdvertiseClientUrls[0].String()}}
|
||||
cli, err := integration.NewClient(t, ccfg)
|
||||
if err != nil {
|
||||
etcdSrv.Close()
|
||||
|
@ -55,7 +55,7 @@ func TestEtcdVersionFromWAL(t *testing.T) {
|
||||
t.Fatalf("failed to wait for cluster version to become ready: %v", err)
|
||||
}
|
||||
|
||||
ccfg := clientv3.Config{Endpoints: []string{cfg.ACUrls[0].String()}}
|
||||
ccfg := clientv3.Config{Endpoints: []string{cfg.AdvertiseClientUrls[0].String()}}
|
||||
cli, err := integration.NewClient(t, ccfg)
|
||||
if err != nil {
|
||||
srv.Close()
|
||||
|
@ -50,8 +50,8 @@ func setupEmbedCfg(cfg *embed.Config, curls, purls, ics []url.URL) {
|
||||
os.RemoveAll(cfg.Dir)
|
||||
|
||||
cfg.ClusterState = "new"
|
||||
cfg.LCUrls, cfg.ACUrls = curls, curls
|
||||
cfg.LPUrls, cfg.APUrls = purls, purls
|
||||
cfg.ListenClientUrls, cfg.AdvertiseClientUrls = curls, curls
|
||||
cfg.ListenPeerUrls, cfg.AdvertisePeerUrls = purls, purls
|
||||
|
||||
cfg.InitialCluster = ""
|
||||
for i := range ics {
|
||||
|
Loading…
x
Reference in New Issue
Block a user