Compare commits

..

7 Commits

Author SHA1 Message Date
Yicheng Qin
2f6ea0a0e5 *: bump to v0.4.8 2015-03-23 13:47:10 -07:00
Kelsey Hightower
fc8020b7d6 Merge pull request #2546 from kelseyhightower/add-internal-dir-flag
etcd: add -internal-dir flag
2015-03-20 10:36:36 -07:00
Kelsey Hightower
03a99cf9b1 etcd: add -internal-dir flag
etcd supports setting the path to the etcd binary directory used for
running legacy mode and upgrades.

etcd no longer limits internal version checking to GOOS=linux.
2015-03-19 20:01:47 -07:00
Kelsey Hightower
eae1e18500 Merge pull request #2418 from kelseyhightower/release-0.4
Documentation: make -bind-addr and -peer-bind-addr docs match the code
2015-03-11 15:35:08 -07:00
Kelsey Hightower
6666b20d91 Documentation: make -bind-addr and -peer-bind-addr docs match the code
Fixes #2072.
2015-03-11 15:31:38 -07:00
Yicheng Qin
2d4592e8c5 Merge pull request #2416 from aeneby/etcd_trace_fix
config: Capitalise strTrace field name
2015-03-03 21:05:23 -08:00
Aaron Sowry
12fec1f936 config: Capitalise strTrace field name
Field names not beginning with a capital letter will not be exported
and therefore cannot be assigned values. This breaks the usage of
ETCD_TRACE when debugging.

Fixes #1970
2015-03-03 14:52:08 +01:00
8 changed files with 60 additions and 58 deletions

View File

