mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
fix(Dockerfile): reverted unneeded changes
fix(server/config.go): ensured params are changeable from config file and env fix(server/server.go): removed unnecessary debug line fix(server/timeout.go): removed a commented block style(server/transporter.go): put explicit vars to replace timeout expressions style(tests/server_utils.go): ran gofmt to clean up indenting
This commit is contained in:
parent
faab194247
commit
0867b33de5
@ -7,4 +7,4 @@ RUN apt-get install -y golang
|
|||||||
ADD . /opt/etcd
|
ADD . /opt/etcd
|
||||||
RUN cd /opt/etcd && ./build
|
RUN cd /opt/etcd && ./build
|
||||||
EXPOSE 4001 7001
|
EXPOSE 4001 7001
|
||||||
ENTRYPOINT ["/datastore/start.sh"]
|
ENTRYPOINT ["/opt/etcd/etcd", "-addr", "0.0.0.0:4001", "-bind-addr", "0.0.0.0"]
|
@ -67,8 +67,8 @@ type Config struct {
|
|||||||
ShowVersion bool
|
ShowVersion bool
|
||||||
Verbose bool `toml:"verbose" env:"ETCD_VERBOSE"`
|
Verbose bool `toml:"verbose" env:"ETCD_VERBOSE"`
|
||||||
VeryVerbose bool `toml:"very_verbose" env:"ETCD_VERY_VERBOSE"`
|
VeryVerbose bool `toml:"very_verbose" env:"ETCD_VERY_VERBOSE"`
|
||||||
HeartbeatTimeout int
|
HeartbeatTimeout int `toml:"peer_heartbeat_timeout" env:"ETCD_PEER_HEARTBEAT_TIMEOUT"`
|
||||||
ElectionTimeout int
|
ElectionTimeout int `toml:"peer_election_timeout" env:"ETCD_PEER_ELECTION_TIMEOUT"`
|
||||||
Peer struct {
|
Peer struct {
|
||||||
Addr string `toml:"addr" env:"ETCD_PEER_ADDR"`
|
Addr string `toml:"addr" env:"ETCD_PEER_ADDR"`
|
||||||
BindAddr string `toml:"bind_addr" env:"ETCD_PEER_BIND_ADDR"`
|
BindAddr string `toml:"bind_addr" env:"ETCD_PEER_BIND_ADDR"`
|
||||||
@ -88,6 +88,8 @@ func NewConfig() *Config {
|
|||||||
c.MaxRetryAttempts = 3
|
c.MaxRetryAttempts = 3
|
||||||
c.Peer.Addr = "127.0.0.1:7001"
|
c.Peer.Addr = "127.0.0.1:7001"
|
||||||
c.SnapshotCount = 10000
|
c.SnapshotCount = 10000
|
||||||
|
c.HeartbeatTimeout = HeartbeatTimeout
|
||||||
|
c.ElectionTimeout = ElectionTimeout
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,8 +231,8 @@ func (c *Config) LoadFlags(arguments []string) error {
|
|||||||
f.IntVar(&c.MaxResultBuffer, "max-result-buffer", c.MaxResultBuffer, "")
|
f.IntVar(&c.MaxResultBuffer, "max-result-buffer", c.MaxResultBuffer, "")
|
||||||
f.IntVar(&c.MaxRetryAttempts, "max-retry-attempts", c.MaxRetryAttempts, "")
|
f.IntVar(&c.MaxRetryAttempts, "max-retry-attempts", c.MaxRetryAttempts, "")
|
||||||
f.IntVar(&c.MaxClusterSize, "max-cluster-size", c.MaxClusterSize, "")
|
f.IntVar(&c.MaxClusterSize, "max-cluster-size", c.MaxClusterSize, "")
|
||||||
f.IntVar(&c.HeartbeatTimeout, "peer-heartbeat-timeout", HeartbeatTimeout, "")
|
f.IntVar(&c.HeartbeatTimeout, "peer-heartbeat-timeout", c.HeartbeatTimeout, "")
|
||||||
f.IntVar(&c.ElectionTimeout, "peer-election-timeout", ElectionTimeout, "")
|
f.IntVar(&c.ElectionTimeout, "peer-election-timeout", c.ElectionTimeout, "")
|
||||||
|
|
||||||
f.StringVar(&cors, "cors", "", "")
|
f.StringVar(&cors, "cors", "", "")
|
||||||
|
|
||||||
|
@ -227,7 +227,6 @@ func (s *Server) listenAndServeTLS(certFile, keyFile string) error {
|
|||||||
|
|
||||||
tlsListener := tls.NewListener(conn, config)
|
tlsListener := tls.NewListener(conn, config)
|
||||||
s.listener = tlsListener
|
s.listener = tlsListener
|
||||||
log.Debugf("etcd listening using tls key %s, cert %s", keyFile, certFile)
|
|
||||||
return s.Server.Serve(tlsListener)
|
return s.Server.Serve(tlsListener)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,16 +1,10 @@
|
|||||||
package server
|
package server
|
||||||
|
|
||||||
// import (
|
|
||||||
// "time"
|
|
||||||
// )
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// The amount of time to elapse without a heartbeat before becoming a candidate.
|
// The amount of time (ms) to elapse without a heartbeat before becoming a candidate.
|
||||||
// ElectionTimeout = 200 * time.Millisecond
|
|
||||||
ElectionTimeout = 200
|
ElectionTimeout = 200
|
||||||
|
|
||||||
// The frequency by which heartbeats are sent to followers.
|
// The frequency by which heartbeats are sent to followers.
|
||||||
//HeartbeatTimeout = 50 * time.Millisecond
|
|
||||||
HeartbeatTimeout = 50
|
HeartbeatTimeout = 50
|
||||||
|
|
||||||
RetryInterval = 10
|
RetryInterval = 10
|
||||||
|
@ -27,13 +27,17 @@ type dialer func(network, addr string) (net.Conn, error)
|
|||||||
// Create http or https transporter based on
|
// Create http or https transporter based on
|
||||||
// whether the user give the server cert and key
|
// whether the user give the server cert and key
|
||||||
func newTransporter(scheme string, tlsConf tls.Config, peerServer *PeerServer) *transporter {
|
func newTransporter(scheme string, tlsConf tls.Config, peerServer *PeerServer) *transporter {
|
||||||
|
// names for each type of timeout, for the sake of clarity
|
||||||
|
dialTimeout := time.Duration(3 * peerServer.heartbeatTimeout + peerServer.electionTimeout) * time.Millisecond
|
||||||
|
responseHeaderTimeout := time.Duration(3 * peerServer.heartbeatTimeout + peerServer.electionTimeout) * time.Millisecond
|
||||||
|
|
||||||
t := transporter{}
|
t := transporter{}
|
||||||
|
|
||||||
t.tranTimeout = time.Duration(peerServer.heartbeatTimeout) * time.Millisecond
|
t.tranTimeout = time.Duration(peerServer.heartbeatTimeout) * time.Millisecond
|
||||||
|
|
||||||
tr := &http.Transport{
|
tr := &http.Transport{
|
||||||
Dial: dialWithTimeoutFactory( time.Duration(3 * peerServer.heartbeatTimeout + peerServer.electionTimeout) * time.Millisecond),
|
Dial: dialWithTimeoutFactory(dialTimeout),
|
||||||
ResponseHeaderTimeout: time.Duration(3 * peerServer.heartbeatTimeout + peerServer.electionTimeout) * time.Millisecond,
|
ResponseHeaderTimeout: responseHeaderTimeout,
|
||||||
}
|
}
|
||||||
|
|
||||||
if scheme == "https" {
|
if scheme == "https" {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user