mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #17432 from ivanvc/release-3.4-implement-etcd-process-go-fail-client-timeout
[3.4] backport EtcdProcess GoFailClientTimeout
This commit is contained in:
commit
26620387c7
@ -101,12 +101,13 @@ type etcdProcessCluster struct {
|
||||
}
|
||||
|
||||
type etcdProcessClusterConfig struct {
|
||||
execPath string
|
||||
dataDirPath string
|
||||
keepDataDir bool
|
||||
goFailEnabled bool
|
||||
peerProxy bool
|
||||
envVars map[string]string
|
||||
execPath string
|
||||
dataDirPath string
|
||||
keepDataDir bool
|
||||
goFailEnabled bool
|
||||
goFailClientTimeout time.Duration
|
||||
peerProxy bool
|
||||
envVars map[string]string
|
||||
|
||||
clusterSize int
|
||||
|
||||
@ -348,20 +349,21 @@ func (cfg *etcdProcessClusterConfig) etcdServerProcessConfigs() []*etcdServerPro
|
||||
}
|
||||
|
||||
etcdCfgs[i] = &etcdServerProcessConfig{
|
||||
execPath: cfg.execPath,
|
||||
args: args,
|
||||
envVars: envVars,
|
||||
tlsArgs: cfg.tlsArgs(),
|
||||
dataDirPath: dataDirPath,
|
||||
keepDataDir: cfg.keepDataDir,
|
||||
name: name,
|
||||
purl: peerAdvertiseUrl,
|
||||
acurl: curl,
|
||||
murl: murl,
|
||||
initialToken: cfg.initialToken,
|
||||
clientHttpUrl: clientHttpUrl,
|
||||
goFailPort: gofailPort,
|
||||
proxy: proxyCfg,
|
||||
execPath: cfg.execPath,
|
||||
args: args,
|
||||
envVars: envVars,
|
||||
tlsArgs: cfg.tlsArgs(),
|
||||
dataDirPath: dataDirPath,
|
||||
keepDataDir: cfg.keepDataDir,
|
||||
name: name,
|
||||
purl: peerAdvertiseUrl,
|
||||
acurl: curl,
|
||||
murl: murl,
|
||||
initialToken: cfg.initialToken,
|
||||
clientHttpUrl: clientHttpUrl,
|
||||
goFailPort: gofailPort,
|
||||
goFailClientTimeout: cfg.goFailClientTimeout,
|
||||
proxy: proxyCfg,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,8 +92,9 @@ type etcdServerProcessConfig struct {
|
||||
initialToken string
|
||||
initialCluster string
|
||||
|
||||
proxy *proxy.ServerConfig
|
||||
goFailPort int
|
||||
proxy *proxy.ServerConfig
|
||||
goFailPort int
|
||||
goFailClientTimeout time.Duration
|
||||
}
|
||||
|
||||
func newEtcdServerProcess(cfg *etcdServerProcessConfig) (*etcdServerProcess, error) {
|
||||
@ -107,8 +108,12 @@ func newEtcdServerProcess(cfg *etcdServerProcessConfig) (*etcdServerProcess, err
|
||||
}
|
||||
ep := &etcdServerProcess{cfg: cfg, donec: make(chan struct{})}
|
||||
if cfg.goFailPort != 0 {
|
||||
ep.failpoints = &BinaryFailpoints{member: ep}
|
||||
ep.failpoints = &BinaryFailpoints{
|
||||
member: ep,
|
||||
clientTimeout: cfg.goFailClientTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
return ep, nil
|
||||
}
|
||||
|
||||
@ -232,6 +237,7 @@ func (ep *etcdServerProcess) Etcdctl(connType clientConnType, isAutoTLS, v2 bool
|
||||
type BinaryFailpoints struct {
|
||||
member etcdProcess
|
||||
availableCache map[string]string
|
||||
clientTimeout time.Duration
|
||||
}
|
||||
|
||||
func (f *BinaryFailpoints) SetupEnv(failpoint, payload string) error {
|
||||
@ -253,6 +259,12 @@ func (f *BinaryFailpoints) SetupHTTP(ctx context.Context, failpoint, payload str
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
httpClient := http.Client{
|
||||
Timeout: 1 * time.Second,
|
||||
}
|
||||
if f.clientTimeout != 0 {
|
||||
httpClient.Timeout = f.clientTimeout
|
||||
}
|
||||
resp, err := httpClient.Do(r)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -275,6 +287,12 @@ func (f *BinaryFailpoints) DeactivateHTTP(ctx context.Context, failpoint string)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
httpClient := http.Client{
|
||||
Timeout: 1 * time.Second,
|
||||
}
|
||||
if f.clientTimeout != 0 {
|
||||
httpClient.Timeout = f.clientTimeout
|
||||
}
|
||||
resp, err := httpClient.Do(r)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -286,10 +304,6 @@ func (f *BinaryFailpoints) DeactivateHTTP(ctx context.Context, failpoint string)
|
||||
return nil
|
||||
}
|
||||
|
||||
var httpClient = http.Client{
|
||||
Timeout: 1 * time.Second,
|
||||
}
|
||||
|
||||
func (f *BinaryFailpoints) Enabled() bool {
|
||||
_, err := failpoints(f.member)
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user