@@ -34,7 +34,7 @@ The full documentation is contained in the [API docs](https://github.com/coreos/
* `-discovery` - A URL to use for discovering the peer list. (i.e `"https://discovery.etcd.io/your-unique-key"`).
* `-http-read-timeout` - The number of seconds before an HTTP read operation is timed out.
* `-http-write-timeout` - The number of seconds before an HTTP write operation is timed out.
* `-bind-addr` - The listening hostname for client communication. Defaults to advertised IP.
* `-bind-addr` - The listening hostname for client communication. Defaults to 0.0.0.0 and the advertised port.
* `-peers` - A comma separated list of peers in the cluster (i.e `"203.0.113.101:7001,203.0.113.102:7001"`).
* `-peers-file` - The file path containing a comma separated list of peers in the cluster.
* `-ca-file` - The path of the client CAFile. Enables client cert authentication when present.
@@ -44,10 +44,11 @@ The full documentation is contained in the [API docs](https://github.com/coreos/
* `-cors` - A comma separated white list of origins for cross-origin resource sharing.
* `-cpuprofile` - The path to a file to output CPU profile data. Enables CPU profiling when present.
* `-data-dir` - The directory to store log and snapshot. Defaults to the current working directory.
* `-internal-binary-dir` - The path to the etcd internal binary directory. Defaults to `/usr/libexec/etcd/internal_versions/`.
* `-max-result-buffer` - The max size of result buffer. Defaults to `1024`.
* `-max-retry-attempts` - The max retry attempts when trying to join a cluster. Defaults to `3`.
* `-peer-addr` - The advertised public hostname:port for server communication. Defaults to `127.0.0.1:7001`.
* `-peer-bind-addr` - The listening hostname for server communication. Defaults to advertised IP.
* `-peer-bind-addr` - The listening hostname for server communication. Defaults to 0.0.0.0 and the advertised peer port.
* `-peer-ca-file` - The path of the CAFile. Enables client/peer cert authentication when present.
* `-peer-cert-file` - The cert file of the server.
* `-peer-key-file` - The key file of the server.
@@ -115,6 +116,7 @@ sync_interval = 5.0
* `ETCD_CLUSTER_HTTP_READ_TIMEOUT`
* `ETCD_CLUSTER_HTTP_WRITE_TIMEOUT`
* `ETCD_KEY_FILE`
* `ETCD_INTERNAL_BINARY_DIR`
* `ETCD_PEERS`
* `ETCD_PEERS_FILE`
* `ETCD_MAX_CLUSTER_SIZE`

View File

@@ -1,6 +1,6 @@
# etcd
README version 0.4.7
README version 0.4.8
A highly-available key value store for shared configuration and service discovery.
etcd is inspired by [Apache ZooKeeper][zookeeper] and [doozer][doozer], with a focus on being:

View File

@@ -24,6 +24,9 @@ import (
// The default location for the etcd configuration file.
const DefaultSystemConfigPath = "/etc/etcd/etcd.conf"
// The default location of the etcd internal binary directory.
const DefaultInternalBinaryDir = "/usr/libexec/etcd/internal_versions/"
// A lookup of deprecated flags to their new flag name.
var newFlagNameLookup = map[string]string{
"C": "peers",
@@ -52,32 +55,33 @@ var newFlagNameLookup = map[string]string{
type Config struct {
SystemPath string
Addr string `toml:"addr" env:"ETCD_ADDR"`
BindAddr string `toml:"bind_addr" env:"ETCD_BIND_ADDR"`
CAFile string `toml:"ca_file" env:"ETCD_CA_FILE"`
CertFile string `toml:"cert_file" env:"ETCD_CERT_FILE"`
CPUProfileFile string
CorsOrigins []string `toml:"cors" env:"ETCD_CORS"`
DataDir string `toml:"data_dir" env:"ETCD_DATA_DIR"`
Discovery string `toml:"discovery" env:"ETCD_DISCOVERY"`
Force bool
KeyFile string `toml:"key_file" env:"ETCD_KEY_FILE"`
HTTPReadTimeout float64 `toml:"http_read_timeout" env:"ETCD_HTTP_READ_TIMEOUT"`
HTTPWriteTimeout float64 `toml:"http_write_timeout" env:"ETCD_HTTP_WRITE_TIMEOUT"`
Peers []string `toml:"peers" env:"ETCD_PEERS"`
PeersFile string `toml:"peers_file" env:"ETCD_PEERS_FILE"`
MaxResultBuffer int `toml:"max_result_buffer" env:"ETCD_MAX_RESULT_BUFFER"`
MaxRetryAttempts int `toml:"max_retry_attempts" env:"ETCD_MAX_RETRY_ATTEMPTS"`
RetryInterval float64 `toml:"retry_interval" env:"ETCD_RETRY_INTERVAL"`
Name string `toml:"name" env:"ETCD_NAME"`
Snapshot bool `toml:"snapshot" env:"ETCD_SNAPSHOT"`
SnapshotCount int `toml:"snapshot_count" env:"ETCD_SNAPSHOTCOUNT"`
ShowHelp bool
ShowVersion bool
Verbose bool `toml:"verbose" env:"ETCD_VERBOSE"`
VeryVerbose bool `toml:"very_verbose" env:"ETCD_VERY_VERBOSE"`
VeryVeryVerbose bool `toml:"very_very_verbose" env:"ETCD_VERY_VERY_VERBOSE"`
Peer struct {
Addr string `toml:"addr" env:"ETCD_ADDR"`
BindAddr string `toml:"bind_addr" env:"ETCD_BIND_ADDR"`
CAFile string `toml:"ca_file" env:"ETCD_CA_FILE"`
CertFile string `toml:"cert_file" env:"ETCD_CERT_FILE"`
CPUProfileFile string
CorsOrigins []string `toml:"cors" env:"ETCD_CORS"`
DataDir string `toml:"data_dir" env:"ETCD_DATA_DIR"`
Discovery string `toml:"discovery" env:"ETCD_DISCOVERY"`
Force bool
KeyFile string `toml:"key_file" env:"ETCD_KEY_FILE"`
HTTPReadTimeout float64 `toml:"http_read_timeout" env:"ETCD_HTTP_READ_TIMEOUT"`
HTTPWriteTimeout float64 `toml:"http_write_timeout" env:"ETCD_HTTP_WRITE_TIMEOUT"`
InternalBinaryDir string `toml:"internal_binary_dir" env:"ETCD_INTERNAL_BINARY_DIR"`
Peers []string `toml:"peers" env:"ETCD_PEERS"`
PeersFile string `toml:"peers_file" env:"ETCD_PEERS_FILE"`
MaxResultBuffer int `toml:"max_result_buffer" env:"ETCD_MAX_RESULT_BUFFER"`
MaxRetryAttempts int `toml:"max_retry_attempts" env:"ETCD_MAX_RETRY_ATTEMPTS"`
RetryInterval float64 `toml:"retry_interval" env:"ETCD_RETRY_INTERVAL"`
Name string `toml:"name" env:"ETCD_NAME"`
Snapshot bool `toml:"snapshot" env:"ETCD_SNAPSHOT"`
SnapshotCount int `toml:"snapshot_count" env:"ETCD_SNAPSHOTCOUNT"`
ShowHelp bool
ShowVersion bool
Verbose bool `toml:"verbose" env:"ETCD_VERBOSE"`
VeryVerbose bool `toml:"very_verbose" env:"ETCD_VERY_VERBOSE"`
VeryVeryVerbose bool `toml:"very_very_verbose" env:"ETCD_VERY_VERY_VERBOSE"`
Peer struct {
Addr string `toml:"addr" env:"ETCD_PEER_ADDR"`
BindAddr string `toml:"bind_addr" env:"ETCD_PEER_BIND_ADDR"`
CAFile string `toml:"ca_file" env:"ETCD_PEER_CA_FILE"`
@@ -86,7 +90,7 @@ type Config struct {
HeartbeatInterval int `toml:"heartbeat_interval" env:"ETCD_PEER_HEARTBEAT_INTERVAL"`
ElectionTimeout int `toml:"election_timeout" env:"ETCD_PEER_ELECTION_TIMEOUT"`
}
strTrace string `toml:"trace" env:"ETCD_TRACE"`
StrTrace string `toml:"trace" env:"ETCD_TRACE"`
GraphiteHost string `toml:"graphite_host" env:"ETCD_GRAPHITE_HOST"`
Cluster struct {
ActiveSize int `toml:"active_size" env:"ETCD_CLUSTER_ACTIVE_SIZE"`
@@ -116,6 +120,7 @@ func New() *Config {
c.Cluster.ActiveSize = server.DefaultActiveSize
c.Cluster.RemoveDelay = server.DefaultRemoveDelay
c.Cluster.SyncInterval = server.DefaultSyncInterval
c.InternalBinaryDir = DefaultInternalBinaryDir
return c
}
@@ -263,6 +268,7 @@ func (c *Config) LoadFlags(arguments []string) error {
f.Float64Var(&c.HTTPWriteTimeout, "http-write-timeout", c.HTTPReadTimeout, "")
f.StringVar(&c.DataDir, "data-dir", c.DataDir, "")
f.StringVar(&c.InternalBinaryDir, "internal-binary-dir", c.InternalBinaryDir, "")
f.IntVar(&c.MaxResultBuffer, "max-result-buffer", c.MaxResultBuffer, "")
f.IntVar(&c.MaxRetryAttempts, "max-retry-attempts", c.MaxRetryAttempts, "")
f.Float64Var(&c.RetryInterval, "retry-interval", c.RetryInterval, "")
@@ -275,7 +281,7 @@ func (c *Config) LoadFlags(arguments []string) error {
f.IntVar(&c.SnapshotCount, "snapshot-count", c.SnapshotCount, "")
f.StringVar(&c.CPUProfileFile, "cpuprofile", "", "")
f.StringVar(&c.strTrace, "trace", "", "")
f.StringVar(&c.StrTrace, "trace", "", "")
f.StringVar(&c.GraphiteHost, "graphite-host", "", "")
f.IntVar(&c.Cluster.ActiveSize, "cluster-active-size", c.Cluster.ActiveSize, "")
@@ -441,7 +447,7 @@ func (c *Config) MetricsBucketName() string {
// Trace determines if any trace-level information should be emitted
func (c *Config) Trace() bool {
return c.strTrace == "*"
return c.StrTrace == "*"
}
func (c *Config) ClusterConfig() *server.ClusterConfig {

View File

@@ -19,6 +19,7 @@ func TestConfigTOML(t *testing.T) {
cpu_profile_file = "XXX"
data_dir = "/tmp/data"
discovery = "http://example.com/foobar"
internal_binary_dir = "/tmp/etcd/internal_versions"
key_file = "/tmp/file.key"
bind_addr = "127.0.0.1:4003"
peers = ["coreos.com:4001", "coreos.com:4002"]
@@ -54,6 +55,7 @@ func TestConfigTOML(t *testing.T) {
assert.Equal(t, c.CorsOrigins, []string{"*"}, "")
assert.Equal(t, c.DataDir, "/tmp/data", "")
assert.Equal(t, c.Discovery, "http://example.com/foobar", "")
assert.Equal(t, c.InternalBinaryDir, "/tmp/etcd/internal_versions", "")
assert.Equal(t, c.HTTPReadTimeout, 2.34, "")
assert.Equal(t, c.HTTPWriteTimeout, 1.23, "")
assert.Equal(t, c.KeyFile, "/tmp/file.key", "")
@@ -86,6 +88,7 @@ func TestConfigEnv(t *testing.T) {
os.Setenv("ETCD_DISCOVERY", "http://example.com/foobar")
os.Setenv("ETCD_HTTP_READ_TIMEOUT", "2.34")
os.Setenv("ETCD_HTTP_WRITE_TIMEOUT", "1.23")
os.Setenv("ETCD_INTERNAL_BINARY_DIR", "/tmp/etcd/internal_versions")
os.Setenv("ETCD_KEY_FILE", "/tmp/file.key")
os.Setenv("ETCD_BIND_ADDR", "127.0.0.1:4003")
os.Setenv("ETCD_PEERS", "coreos.com:4001,coreos.com:4002")
@@ -115,6 +118,7 @@ func TestConfigEnv(t *testing.T) {
assert.Equal(t, c.Discovery, "http://example.com/foobar", "")
assert.Equal(t, c.HTTPReadTimeout, 2.34, "")
assert.Equal(t, c.HTTPWriteTimeout, 1.23, "")
assert.Equal(t, c.InternalBinaryDir, "/tmp/etcd/internal_versions", "")
assert.Equal(t, c.KeyFile, "/tmp/file.key", "")
assert.Equal(t, c.BindAddr, "127.0.0.1:4003", "")
assert.Equal(t, c.Peers, []string{"coreos.com:4001", "coreos.com:4002"}, "")

View File

@@ -309,7 +309,7 @@ func (e *Etcd) runServer() {
for {
if e.mode == PeerMode {
log.Infof("%v starting in peer mode", e.Config.Name)
go registerAvailableInternalVersions(e.Config.Name, e.Config.Addr, e.Config.EtcdTLSInfo())
go registerAvailableInternalVersions(e.Config.InternalBinaryDir, e.Config.Name, e.Config.Addr, e.Config.EtcdTLSInfo())
// Starting peer server should be followed close by listening on its port
// If not, it may leave many requests unaccepted, or cannot receive heartbeat from the cluster.
// One severe problem caused if failing receiving heartbeats is when the second node joins one-node cluster,

View File

@@ -1,9 +1,7 @@
package etcd
import (
"fmt"
"os"
"runtime"
"time"
"github.com/coreos/etcd/log"
@@ -11,9 +9,7 @@ import (
"github.com/coreos/etcd/third_party/github.com/coreos/go-etcd/etcd"
)
var defaultEtcdBinaryDir = "/usr/libexec/etcd/internal_versions/"
func registerAvailableInternalVersions(name string, addr string, tls *server.TLSInfo) {
func registerAvailableInternalVersions(internalBinaryDir, name, addr string, tls *server.TLSInfo) {
var c *etcd.Client
if tls.Scheme() == "http" {
c = etcd.NewClient([]string{addr})
@@ -25,7 +21,7 @@ func registerAvailableInternalVersions(name string, addr string, tls *server.TLS
}
}
vers, err := getInternalVersions()
vers, err := getInternalVersions(internalBinaryDir)
if err != nil {
log.Infof("failed to get local etcd versions: %v", err)
return
@@ -42,15 +38,8 @@ func registerAvailableInternalVersions(name string, addr string, tls *server.TLS
log.Infof("%s: available_internal_versions %s is registered into key space successfully.", name, vers)
}
func getInternalVersions() ([]string, error) {
if runtime.GOOS != "linux" {
return nil, fmt.Errorf("unmatched os version %v", runtime.GOOS)
}
etcdBinaryDir := os.Getenv("ETCD_BINARY_DIR")
if etcdBinaryDir == "" {
etcdBinaryDir = defaultEtcdBinaryDir
}
dir, err := os.Open(etcdBinaryDir)
func getInternalVersions(internalBinaryDir string) ([]string, error) {
dir, err := os.Open(internalBinaryDir)
if err != nil {
return nil, err
}

View File

@@ -15,15 +15,16 @@ Usage:
etcd -version
Options:
-h -help Show this screen.
--version Show version.
-f -force Force a new configuration to be used.
-config=<path> Path to configuration file.
-name=<name> Name of this node in the etcd cluster.
-data-dir=<path> Path to the data directory.
-cors=<origins> Comma-separated list of CORS origins.
-v Enabled verbose logging.
-vv Enabled very verbose logging.
-h -help Show this screen.
--version Show version.
-f -force Force a new configuration to be used.
-config=<path> Path to configuration file.
-name=<name> Name of this node in the etcd cluster.
-data-dir=<path> Path to the data directory.
-internal-binary-dir=<path> Path to the etcd internal binary directory.
-cors=<origins> Comma-separated list of CORS origins.
-v Enabled verbose logging.
-vv Enabled very verbose logging.
Cluster Configuration Options:
-discovery=<url> Discovery service used to find a peer list.

View File

@@ -1,5 +1,5 @@
package server
const ReleaseVersion = "0.4.7"
const ReleaseVersion = "0.4.8"
const InternalVersion = "1"
const Version = "v2"