Compare commits

...

5140 Commits

Author SHA1 Message Date
bdee27b19e *: bump to v2.2.4 2016-01-13 14:07:39 -08:00
7f684641a3 Godeps: remove golang.org/x/net/netutil
Now using our own LimitListener to support KeepAlives.
2016-01-13 13:32:38 -08:00
d54cf26bed etcdmain: support keep alive listeners on limit listener connections
Fixes #4171
2016-01-13 13:32:26 -08:00
d3e73aadab etcdmain: tls listener MUST be at the outer layer of all listeners
go HTTP library uses type assertion to determine if a connection
is a TLS connection. If we wrapper TLS Listener with any customized
Listener that can create customized Conn, HTTPs will be broken.

This commit fixes the issue.
2016-01-13 13:32:08 -08:00
e340928988 etcdctl: ignore value in updatedir command
Fixes coreos#4145.
client.KeysAPI ignores value if SetOptions.Dir is true.
2016-01-13 13:31:49 -08:00
e6ffe22e16 *: bump to v2.2.3+git 2015-12-30 13:54:57 -08:00
05b564a394 *: bump to v2.2.3 2015-12-30 13:41:16 -08:00
cb779b2305 etcdctl: fix syncWithPeerAPI by breaking the loop when there is no error 2015-12-30 11:24:27 -08:00
22c3208fb3 etcdserver: always check if the data dir is writable before starting etcd 2015-12-30 10:22:52 -08:00
e44372e430 etcdsever: avoid creating member dir before finishing validate bootstrap
This commit fixes the issue of creating member dir before validating
the configuration. When member dir exists, it indicates the local etcd
process is a valid etcd member. So we should only create member dir
after we finish configuration validation, joining validation or
discovery validation.
2015-12-30 10:19:51 -08:00
05a90bc1e5 etcdmain: fix incomplete proxy config file
etcd might generate incomplete proxy config file after a power failure.
It is because we use ioutil.WriteFile. And iotuile.WriteFile does
not call Sync before closing the file.
2015-12-22 12:30:39 -08:00
6751727809 etcdctl: support basic operations with etcd 0.4.
For CoreOS users, they will get a updated version of etcdctl without updating
the etcd server version. And the users cannot really control this behavior.
We do not want to suddenly break them without enough communication.

So we still want the most basic opeartions like get, set, watch of etcdctl2 work
with etcd 0.4. This patches solve the incompability issue.
2015-12-22 12:29:16 -08:00
916106c3a2 client: support reset Endpoints.
ResetEndpoints is useful when the there is a scheduled cluster
changes or when manually manage the cluster without auto-sync
enabled.
2015-12-22 12:25:59 -08:00
e0c7768f94 store: fix data race when modify event in watchHub.
The event got from watchHub should be considered as readonly.
To modify it, we first need to get a clone of it or there might
be a data race.
2015-12-14 14:08:39 -08:00
0fb2d5d4d3 client: fix goroutine leak in unreleased context
If headerTimeout is not zero then two context are created but only one is released.
cancelCtx in this case is never released which leads to goroutine leak inside it.
2015-12-14 13:58:43 -08:00
fc61fc7c7a etcdctl: cluster health exit with non-zero when cluster is unhealthy 2015-12-14 13:58:10 -08:00
09b81bad15 *: bump to v2.2.2+git 2015-11-19 14:24:59 -08:00
b4bddf685b *: bump to v2.2.2 2015-11-19 14:24:35 -08:00
af1c711270 auth: use canonical path for pre-defined guest role 2015-11-19 13:41:27 -08:00
c269426be8 *: fix various data races detected by race detector
Conflicts:
	rafthttp/transport.go
2015-11-19 13:38:28 -08:00
20b7df3c12 rafthttp: fix data races detected by go race detector
Conflicts:
	rafthttp/pipeline.go
2015-11-19 13:34:49 -08:00
e342de3cc5 etcdmain: fix parsing discovery error
The discovery error is wrapped into a struct now, and cannot be compared
to predefined errors. Correct the comparison behavior to fix the
problem.
2015-11-19 13:26:50 -08:00
26cc2111cd etcdmain: improve log when join discovery fails
Before this PR, the log is

```
2015/09/1 13:18:31 etcdmain: client: etcd cluster is unavailable or
misconfigured
```

It is quite hard for people to understand what happens.

Now we print out the exact reason for the failure, and explains the way
to handle it.
2015-11-19 13:26:42 -08:00
5d6457e658 godeps: bump coreos/pkg/capnslog
Update to catch coreos/pkg#43 which should fix SYSLOG_IDENTIFIER getting
set when etcd is logging to the journal.
2015-11-19 13:26:29 -08:00
53bc644168 client: regenerate code to unmarshal key response
Regenerate code for unmarshaling key response with a new version of
ugorji/go/codec.
2015-11-19 13:26:19 -08:00
ad3bb484ca Godeps: update ugorji/go/codec dependency
Update ugorji/go/codec dependency to the newer version.
2015-11-19 13:26:08 -08:00
15f7b736e4 etcdctl:fix health check condition 2015-11-19 13:25:57 -08:00
4dc835c718 *: bump to v2.2.1+git 2015-10-15 21:59:15 -07:00
75f8282eef *: bump to v2.2.1 2015-10-15 21:31:51 -07:00
45c86af0eb etcdctl/command: mk command with PrevNoExist
This attempts to fix #3676. `PrevNoExist` checks if the key previously exists
and if so, it returns an error, which is how `mk` command is supposed to work.
The previous code ignores the previous key and overwrites with the later value.

/cc @yichengq
2015-10-15 15:26:52 -07:00
71e5467807 Godeps: update prometheus dependency
prometheus updates its directory layout
(https://github.com/prometheus/client_golang#where-is-model-extraction-and-text)
and makes Godeps restore/save unable to work.

Remove all prometheus dependency manually and godep save again to fix
this problem.
2015-10-15 15:26:42 -07:00
0169fec873 client: regenerate code to unmarshal key response
Regenerate code for unmarshaling key response with a new version of
ugorji/go/codec
2015-10-15 15:24:21 -07:00
766023b1b0 Godeps: update ugorji/go/codec dependency
Update ugorji/go/codec dependency to the newer version (a bunch of fixed were made).
2015-10-15 15:24:12 -07:00
ca9e63dde2 pkg/types: fix unwanted unescape in NewURLsMap
We use url.ParseQuery to parse names-to-urls string, but it has side
effect that unescape the string. If the initial-cluster string has ipv6
which contains `%25`, it will unescape it to `%` and make further url
parse failed.

Fix it by modifiying the parse process.

Go1.4 doesn't support literal IPv6 address w/ zone in
URI(https://github.com/golang/go/issues/6530), so we only enable tests
in Go1.5+.
2015-10-15 15:24:00 -07:00
7659bbb1b2 etcdmain: print out error and suggestion for fixing notify issue 2015-10-15 15:23:49 -07:00
f8b98d3925 etcdhttp: add Content-Type: application/json header to version handler 2015-10-15 15:23:34 -07:00
9ee3ed777b etcdmain: exit after print out ErrDuplicateID
etcd should exit after printing log for unhandlable error.
2015-10-15 15:23:24 -07:00
c9bd125490 etcdsever: mismatch error uses the same format as the corresponding flags 2015-10-15 15:22:52 -07:00
ec49496111 proxy: improve log for retrying an unavailable endpoint
Fixes #3541

Signed-off-by: Guohua ouyang <guohuaouyang@gmail.com>
2015-10-15 15:22:40 -07:00
baaefd18e2 etcdmain: better logging when user forget to set initial flags 2015-10-15 15:22:29 -07:00
72c18eb7ba etcdctl: use a context with -total-timeout in simple commands
Like the commit 8ebc933111, this commit lets simple etcdctl commands
use a context with timeout value passed via -total-timeout.

This commit doesn't change complex commands like watch,
cluster-health, and import because it is not obvious that using the
context in the commands is good or not.
2015-10-15 15:22:13 -07:00
2e87d71bc6 etcdctl: use user specified timeout value for entire command execution
etcdctl should be capable to use a user specified timeout value for
total command execution, not only per request timeout. This commit
adds a new option --total-timeout to the command. The value passed via
this option is used as a timeout value of entire command execution.

Fixes coreos#3517
2015-10-15 15:21:38 -07:00
217dccd617 raft: improve panic error message
Give a human being some insight into how we might have gotten to this
state based on feedback from #3504.
2015-10-15 15:20:12 -07:00
3ceb5dd270 client: add Nodes to codecgen and regenerate 2015-10-15 15:19:58 -07:00
49b77a59cf client: add Nodes type to faciliate sorting
This helps users to sort easily.
2015-10-15 15:19:52 -07:00
db0511e28c *: bump to v2.2.0+git 2015-09-10 10:03:07 -07:00
e4561dd8cf *: bump to v2.2.0 2015-09-10 10:02:45 -07:00
6e7725cd51 Merge pull request #3478 from endocode/kayrus/typo_fix
doc: member id typo fixed
2015-09-10 00:11:26 -07:00
37392ad223 doc: member id typo fixed 2015-09-10 08:47:45 +02:00
9b032c6a00 Merge pull request #3473 from MrLawes/master
doc: fix bad url in using a directory TTL section
2015-09-09 18:57:09 -07:00
1c058e9706 doc: fix bad url in using a directory TTL section 2015-09-10 09:23:10 +08:00
f3085d2ea4 Merge pull request #3459 from yichengq/release-doc
docs/dev: add release doc
2015-09-09 17:46:10 -07:00
b70e6fc677 docs/dev: add release doc
It documents the standard way to release etcd today. Maintainer should
follow this doc to cut release, and update it in time to fit current
situation.
2015-09-09 16:42:31 -07:00
c34cf04c27 Merge pull request #3448 from yichengq/release-script
scripts: add release.sh
2015-09-09 13:54:15 -07:00
bdd8774169 Merge pull request #3204 from endocode/kayrus/recovery
Improved "disaster restore" doc, added "member update" command descri…
2015-09-09 12:23:51 -07:00
19ad634673 doc: improved "disaster restore" doc, added "member update" command description 2015-09-09 20:07:31 +02:00
7d4cd7c76a scripts: add release.sh
It could build all binaries and images for the given version.
2015-09-09 09:50:41 -07:00
af0474f2e3 Merge pull request #3465 from raoofm/patch-1
etcdmain: Proxy doesnt specify - listening on http or https
2015-09-08 14:38:55 -07:00
2de1c36061 etcdmain: Proxy doesnt specify - listening on http or https
etcdmain: Proxy doesnt specify - listening on http or https

Fixes #3464
2015-09-08 17:19:23 -04:00
ccdd10c757 Merge pull request #3463 from yichengq/update-roadmap
roadmap: remove 2.2 section
2015-09-08 13:55:50 -07:00
c837f0526f roadmap: remove 2.2 section
We have finished all of them.
2015-09-08 13:43:39 -07:00
d8e6e217fd Merge pull request #3461 from xiang90/doc
doc: remove one limitation in upgrade doc
2015-09-08 13:29:43 -07:00
3689ea3071 doc: remove one limitation in upgrade doc 2015-09-08 13:28:23 -07:00
a44da0b62a Merge pull request #3451 from raoofm/patch-1
discovery: log error only if both ssl and non-ssl srv lookups fail
2015-09-06 20:54:43 -07:00
9a2809f0b5 discovery: log error only if both ssl and non-ssl srv lookups fail
discovery: log error only if both ssl and non-ssl srv lookups fail
Earlier we were logging as soon as one of the lookups failed.

Fixes #3414
2015-09-06 23:44:19 -04:00
184337568d scripts/build-docker: build docker in image-docker dir
The docker build command will use whatever directory contains the
Dockerfile as the build context (including all of its subdirectories).
And the <src> path of ADD must be inside the context of the build.
So change it to build in a specific directory for clean and fast.
2015-09-06 00:17:41 -07:00
15d1db9bf8 scripts/build-aci: support BINARYDIR and BUILDDIR
This makes it more configurable, and is ready for overall release script.
2015-09-06 00:17:41 -07:00
6b70fa72fe scripts: build-release -> build-binary
This makes the functionality of the script more clear, and always use
bash to run the script because it has bash-specific grammar.
2015-09-06 00:16:51 -07:00
cf6cb82caa scripts/build-docker: stop creating scratch image
Scratch image has become docker's reserved image.
2015-09-06 00:16:08 -07:00
a1b01c266a scripts/build-aci: fix the way to check executability
Or it may treat runnable command as unexecutable.
2015-09-06 00:15:31 -07:00
b9646b5734 Merge pull request #3447 from xiang90/txn
etcdctlv3: fix txn command
2015-09-05 18:21:11 -07:00
1532f7585b etcdctlv3: fix txn command 2015-09-05 16:08:15 -07:00
dab0871acb Merge pull request #3446 from xiang90/v3
etcdserver: refactor v3demo do
2015-09-05 15:41:00 -07:00
95d5556445 etcdserver: refactor v3demo do 2015-09-05 15:31:28 -07:00
d5ab71a4e8 Merge pull request #3445 from xiang90/api_doc
doc: add monitoring section to admin doc
2015-09-05 08:27:11 -07:00
13b3c64c10 doc: add monitoring section to admin doc 2015-09-05 08:25:35 -07:00
51d0630a8e Merge pull request #3440 from yichengq/memory-bench
docs/benchmark: add 2.2.0-rc memory usage benchmark
2015-09-04 20:23:56 -07:00
91b5b247e9 docs/benchmark: add 2.2.0-rc memory usage benchmark
It records the memory usage for different average value size, and
records the data size limitation.
2015-09-04 18:27:49 -07:00
106d918dd5 Merge pull request #3444 from xiang90/doc
etcdctl: suggest endpoint over peer
2015-09-04 13:22:03 -07:00
322aab133d etcdctl: suggest endpoint over peer 2015-09-04 13:16:33 -07:00
9fa05ad8a0 Merge pull request #3443 from xiang90/test
test: now raft has no shadow issue
2015-09-04 11:31:44 -07:00
39580479b5 Merge pull request #3442 from xiang90/b
etcdctl: prepare for health endpoint change
2015-09-04 11:30:44 -07:00
a6e67a6dec test: now raft has no shadow issue
We can test raft pkg now!
2015-09-04 10:52:14 -07:00
778f8d8fea Merge pull request #3434 from xiang90/index_revision
*: v3api index->revision
2015-09-04 10:48:59 -07:00
3f18ded10a *: v3api index->revision 2015-09-04 10:41:20 -07:00
5a5f15de39 Merge pull request #3438 from yichengq/storage-test
storage: add mock tests for store struct
2015-09-04 10:26:08 -07:00
04539c6240 etcdctl: prepare for health endpoint change
We made a mistake on the health endpoint by returning a string "true".
We have to make the etcdctl works for the next version of etcd which
will correct the mistake on the server side.

It is too late to change the server side right now since we already
released a version of etcdctl that only understands "true".
2015-09-04 10:20:24 -07:00
215f27c2f5 storage: add mock tests for store struct 2015-09-04 08:53:49 -07:00
8ca76a789b Merge pull request #3439 from akolb1/godep_all_fixes
Godep: fixed missing dependencies
2015-09-03 22:20:48 -07:00
2782418923 Godep: fixed missing dependencies 2015-09-04 04:51:44 +00:00
5ae2eb4731 storage: avoid one extra round of wait
It could exit early if it knows that there is no more keys.
2015-09-03 19:12:27 -07:00
9175df7c71 storage: correct revision for range when deleteRange
to make it logically reasonable.
2015-09-03 19:12:27 -07:00
797a4796d9 storage: remove check for DELETE type KeyValue
kvindex always returns kvs that exist at given revision, so there is no
need to check for whether the KeyValue range from backend is DELETE type.
2015-09-03 19:12:27 -07:00
00e31f13a6 storage: remove unnecessary rev parameter 2015-09-03 19:12:27 -07:00
2f2b084ab5 Merge pull request #3436 from xiang90/remove_consistent_token
*: replace consistent token with revision in v3 api
2015-09-03 17:16:07 -07:00
254d641ff9 Merge pull request #3429 from xiang90/upgrade_doc
doc: add upgrade to 2.2 doc
2015-09-03 15:47:10 -07:00
2ac9af4924 *: replace consistent token with revision in v3 api 2015-09-03 15:41:33 -07:00
243fe519a9 Merge pull request #3435 from xiang90/gogoproto
*: update gogoproto
2015-09-03 15:35:48 -07:00
ef7cf058a2 *: update gogoproto 2015-09-03 15:32:25 -07:00
356aba7595 doc: add upgrade to 2.2 doc 2015-09-03 11:48:30 -07:00
ae2b43b588 Merge pull request #3433 from tamird/proto-import-path
*: regenerate proto to use local import path
2015-09-03 10:52:37 -07:00
45390b9fb8 *: regenerate proto to use local import path
Using Go-style import paths in protos is not idiomatic. Normally, this
detail would be internal to etcd, but the path from which gogoproto
is imported affects downstream consumers (e.g. cockroachdb).

In cockroach, we want to avoid including `$GOPATH/src` in our protoc
include path for various reasons. This patch puts etcd on the same
convention, which allows this for cockroach.

More information: https://github.com/cockroachdb/cockroach/pull/2339#discussion_r38663417

This commit also regenerates all the protos, which seem to have
drifted a tiny bit.
2015-09-03 13:38:28 -04:00
84d1527df6 Merge pull request #3432 from coreos/robszumski-patch-1
docs: insert whitespace
2015-09-03 09:56:57 -07:00
49e7e6eb9f docs: insert whitespace
Fixes the rendering of this page on https://coreos.com/etcd/docs/2.1.0/proxy.html
2015-09-03 09:50:07 -07:00
1eaf169057 Merge pull request #3395 from yichengq/backend-test
storage/backend: add unit tests for backend and batchTx
2015-09-03 07:23:38 -07:00
44fd734038 storage/backend: add unit tests for backend and batchTx 2015-09-02 16:57:13 -07:00
16e9e4b3d5 Merge pull request #3412 from yichengq/etcdctl-sync
etcdctl: better logging for sync process
2015-09-02 16:49:00 -07:00
8e040efed9 etcdctl: log more about sync process
Users don't even know that etcdctl is doing sync and fails on sync
process. So we add more logs for sync process.
2015-09-02 16:10:25 -07:00
3a8db488ca Merge pull request #3415 from yichengq/better-err
etcdctl/command: print more details about ErrNoEndpoint
2015-09-02 10:11:45 -07:00
41cc16481f Merge pull request #3418 from AdoHe/fix_build_script_error
build: fix build error on ubuntu
2015-09-01 22:44:23 -07:00
9665cda7c1 build: fix build error on ubuntu 2015-09-02 13:28:55 +08:00
484a115813 Merge pull request #3424 from akolb1/bolt_solaris1
Godeps: boltdb dependency missing solaris support
2015-09-01 16:19:23 -07:00
ecbc44fb63 Godeps: boltdb dependency missing solaris support 2015-09-01 23:17:36 +00:00
423e3bbbd8 etcdctl/cluster_health: provide better message for empty client urls
It skips sync when init client, and prints out unreachable messagen and
points to notice when checking health of etcd members one by one.
2015-09-01 14:42:19 -07:00
aa0c8fea55 Merge pull request #3321 from yichengq/doc-tls-setup
docs/security: link cfssl example
2015-09-01 14:28:40 -07:00
6caae58814 docs/security: recommend cfssl instead of etcd-ca
This provides a more general and stable way for users to set TLS cluster.
2015-09-01 14:07:26 -07:00
d412eaa3a2 Merge pull request #3308 from yichengq/go-codec
Use ugorji codec for unmarshalling key responses in client
2015-09-01 14:04:38 -07:00
53b8175d3f Merge pull request #3421 from xiang90/3411
etcdmain: proxy does not need to belong to the discovered cluster
2015-09-01 13:49:31 -07:00
7957677cf2 etcdmain: proxy does not need to belong to the discovered cluster 2015-09-01 11:24:02 -07:00
a94118893c Merge pull request #3413 from xiang90/snapshot_dir
*: support wal dir
2015-09-01 10:03:50 -07:00
d94e712d91 *: support wal dir 2015-09-01 09:54:27 -07:00
85b6c51a23 Merge pull request #3420 from yichengq/wait-more
storage: extend timeout to wait for put complete
2015-09-01 09:25:46 -07:00
a21166c3aa storage: extend timeout to wait for put complete
travis is sometimes slow, and it could fail to complete the put in 10ms.
2015-09-01 09:03:03 -07:00
8ac981e1ee Merge pull request #3416 from yichengq/get-cluster-timeout
etcdserver: add timeout param on getClusterFromRemotePeers
2015-09-01 09:00:19 -07:00
f3bfcb9dee etcdserver: add timeout param on getClusterFromRemotePeers
It sets 10s timeout for public GetClusterFromRemotePeers.

This helps the following cases to work well in high latency scenario:

1. proxy sync members from the cluster
2. newly-joined member sync members from the cluster

Besides 10s request timeout, the request is also controlled by dial
timeout and read connection timeout.
2015-09-01 08:49:01 -07:00
1fabc48968 Merge pull request #3404 from bdarnell/multinode-propose-panic
raft: A removed node can no longer be leader.
2015-08-31 20:06:34 -07:00
4f20e01f60 raft: Ignore proposals if not a current member.
Fixes another panic in MultiNode.Propose.
2015-08-31 20:31:14 -04:00
c2caa4ae3b etcdctl/command: print more details about ErrNoEndpoint
This commit prints more details if getting ErrNoEndpoint when sync with
cluster. This helps users to know what happens.
2015-08-31 16:28:43 -07:00
4b9b0cbcc1 storage: add newBackend and newBatchTx
This is for ease of testing.
2015-08-31 13:25:10 -07:00
57b39aca4e Merge pull request #3403 from xiang90/doc
doc: add 0.4.9 to 2.2 migration guide
2015-08-31 11:28:25 -07:00
3c1f80bdff Merge pull request #3401 from xiang90/more_metrics
more on storage metrics
2015-08-31 09:55:29 -07:00
406bb6749e doc: add 0.4.9 to 2.2 migration guide 2015-08-31 09:55:12 -07:00
bc71aab07a Merge pull request #3409 from xiang90/fix_force_new
etcdserver: ignore confChangeUpdateNode in getIDs
2015-08-31 09:44:10 -07:00
1bcaa9f4a1 etcdserver: ignore confChangeUpdateNode in getIDs 2015-08-31 09:36:39 -07:00
aaa7dfc14d Merge pull request #3407 from MSamman/fix-build-warning
build: fixed build warning
2015-08-31 07:47:23 -07:00
dd4317db43 build: fixed build warning
to clear warning and ensure git sha linkage works in the future

Fixes #3406
2015-08-30 15:05:56 -07:00
b9632e0f8d storage: register txnCounter 2015-08-28 15:17:16 -07:00
dd443be41b storage: report total number of keys 2015-08-28 15:16:53 -07:00
d2cb732c7b test: activate test on storage/backend 2015-08-28 13:52:31 -07:00
054fab84ee storage/backend: remove startc var
This makes start logic cleaner.
2015-08-28 13:52:31 -07:00
fca98c9071 Merge pull request #3398 from xiang90/storage_metrics
storage: add initial metrics for kv
2015-08-28 13:50:44 -07:00
b5838edb93 storage: add initial metrics for kv 2015-08-28 13:41:42 -07:00
6cbaaa715c Merge pull request #3396 from bdarnell/multinode-propose-panic
raft: Fix a nil-pointer panic in MultiNode.Propose.
2015-08-28 12:34:49 -07:00
cba7c6a180 *: bump to v2.2.0-rc.0+git 2015-08-28 10:26:56 -07:00
dc3e027288 *: bump to v2.2.0-rc.0 2015-08-28 10:26:32 -07:00
b40e077047 Merge pull request #3388 from sckott/docfix-tuning
fix docs, change tuning link in api.md from section to file
2015-08-28 09:23:58 -07:00
05924b330a raft: Fix a nil-pointer panic in MultiNode.Propose. 2015-08-28 11:17:59 +02:00
f04884f74d storage/backend: fix off-by-one error for pending var
Or it may commit until batchLimit + 1.
2015-08-27 22:51:32 -07:00
7ed929fb3d storage/backend: fix limit doesn't effect in range 2015-08-27 22:51:32 -07:00
37d9354aa2 Merge pull request #3394 from yichengq/bench-2.2
adjust file and README in docs/benchmark
2015-08-27 21:09:39 -07:00
9d78d84270 Merge pull request #3390 from xiang90/ctl_peer
etcdctl: suggest endpoint over peers flag
2015-08-27 21:03:39 -07:00
8d8033df55 etcdctl: suggest endpoint over peers flag 2015-08-27 18:52:17 -07:00
753a079700 docs/benchmark: add benchmark result links in README 2015-08-27 17:08:49 -07:00
425afa66ea docs/benchmarks: update bench version for more accuracy 2015-08-27 17:08:30 -07:00
f68e4a1a5d Merge pull request #3392 from yichengq/bench-2.2
docs/benchmark: update etcd 2.2 bench
2015-08-27 16:58:04 -07:00
605f0ce730 docs/benchmark: update etcd 2.2 bench
This benchmark is for etcd 2.2 rc after fixing several performance
downgrade bugs.
2015-08-27 16:52:55 -07:00
b0192118dd doc: change tuning link in api.md from section to file 2015-08-27 15:04:07 -07:00
1124a06860 Merge pull request #3387 from yichengq/fix-quorum
doc: correct calculation of fault tolerance of an etcd cluster in adm…
2015-08-27 14:48:39 -07:00
bc2b8856d7 doc: correct calculation of fault tolerance of an etcd cluster in admin_guide.md
doc: correct calculation of fault tolerance of an etcd cluster in admin_guide.md
2015-08-27 14:30:12 -07:00
df83af944b Merge pull request #3384 from yichengq/fix-shadow
test: use go vet shadow feature instead of go-nyet
2015-08-27 14:27:57 -07:00
92cd24d5bd *: fix govet shadow check failure 2015-08-27 14:15:30 -07:00
b2d33e6dcb Merge pull request #3382 from xiang90/env
pkg/flags: print out evn usage information
2015-08-27 13:36:55 -07:00
ccdb850e1e test: use go vet shadow feature instead of go-nyet
Use official support instead of home-made one.
2015-08-27 13:29:12 -07:00
4ac4648b5b Merge pull request #3383 from cognusion/fixes2
Test Fixes: Take 2
2015-08-27 13:22:19 -07:00
327632014e cors: Removed new(?) header from test, resolving failure
"X-Content-Type-Options" was being autoadded, but none of the
test maps took it into account. I saw that "Content-Type" was
also being deleted, so I figured that was the best solution
for this as well.
2015-08-27 15:23:14 -04:00
19a28c8efd storage: Fixed backend test
./backend_test.go:23: multiple-value batchTx.UnsafeRange() in single-value context
2015-08-27 15:20:29 -04:00
32372e1d70 raft: Fixed a test misassumption
network_test.go:56: total = 59.22354ms, want > 50ms
59 is > 50, but the equation added 10 to the right side
2015-08-27 15:15:34 -04:00
c8f5e03b75 pkg/flags: print out evn usage information 2015-08-27 12:08:31 -07:00
25c87f13fd Merge pull request #3354 from mx2323/faq
add faq documentation
2015-08-26 16:36:04 -07:00
8f3ea5ebed doc: add faq documentation 2015-08-26 16:34:52 -07:00
59a5a7e309 Merge pull request #3368 from yichengq/storage-test
add unit tests for storage
2015-08-26 15:32:02 -07:00
0d38c13990 storage: use temp path to handle test file 2015-08-26 15:01:41 -07:00
2d01eb4e11 storage: add tests for kvstore_compaction 2015-08-26 15:01:13 -07:00
f38778160d Merge pull request #3376 from yichengq/connection-down
etcdserver: specify request timeout error due to connection down
2015-08-26 13:09:30 -07:00
0813139140 storage: add more tests for index 2015-08-26 12:53:30 -07:00
3723f01b48 storage: add more unit tests for keyIndex 2015-08-26 12:53:30 -07:00
ad8a291dc1 storage: return error when tombstone on new generation
It is not allowed to put tombstone on an empty generation.
2015-08-26 12:53:30 -07:00
ffa87f9678 storage: fix the comment in generation.walk 2015-08-26 12:53:30 -07:00
8f6bf029f8 etcdserver: specify request timeout error due to connection lost
It specifies request timeout error possibly caused by connection lost,
and print out better log for user to understand.

It handles two cases:
1. the leader cannot connect to majority of cluster.
2. the connection between follower and leader is down for a while,
and it losts proposals.

log format:
```
20:04:19 etcd3 | 2015-08-25 20:04:19.368126 E | etcdhttp: etcdserver:
request timed out, possibly due to connection lost
20:04:19 etcd3 | 2015-08-25 20:04:19.368227 E | etcdhttp: etcdserver:
request timed out, possibly due to connection lost
```
2015-08-26 12:38:37 -07:00
76db9747f8 Merge pull request #3377 from yichengq/tls-info-string
pkg/transport: print ClientCertAuth in TLSInfo.String()
2015-08-25 22:45:10 -07:00
45bb88069b Merge pull request #3378 from yichengq/set-late
etcdmain: check error before assigning peer transport
2015-08-25 22:38:36 -07:00
58455a2ae4 etcdmain: check error before assigning peer transport
Or it may panic when new transport fails, e.g., TLS info is invalid.
2015-08-25 22:04:26 -07:00
57e88465bf pkg/transport: print ClientCertAuth in TLSInfo.String()
It is good to print it in debug output:

```
21:56:12 etcd1 | 2015-08-25 21:56:12.162406 I | etcdmain: peerTLS: cert
= certs/etcd1.pem, key = certs/etcd1-key.pem, ca = , trusted-ca =
certs/ca.pem, client-cert-auth = true
```
2015-08-25 21:53:52 -07:00
6250fed8a8 Merge pull request #3096 from philips/tls-info-debug
pkg/transport: include debug output for trusted-ca
2015-08-25 20:08:19 -07:00
008f988f6b Merge pull request #3375 from xiang90/doc
doc: add evn variable name to configuration.md
2015-08-25 14:48:35 -07:00
2b58da1699 Merge pull request #3374 from yichengq/gomaxprocs
etcdmain: change default GOMAXPROCS when compiling in go1.5
2015-08-25 14:48:00 -07:00
35a0459cc8 doc: add evn variable name to configuration.md 2015-08-25 14:35:15 -07:00
32ab3f6931 Merge pull request #3372 from xiang90/doc
improve clustering.md doc
2015-08-25 14:04:30 -07:00
c30c85898e doc: add explanation for client urls 2015-08-25 13:46:27 -07:00
2ac9a329ab etcdmain: stop setting GOMAXPROCS explicitly
We always want to use GOMAXPROCS() as the way go parses it. When in go1.4, we
want to expose GOMAXPROCS value, so we set GOMAXPROCS explicitly as the
way go 1.4 does and print it out.

But it becomes a problem when go 1.5 changes the way to set GOMAXPROCS.

Fix the problem by stop setting GOMAXPROCS and get its value directly.

Due to this change, it sets default GOMAXPROCS to the
number of CPUs available when compiling in go 1.5, which matches how go 1.5 works:
https://docs.google.com/document/d/1At2Ls5_fhJQ59kDK2DFVhFu3g5mATSXqqV5QrxinasI/edit

This is a behavior change in etcd 2.2.
2015-08-25 13:38:16 -07:00
a4285ef5c9 Merge pull request #3367 from MSamman/master
etcdserver: handle malformed basic auth
2015-08-25 13:12:48 -07:00
e2e002f94e etcdserver: handle malformed basic auth
return insufficient credentials if basic auth header is malformed

Fixes #3280
2015-08-25 12:37:24 -07:00
7bd558b2e0 Merge pull request #3373 from ecnahc515/add_report_bugs_contributing
Contributing: Link to reporting bugs doc
2015-08-25 12:17:06 -07:00
ad843341a9 Contributing: Link to reporting bugs doc 2015-08-25 12:15:03 -07:00
f56c5455f3 doc: mention reconfiguration design in clustering.md 2015-08-25 11:22:08 -07:00
986f354694 Merge pull request #3371 from xiang90/bolt
Godeps: update bolt dependency
2015-08-25 11:17:14 -07:00
e8f40b0412 storage/backend: add commitAndStop
After the upgrade of boltdb, db.Close waits for all txn to finish.
CommitAndStop commits the current txn and stop creating new ones.
2015-08-25 10:57:25 -07:00
8738a88fae Godeps: update bolt dependency 2015-08-25 10:39:29 -07:00
2d06f6b371 Merge pull request #3362 from yichengq/rafthttp-cancel
rafthttp: always cancel in-flight request when stop streamReader
2015-08-25 09:26:46 -07:00
61a75b3d48 rafthttp: always cancel in-flight request when pipeline.send
This fits the way for go1.5 to cancel request.
2015-08-25 09:07:49 -07:00
27b9963959 client: always cancel in-flight request when do request
This fits the way for go1.5 to cancel request.
2015-08-25 09:04:58 -07:00
ece39c9462 proxy: always cancel in-flight request
This fits the way for go1.5 to cancel request.
2015-08-25 08:59:59 -07:00
6fc638673c rafthttp: return err if stopped before setting cancel in dial()
The original workflow may fail to cancel if stop() cancels the finished
request just before dial() assigning a new cancel. This commit checks
streamReader status before setting cancel to avoid this problem.

It is tested at travis for 300 times. go 1.5 always works well, while
go 1.4 fails to stop once.
2015-08-25 08:59:12 -07:00
fc95ec0cc6 rafthttp: always cancel in-flight request when stop streamReader
This problem is totally fixed at 1.5.

go1.5 adds a Request.Cancel channel, which allows for "race free"
cancellation
(8b4278ffb7).
Our implementation relies on it to always cancel in-flight request.
2015-08-25 08:54:13 -07:00
0132b091d2 Merge pull request #3360 from yichengq/bench-3
*: add initial read benchmark for etcd v3
2015-08-25 07:58:30 -07:00
3632a1b9b1 *: add initial read benchmark for etcd v3
It includes the initial read benchmark for etcd v3.

This is the first step to give some rough thoughts. I haven't digged
deeper to answer some questions, including why its performance is not
better than HTTP + json, why one put will cause performance downgrade.
2015-08-25 07:50:18 -07:00
e3ef1d363a Merge pull request #3366 from xiang90/v3_proto
update v3 proto and doc
2015-08-24 11:22:29 -07:00
0cb45aee64 rfc: update v3 proto 2015-08-24 11:00:51 -07:00
1cccbb5ebd etcdserverpb: add comments for compaction 2015-08-24 10:52:54 -07:00
3a60d490d1 storagepb: fix comment location 2015-08-24 10:42:16 -07:00
4a5b94478e etcdserverpb: update comment for txn request 2015-08-24 10:40:05 -07:00
98ceb3cdbd etcdserverpb: add more field into rangeResponse 2015-08-24 10:33:20 -07:00
c7f10ed975 Merge pull request #3361 from yichengq/no-log
integration: only print critical log
2015-08-24 09:44:13 -07:00
3702be476b integration: only print critical log
This limits the logs printed out in integration test, so it will not
have log flood and help us read fatal log in travis.
2015-08-23 21:22:21 -07:00
514c4371a9 Merge pull request #3359 from yichengq/storage-test
functional tests for storage package and some related fixes
2015-08-23 21:12:36 -07:00
1e2b0acf6d test: activate test for storage package 2015-08-23 20:59:06 -07:00
9c0c314425 storage: add functional tests for the package
It adds and reorganize tests to construct functional tests.
2015-08-23 20:59:06 -07:00
9960651c3f storage: let range work in the process of txn
range should work in the process of txn to help check the status during the
txn.
2015-08-23 20:59:06 -07:00
6d97dcaf3f storage: ensure that desired compaction is persisted
It needs to persist the desired compaction, so it won't forget the compaction
if it crashes later.
2015-08-23 20:59:06 -07:00
353f10ca2b storage: reject to compact on future rev
Compaction on future rev is unreasonable.
2015-08-23 20:59:06 -07:00
47b243be5d storage: let TxnDeleteRange return rev if no error
If it doesn't return error, it should return valid rev.
2015-08-23 20:59:06 -07:00
62f7481b19 storage: keyIndex.get returns err when key is tombstoned
Before this commit, it will return wrong create index, mod index.

It lets findGeneration return error when rev is at the gap of two
generations. This leads to the change of compact() code.
2015-08-23 20:59:02 -07:00
3b2fa9f1de storage: fix TestKeyIndexCompact
It fails to pass before.
2015-08-23 17:22:49 -07:00
97b211c8ba Merge pull request #3357 from ccding/master
go vet
2015-08-22 10:29:29 -07:00
c09b667d57 *: fix go vet reported issues 2015-08-22 12:19:02 -05:00
044b23c3ca Merge pull request #3356 from xiang90/travis
*: test gofmt with -s and fix reported issues
2015-08-21 18:59:51 -07:00
6b23a8131f *: test gofmt with -s and fix reported issues 2015-08-21 18:52:16 -07:00
301b7f57c0 Merge pull request #3355 from yichengq/health-var
etcdctl/cluster_health: set health var when checked healthy
2015-08-21 15:37:15 -07:00
224755855d etcdctl/cluster_health: set health var when checked healthy
This was a typo.
2015-08-21 15:27:35 -07:00
84b614c508 Merge pull request #3342 from xiang90/travis
travis: test for go 1.5 build
2015-08-21 14:49:00 -07:00
1dcc145aef client: fix test 2015-08-21 14:36:29 -07:00
8c0610d4f5 Merge pull request #3352 from yichengq/fix-name-url
fix that etcd fails to start if using both IP and hostname when discovery srv
2015-08-21 12:38:38 -07:00
3c1e6b54b3 pkg/netutil: stop resolving in place
It helps to copy out a and b, and not modify the original a and b.
2015-08-21 12:09:17 -07:00
1c334979cd pkg/netutil: not introduce empty url when converting
It should not make slices with length and append elements at the same
time.
2015-08-21 12:08:17 -07:00
7b871aab41 pkg/netutil: not export resolve and urlsEqual functions
They are only used in this package, so there is no need to public them.
2015-08-21 11:58:37 -07:00
b1192e5c48 pkg/netutil: fix false negative comparison
Sort the resolved URLs before DeepEqual, so it will not compare URLs
that may be out of order due to resolution.
2015-08-21 10:15:08 -07:00
72462a72fb etcdserver: remove TODO to delete URLStringsEqual
Discovery SRV supports to compare IP addresses with domain names,
so we need URLStringsEqual function.
2015-08-21 09:52:17 -07:00
8ea3d157c5 Revert "Revert "Treat URLs have same IP address as same""
This reverts commit 3153e635d5.

Conflicts:
	etcdserver/config.go
2015-08-21 09:41:13 -07:00
07af0b3e5b Merge pull request #3346 from xiang90/auth_skip
etcdserver/auth: cache auth enable result
2015-08-20 23:32:29 -07:00
11a689d063 etcdserver/auth: cache auth enable result 2015-08-20 23:05:00 -07:00
e8e507b29b Merge pull request #3348 from xiang90/l
use limited listener from golang
2015-08-20 22:44:51 -07:00
ff37cc455c pkg/transport: remove home-grown limitedListener 2015-08-20 20:03:27 -07:00
92634356c1 *: use limitedListener from golang 2015-08-20 20:02:35 -07:00
da9a12b97c Merge pull request #3344 from xiang90/startup_version
etcdmain: print out version information on startup
2015-08-20 15:10:25 -07:00
6b77c146ec etcdmain: print out version information on startup 2015-08-20 14:50:16 -07:00
31395d257c travis: test for go 1.5 build 2015-08-20 11:39:41 -07:00
7cf9770e12 Merge pull request #3340 from xiang90/fix_perallocate
pkg/fileutil: treat not support error as nil error in preallocate
2015-08-20 11:38:03 -07:00
3ca5482251 pkg/fileutil: treat not support error as nil error in preallocate 2015-08-20 11:15:02 -07:00
4a6d6b0052 Merge pull request #3338 from spacejam/master
Reversion->Revision
2015-08-20 10:16:31 -07:00
acd7a92f03 storage: reversion -> revision 2015-08-20 08:39:07 -07:00
e1dfcec0ab Merge pull request #3327 from yichengq/bench-2.2
docs/benchmarks: add benchmark result for 2.2
2015-08-20 00:18:32 -07:00
807de81172 docs/benchmarks: add benchmark result for 2.2
And it analyzes the reason for performance changes.
2015-08-19 23:59:33 -07:00
795e962403 Merge pull request #3334 from mitake/snap-marsharing-prometheus
snap: export durations of marsharing cost during snapshot save
2015-08-19 20:59:04 -07:00
7a6d33620f snap: export durations of marshalling cost during snapshot save
Currently, total duration of snapshot saving is exported for
prometheus. For more detailed analysis, this commit let etcd export
durations of marshalling for prometheus.
2015-08-20 12:47:07 +09:00
46a2ae77a1 hack/benchmark: add script for benchmark
This is for etcd benchmark.
2015-08-19 20:37:27 -07:00
b0303e948c Merge pull request #3323 from xiang90/cl_health
etcdctl: use health endpoint to greatly simplify health checking
2015-08-19 17:15:52 -07:00
568d1c6783 etcdctl: use health endpoint to greatly simplify health checking 2015-08-19 11:47:08 -07:00
60387dc408 Merge pull request #3320 from yichengq/doc-rtt
docs: document how to set heartbeat interval and election timeout
2015-08-19 11:08:05 -07:00
28b61acd9e Merge pull request #3324 from xiang90/raft_logging
raft: downgrade the logging around snapshot to debugf
2015-08-18 17:18:08 -07:00
d01b6cd639 Merge pull request #3326 from elimisteve/master
client: fixed typo in WatcherOptions docs
2015-08-18 16:49:43 -07:00
952827157a client: fixed typo in WatcherOptions docs
specifices -> specifies
2015-08-18 16:43:09 -07:00
b3d2a621ab Merge pull request #3325 from elimisteve/master
client: spelling error in docs (occured -> occurred)
2015-08-18 16:35:13 -07:00
69fc796926 client: spelling error in docs (occured -> occurred) 2015-08-18 16:26:52 -07:00
50c1db3fbf raft: downgrade the logging around snapshot to debugf
Snapshot related logging is spamming when leader trying to
sync a failed peer.
2015-08-18 15:43:53 -07:00
7082d3a765 docs: document how to set heartbeat interval and election timeout
It gives more details about how to set heartbeat interval and election
timeout correctly based on RTT.
2015-08-18 13:54:44 -07:00
28cec1128d Merge pull request #3322 from philips/use-proxy-as-default-endpoint
Procfile: use proxy as default
2015-08-18 12:38:51 -07:00
087061e434 Merge pull request #3303 from yichengq/auth-path
use canonical path for auth
2015-08-18 12:06:48 -07:00
4778d780a8 pkg/pathutil: change copyright for path.go
The file only contains the function that is borrowed from std http lib,
so we use their copyright.
2015-08-18 11:48:22 -07:00
9106675fd4 Procfile: use proxy as default
I think it makes sense to make the proxy listen on the default port so
we can give the proxy more testing by default. Also, this should make it
easy to kill a single etcd member and test that etcdctl still works,
etc.

However, I have hit a bug: the proxy takes several seconds
2015-08-18 09:42:13 -07:00
fab3feab66 etcdctl/role: reject non-canonical permission path
Non-canonical permission path is useless because the path received
by auth is always canonical, which is due to our ServeMux always
redirects request to canonical path().

This helps users to detect path permission setting error early.

Ref: http://godoc.org/net/http#ServeMux
2015-08-18 08:59:53 -07:00
b5ec7f543a client: use canonical url path in request
The main change is that it keeps the trailing slash. This helps
auth feature to judge path permission accurately.
2015-08-18 08:59:48 -07:00
927d5f3d26 Merge pull request #3301 from yichengq/ca-file
etcdmain: update -ca-file description
2015-08-17 23:36:33 -07:00
c0747a7b8b etcdmain: update -ca-file description
so people could deprecate old flags and use new flags much easier.
2015-08-17 22:36:04 -07:00
bcb4d5d53e Merge pull request #3311 from yichengq/request-timeout
extend hardcoded timeout for globally-deployed etcd cluster
2015-08-17 17:00:24 -07:00
dfc6b4436f Merge pull request #3315 from xiang90/key_err
etcdhttp:write etcderror for all errors in keyhandler
2015-08-17 16:54:12 -07:00
ffae601af5 etcdmain: calculate dial timeout for peer transport
This helps peer communication in globally-deployed cluster.
2015-08-17 16:52:53 -07:00
1375ef8985 etcdserver: remove getVersion timeout
The request can still time out because we have set dial timeout and
read/write timeout. It increases timeout expectation from 1s to 5s,
but it makes it workable in globally-deployer cluster.
2015-08-17 16:50:40 -07:00
c7fbc01ef1 Merge pull request #3314 from sebschrader/proxy-loop
Warn about proxy loops with incorrect advertise-client-urls
2015-08-17 16:04:00 -07:00
d487cf6b63 etcdhttp:write etcderror for all errors in keyhandler 2015-08-17 15:51:29 -07:00
f70950ff93 docs: warn about proxy loops with incorrect advertise-client-urls 2015-08-18 00:42:48 +02:00
c530385d6d Merge pull request #3313 from yichengq/internal-timeout
etcdserver: use ReqTimeout only
2015-08-17 15:05:46 -07:00
af6d1d3d95 Merge pull request #3310 from xiang90/http_err
*: key handler should write auth error as etcd error
2015-08-17 14:57:19 -07:00
2d5b95c49f etcdserver: use ReqTimeout only
We cannot refer RTT value from heartbeat interval, so CommitTimeout
is invalid. Remove it and use ReqTimeout instead.
2015-08-17 14:54:25 -07:00
87f061bab2 *: key handler should write auth error as etcd error 2015-08-17 14:45:45 -07:00
ba3a9b5f92 Merge pull request #3309 from xiang90/enforce
etcdserver: add version enforcement when setting cluster version
2015-08-17 12:41:04 -07:00
15e03d801f etcdserver: add version enforcement when setting cluster version 2015-08-17 11:12:39 -07:00
f615f9a999 Merge pull request #3305 from xiang90/c_v
*: only print out major.minor version for cluster version
2015-08-17 09:40:01 -07:00
7083828ae3 Godeps: import github.com/ugorji/go/codec 2015-08-16 18:13:44 -07:00
a364af72af client: use ugorij/go/codec to unmarshal key response
This change speeds up response unmarshal ~2x:

```
BenchmarkSmallResponseUnmarshal	   20000	     75243 ns/op
BenchmarkManySmallResponseUnmarshal	     200	   6629661 ns/op
BenchmarkMediumResponseUnmarshal	    1000	   1359041 ns/op
BenchmarkLargeResponseUnmarshal	      20	  61600978 ns/op
```
2015-08-16 18:08:54 -07:00
95d100e957 client: add response unmarshal benchmark
The benchmark result:

```
BenchmarkSmallResponseUnmarshal	  10000	   164524 ns/op
BenchmarkManySmallResponseUnmarshal	    100	 13916636 ns/op
BenchmarkMediumResponseUnmarshal	   1000	  1974295 ns/op
BenchmarkLargeResponseUnmarshal	     20	 80462001 ns/op
ok		github.com/coreos/etcd/client	7.777s
```
2015-08-16 16:44:50 -07:00
d95c7d8a94 Merge pull request #3307 from ian-kelling/master
documentation: fix misspelled word
2015-08-15 18:53:58 -07:00
8dd44465c3 documentation: fix misspelled word 2015-08-15 17:56:17 -07:00
f199a484af *: only print out major.minor version for cluster version 2015-08-15 08:30:06 -07:00
bbcb38189c Merge pull request #3302 from xiang90/v
etcdserver: better version detection log output
2015-08-14 16:14:55 -07:00
0076ab154b etcdserver: better version detection log output
Fix https://github.com/coreos/etcd/issues/3288
2015-08-14 16:08:33 -07:00
dd56b7e05e Merge pull request #3299 from xiang90/txn
initial support for txn
2015-08-14 16:05:16 -07:00
5cd109949a etcdctl: support txn 2015-08-14 15:58:38 -07:00
9233fff48f etcdserver: support txn 2015-08-14 11:45:31 -07:00
46865fa5a5 etcdserverpb: update proto 2015-08-14 11:45:07 -07:00
d448593bbc Merge pull request #3295 from yichengq/err-example
client: fix clusterError typo in README
2015-08-14 09:35:31 -07:00
5eed141d54 client: fix clusterError typo in README
It helps users to use client better.
2015-08-13 16:38:41 -07:00
fefb273389 *: bump to v2.2.0-alpha.1+git 2015-08-13 16:01:31 -07:00
201bb4b3d8 *: bump to v2.2.0-alpha.1 2015-08-13 16:01:09 -07:00
3cc4957d98 Merge pull request #3293 from yichengq/improve-err
etcdserver: improve error message when timeout due to leader fail
2015-08-13 15:58:48 -07:00
c229e6e655 etcdserver: improve error message when timeout due to leader fail 2015-08-13 15:46:21 -07:00
394894e03e Merge pull request #3291 from yichengq/auth-cap
etcdhttp: add auth capability in 2.2
2015-08-13 15:01:59 -07:00
ceb27b1c48 etcdhttp: add auth capability in 2.2 2015-08-13 14:49:10 -07:00
a17288558e Merge pull request #3289 from yichengq/marshal
etcdserver: go back to marshal request in 2.1 way
2015-08-13 14:20:24 -07:00
334bdd1c26 Merge pull request #3153 from gtank/tls-setup
hack: TLS setup using cfssl
2015-08-13 13:53:14 -07:00
959feb70d1 Merge pull request #3275 from xiang90/sort
improve in order key generation
2015-08-13 13:51:19 -07:00
a7b9bff939 store: add 0 as padding for better lexicographic sorting. 2015-08-13 13:42:37 -07:00
0fdb77aea2 etcdserver: go back to marshal request in 2.1 way
It fixes the problem that 2.1 cannot roll upgrade to 2.2 smoothly
because 2.1 cannot understand the bytes marshalled at 2.2.
2015-08-13 13:41:52 -07:00
003d096138 Merge pull request #3286 from yichengq/fit-2.2
*: update MinClusterVersion and supportedStream map
2015-08-13 13:31:37 -07:00
c9cca6a93b *: update MinClusterVersion and supportedStream map 2015-08-13 13:05:14 -07:00
846b1fdbcd Merge pull request #3287 from xiang90/update_roadmap
Update roadmap
2015-08-13 13:00:01 -07:00
329647ab62 roadmap: update roadmap 2015-08-13 12:56:23 -07:00
6a64051245 roadmap: remove 2.1 milestone 2015-08-13 12:51:58 -07:00
80005af5b2 Merge pull request #3285 from yichengq/bump-capnslog
godeps: bump capnslog to 42a8c3b1a6f917bb8346ef738f32712a7ca0ede7
2015-08-13 11:49:38 -07:00
d66ede7186 godeps: bump capnslog to 42a8c3b1a6f917bb8346ef738f32712a7ca0ede7 2015-08-13 11:32:45 -07:00
a46943548a *: bump to v2.2.0-alpha.0+git 2015-08-13 10:21:36 -07:00
ab5a69cb18 *: bump to v2.2.0-alpha.0 2015-08-13 10:20:05 -07:00
976ce93539 Merge pull request #3277 from yichengq/better-log
etcdserver: specify timeout caused by leader election
2015-08-12 17:02:27 -07:00
27170e67b9 etcdserver: specify timeout caused by leader election
Before this PR, the timeout caused by leader election returns:

```
14:45:37 etcd2 | 2015-08-12 14:45:37.786349 E | etcdhttp: got unexpected
response error (etcdserver: request timed out)
```

After this PR:

```
15:52:54 etcd1 | 2015-08-12 15:52:54.389523 E | etcdhttp: etcdserver:
request timed out, possibly due to leader down
```
2015-08-12 16:53:18 -07:00
ddfe343e77 Merge pull request #3271 from yichengq/doc-discovery
docs: add discovery protocol doc
2015-08-12 13:51:32 -07:00
a45f0ede56 docs: add discovery protocol doc
This document talks about the technical details of discovery service
protocol. It helps users to learn about how discovery service works and
what behavior to expect.
2015-08-12 13:15:21 -07:00
7bd9d9aede Merge pull request #3273 from polvi/kube-hack
add etcd on k8s example
2015-08-12 22:13:15 +03:00
cfb3522b63 add etcd on k8s example 2015-08-12 22:12:00 +03:00
f468d8b51a Merge pull request #3270 from xiang90/better_err
Better error message for etcdctl
2015-08-12 10:27:42 -07:00
7e04a79fb4 etcdctl: print out better error information 2015-08-12 10:09:56 -07:00
5d06d4ec44 client: print url as string 2015-08-12 10:09:40 -07:00
e894756144 Merge pull request #3190 from yichengq/adjust-prop-timeout
etcdserver: adjust proposal timeout based on config
2015-08-12 09:41:25 -07:00
c3d4d11402 etcdhttp: adjust request timeout based on config
It uses heartbeat interval and election timeout to estimate the
expected request timeout.

This PR helps etcd survive under high roundtrip-time environment,
e.g., globally-deployed cluster.
2015-08-12 09:22:59 -07:00
18ecc297bc Merge pull request #3254 from es-chow/log-group
set groupID in multinode as log context so it can be logged
2015-08-12 08:05:50 -07:00
cc362ccdad raft: set logger to raft so log context such as multinode groupID can be logged 2015-08-12 22:56:00 +08:00
5a91937367 etcdserver: adjust commit timeout based on config
It uses heartbeat interval and election timeout to estimate the
commit timeout for internal requests.

This PR helps etcd survive under high roundtrip-time environment,
e.g., globally-deployed cluster.
2015-08-11 21:09:03 -07:00
042afcf2a3 Merge pull request #3266 from yichengq/client-readme
client: clean up README
2015-08-11 16:21:13 -07:00
7d618c46ad client: clean up README
Address rob's comments about sentences in README.
2015-08-11 15:33:56 -07:00
18a1c95f22 Merge pull request #3263 from xiang90/ctl_tr
etcdctl: add per request timeout
2015-08-11 14:17:12 -07:00
dceacacd49 Merge pull request #3194 from yichengq/client-readme
client: add README
2015-08-11 13:35:54 -07:00
e36c499d0f etcdctl: add per request timeout 2015-08-11 13:33:50 -07:00
8a7cf56e13 client: add README
It describes some basic usage and caveat of etcd/client package.

Write it together with Xiang.
2015-08-11 12:07:24 -07:00
83efc08137 Merge pull request #3262 from yichengq/client-deadline
client: return context.DeadlineExceeded instead of ClusterError
2015-08-11 10:42:29 -07:00
a1ef699aeb client: return context.DeadlineExceeded instead of ClusterError
This is done to match user expectation to see context.DeadlineExceeded
when it reaches deadline.
2015-08-11 10:18:38 -07:00
1fe52e1ec3 Merge pull request #3245 from yichengq/client_timeout
client: set timeout for each request
2015-08-11 10:10:42 -07:00
f4c29a5f55 client: support to set timeout for each request
Add HeaderTimeout field in Config, so users could set timeout for each request.
Before this, one hanged request may block the call for long time. After
this, if the network is good, the user could set short timeout and expect
that API call can attempt next available endpoint quickly.
2015-08-11 10:01:05 -07:00
a718329ad3 Merge pull request #3248 from xiang90/v3
initial v3 demo
2015-08-10 13:59:03 -07:00
fb5e1ac548 Merge pull request #3256 from xiang90/update_log
update logger
2015-08-10 13:54:28 -07:00
6c58333969 etcdmain: use default formatter
The default formatter would use syslog style when running
under init system, and would use pretty format otherwise.
2015-08-10 13:38:22 -07:00
48e36bbb84 Godep: update capnslog dependency 2015-08-10 13:38:00 -07:00
b0ea4ab3b1 doc: link to v3 api doc 2015-08-10 11:22:55 -07:00
c32919e6d1 *: rename v3etcdctl to etcdctlv3 2015-08-10 11:21:37 -07:00
c1e0b19f9f *: better flag 2015-08-10 09:53:17 -07:00
48b1cd54f3 Merge pull request #3243 from xiang90/conf
doc: add runtime reconfiguration design doc
2015-08-09 10:56:51 -07:00
89bf5824c2 Merge pull request #3159 from sofuture/master
use /usr/bin/env to find bash
2015-08-09 10:56:12 -07:00
601801ced5 doc: add runtime reconfiguration design doc 2015-08-09 10:55:34 -07:00
45f3a0c547 Merge pull request #3249 from philips/get-etcd-running-under-arm64
Get etcd running under arm64
2015-08-08 20:32:33 -07:00
1239e1ce6f test, scripts: use /usr/bin/env to find bash
use /usr/bin/env to find bash

add set -e back into scripts it was removed from
2015-08-08 20:52:53 -06:00
1b894c6b0b test: race detector doesn't work on armv7l
Test fails without this fix on armv7l:

    go test: -race is only supported on linux/amd64, freebsd/amd64, darwin/amd64 and windows/amd64
2015-08-08 18:11:41 -07:00
fb1951204c etcdserver: move atomics to make etcd work on arm64
Follow the simple rule in the atomic package:

"On both ARM and x86-32, it is the caller's responsibility to arrange
for 64-bit alignment of 64-bit words accessed atomically. The first word
in a global variable or in an allocated struct or slice can be relied
upon to be 64-bit aligned."

Tested on a system with /proc/cpuinfo reporting:

processor       : 0
model name      : ARMv7 Processor rev 1 (v7l)
Features        : swp half thumb fastmult vfp edsp thumbee neon vfpv3
tls vfpv4 idiva idivt vfpd32 lpae evtstrm
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xc0d
CPU revision    : 1
2015-08-08 18:11:41 -07:00
9ff7075ce8 etcdserver: use v3server interface 2015-08-08 10:39:04 -07:00
523567bcc7 v3etcdctl: initial v3 ctl support 2015-08-08 05:58:58 -07:00
f004b4dac7 *: etcdserver supports v3 demo 2015-08-08 05:58:29 -07:00
82afadbcc6 etcdserverpb: update proto 2015-08-08 05:31:35 -07:00
668a8a8367 Merge pull request #3242 from xiang90/typo
*: fix typos vaild->valid
2015-08-07 10:58:39 -07:00
845c51fedd *: fix typos vaild->valid 2015-08-07 10:57:11 -07:00
f0a5874473 Merge pull request #3241 from yichengq/sync-pin
client: Sync() pin the endpoint when member list doesn't change
2015-08-07 10:24:29 -07:00
0ab16db728 client: Sync() pin the endpoint when member list doesn't change
This helps client to pin the same endpoint as long as cluster doesn't change.
2015-08-07 10:08:28 -07:00
d7adcc3e65 Merge pull request #3239 from xiang90/improve_probing
rafthttp: use customized transport for probing
2015-08-07 09:37:32 -07:00
b6580a9591 rafthttp: use customized transport for probing
We need to support TLS verification when probing.
2015-08-06 16:20:44 -07:00
d2363afd52 Merge pull request #3240 from xiang90/fix_log
etcdmain: fix path printing
2015-08-06 15:56:14 -07:00
f03f048232 Merge pull request #3184 from yichengq/fast-bootstrap
etcdserver: tick ElectionTicks before starting when bootstrap new cluster
2015-08-06 15:54:40 -07:00
1b572ae2dd etcdmain: fix path printing 2015-08-06 15:53:24 -07:00
21f5b885f2 etcdserver: fast election timeout when bootstrap cluster
The behavior accelarates the happen of the first-time leader election,
so the cluster could elect its leader fast. Technically, it could
help to reduce `electionMs - heartbeatMs` wait time for the first leader election.

Main usage:
1. Quick start for the local cluster when setting a little longer
election timeout
2. Quick start for the global cluster, which sets election timeout to
its maximum 50s.
2015-08-06 15:44:26 -07:00
a637e86372 Merge pull request #3220 from yichengq/fix-auth-check
etcdhttp: fix access check for multiple roles in auth
2015-08-06 15:09:04 -07:00
b9c6b64d61 Merge pull request #3216 from yichengq/cancel-err
client: return context canceled error correctly
2015-08-06 15:04:49 -07:00
b965c4b415 Merge pull request #3217 from yichengq/update-migrate-example
update commands used in admin_guide.md
2015-08-06 15:00:04 -07:00
78af793338 client: return context canceled error correctly
If the body is closed to stop watching, it will ignore the error from
reading body and return context error.

Before this PR, the cancel when watching always returns error `read tcp
127.0.0.1:57824: use of closed network connection`. After this PR, it
will return expected context canceled error.
2015-08-06 14:52:04 -07:00
b04bb3e0ea Merge pull request #3229 from xiang90/f_cerr
client: return context.Canceled error when user cancels the request
2015-08-06 14:41:19 -07:00
25ad71fbac Merge pull request #3225 from yichengq/client-record-err
client: return correct error for 50x response
2015-08-06 14:40:38 -07:00
7314310aed Merge pull request #3233 from xiang90/srv_discovery
better dns discovery error and doc
2015-08-06 14:35:22 -07:00
cfeaf3d172 client: return correct error for 50x response
etcd always returns 500/503 response when it may have no leader.
So we should log the other 50x response in a normal way.

This helps to log correctly when discovery meets 504 error. Before this
PR, it logs like this:

```
18:31:58 etcd2 | 2015/08/4 18:31:58 discovery: error #0: client: etcd
member https://discovery.etcd.io has no leader
18:31:58 etcd2 | 2015/08/4 18:31:58 discovery: waiting for other nodes:
error connecting to https://discovery.etcd.io, retrying in 4s
```

After this PR:

```
22:20:25 etcd2 | 2015/08/4 22:20:25 discovery: error #0: client: etcd
member https://discovery.etcd.io returns server error [Gateway Timeout]
22:20:25 etcd2 | 2015/08/4 22:20:25 discovery: waiting for other nodes:
error connecting to https://discovery.etcd.io, retrying in 4s
```
2015-08-06 14:25:03 -07:00
e9f05e8959 doc: explain srv error 2015-08-06 14:24:58 -07:00
2c2249dadc Merge pull request #3219 from yichengq/limit-listener
etcdmain: stop accepting client conns when it reachs limit
2015-08-06 12:17:49 -07:00
97923ca3fc etcdmain: close client conns when it exceeds limit
This solves the problem that etcd may fatal because its critical path
cannot get file descriptor resource when the number of clients is too
big. The PR lets the client listener close client connections
immediately after they are accepted when
the file descriptor usage in the process reaches some pre-set limit, so
it ensures that the internal critical path could always get file
descriptor when it needs.

When there are tons to clients connecting to the server, the original
behavior is like this:

```
2015/08/4 16:42:08 etcdserver: cannot monitor file descriptor usage
(open /proc/self/fd: too many open files)
2015/08/4 16:42:33 etcdserver: failed to purge snap file open
default2.etcd/member/snap: too many open files
[halted]
```

Current behavior is like this:

```
2015/08/6 19:05:25 transport: accept error: closing connection,
exceed file descriptor usage limitation (fd limit=874)
2015/08/6 19:05:25 transport: accept error: closing connection,
exceed file descriptor usage limitation (fd limit=874)
2015/08/6 19:05:26 transport: accept error: closing connection,
exceed file descriptor usage limitation (fd limit=874)
2015/08/6 19:05:27 transport: accept error: closing connection,
exceed file descriptor usage limitation (fd limit=874)
2015/08/6 19:05:28 transport: accept error: closing connection,
exceed file descriptor usage limitation (fd limit=874)
2015/08/6 19:05:28 etcdserver: 80% of the file descriptor limit is
used [used = 873, limit = 1024]
```

It is available at linux system today because pkg/runtime only has linux
support.
2015-08-06 12:03:20 -07:00
203e0f178b etcdmian: better error for srv discovery failure 2015-08-06 11:38:53 -07:00
01c286ccb6 Merge pull request #3231 from xiang90/fallocate
pkg/fileutil: support perallocate
2015-08-06 10:25:28 -07:00
39a4b6a5e5 pkg/fileutil: support perallocate 2015-08-06 10:10:58 -07:00
9a8607fce1 Merge pull request #3187 from yichengq/client-keep-sync
client: add KeepSync function
2015-08-06 00:16:28 -07:00
c53b3016ae client: add AutoSync function
AutoSync provides the way for client to syncing member list from
etcd cluster automatically.
2015-08-05 13:22:56 -07:00
807a6f209e docs/admin_guide: decouple example from CoreOS specific details
This makes the example commands general, while keeping it easy to
understand. It also fixes some name mismatch.
2015-08-05 11:33:46 -07:00
f38187bbdb client: return context.Canceled error when user cancels the request 2015-08-05 09:52:30 -07:00
ff0b8723c7 Merge pull request #2688 from xiang90/versioning
etcdserver: internal request union
2015-08-05 09:27:32 -07:00
58503817ec etcdserver: internal request union 2015-08-05 07:47:10 -07:00
487639b2d8 Merge pull request #3222 from mitake/wal-log-error
wal: log errors in wal.Close()
2015-08-04 23:19:45 -07:00
9cbeffc720 Merge pull request #3224 from xiang90/fix_ls
etcdctl: ls takes / as default key arg
2015-08-04 23:15:29 -07:00
ba76e27875 wal: log errors in wal.Close()
This patch adds error logging in wal.Close() if unlocking and
destroying fail. Though it is hard to handling the errors, logging
would be helpful for trouble shooting.
2015-08-05 15:03:45 +09:00
9527a97720 etcdctl: ls takes / as default key arg 2015-08-04 22:56:55 -07:00
718a42f408 Merge pull request #3210 from xiang90/probing
monitoring connectivity between peers
2015-08-04 16:56:31 -07:00
18169e896c etcdhttp: fix access check for multiple roles in auth
Check access for multiple roles should go through all roles.
2015-08-04 14:31:07 -07:00
0650170a1b Merge pull request #3196 from eyakubovich/fix-watch-timeout
client: handle watch timing out elegantly
2015-08-04 13:52:42 -07:00
1e048b5c24 rafthttp: cleanup prober when stopping the transport 2015-08-04 17:42:51 +08:00
709718ed97 godeps: update probing pkg 2015-08-04 17:40:39 +08:00
0fc764200d rafthttp: monitor connection 2015-08-04 17:39:40 +08:00
ff5c3469c1 Merge pull request #3197 from xiang90/health
etcdctl: cluster-health supports forever flag
2015-08-03 20:48:06 -07:00
6312e22b1d client: handle empty watch responses elegantly
Even though current etcd does not time out
watches, the client could be running against
an old etcd version or the server may close
polling connection for other reasons.
This patch ignores successful (as in 200)
responses with emtpy bodies instead
of producing JSON errors.
2015-08-03 11:47:21 -07:00
306085db5f Godeps: add probing dependency 2015-08-03 09:07:43 +08:00
f7f00b0af6 etcdctl: cluster-health supports forever flag
cluster-health command supports checking the cluster health
forever.
2015-08-01 22:29:08 +08:00
3da1df2648 Merge pull request #3207 from xiang90/rm_migration
*: remove migration related stuff from 2.2
2015-08-01 19:47:17 +08:00
2b8abeb093 *: remove migration related stuff from 2.2 2015-08-01 19:37:20 +08:00
eee1c8b8ee Merge pull request #3200 from xiang90/d_doc
doc: unique names must be specified when using public discovery service
2015-08-01 07:34:25 +08:00
8bd9554338 Merge pull request #3202 from yichengq/fix-etcdctl-watch
etcdctl: fix watch -after-index parsing
2015-07-31 14:41:45 -07:00
4a89b3f8f3 Merge pull request #3116 from offscale/master
build: implemented build shell-script for Windows
2015-07-31 11:55:42 -07:00
05b2d06788 Merge pull request #3199 from xiang90/sdnotify
etcdmain: support sdnotify for readiness
2015-07-31 19:04:35 +08:00
4a0d8ee4bd build: implemented build shell-script for Windows 2015-07-31 17:43:47 +10:00
0cbac56fa2 etcdmain: support sdnotify for readiness 2015-07-31 13:33:18 +08:00
beeecc32b0 doc: unique names must be specified when using public discovery service 2015-07-31 09:12:44 +08:00
c1c5c7c99c Merge pull request #3091 from barakmich/client_auth_cov
etcdhttp: Improve test coverage surrounding auth
2015-07-30 17:00:49 -04:00
dd1a8fe330 etcdhttp: Improve test coverage surrounding auth 2015-07-30 14:21:08 -04:00
147885078c etcdctl: fix watch -after-index parsing
It uses -after-index incorrectly now:

```
$ ./bin/etcdctl --debug watch -after-index 31 foo
Cluster-Endpoints: http://localhost:2379, http://localhost:4001
cURL Command: curl -X GET
http://localhost:2379/v2/keys/foo?recursive=false&wait=true&waitIndex=33
```

After this PR:

```
$ ./bin/etcdctl --debug watch -after-index 31 foo
Cluster-Endpoints: http://localhost:2379, http://localhost:4001
cURL Command: curl -X GET
http://localhost:2379/v2/keys/foo?recursive=false&wait=true&waitIndex=32
```
2015-07-30 11:15:43 -07:00
219ed1695b Merge pull request #3178 from yichengq/refactor-cluster-health
etcdctl: refactor the way to check cluster health
2015-07-29 18:16:26 -07:00
80b794dccc Merge pull request #3185 from xiang90/add_debug_endpoint
etcdhttp: add config/local/debug endpoint
2015-07-30 08:46:07 +08:00
4e31df2c2b etcdhttp: add config/local/log endpoint
PUT on the endpoint sets the GlobalDebugLevel to json level value.
The action overwrites the origianl log level setting from
users. We need to write doc to warn this.
2015-07-30 08:35:01 +08:00
e62a3b8a62 Merge pull request #2891 from glensc/patch-1
build: use posix shell
2015-07-29 17:15:57 -07:00
ff945c7404 Merge pull request #3181 from xiang90/2.2-client-error
client: return cluster error if the etcd cluster is not avaliable
2015-07-30 08:08:09 +08:00
f1aaa7a9e3 etcdctl: refactor the way to check cluster health
This method uses raft status exposed at /debug/varz to determine the
health of the cluster. It uses whether commit index increases to
determine the cluster health, and uses whether match index increases to
determine the member health.

This could fix the bug #2711 that fails to detect follower is unhealthy
because it doesn't rely on whether message in long-polling connection is sent.

This health check is stricter than the old one, and reflects the
situation that whether followers are healthy in the view of the leader. One
example is that if the follower is receiving the snapshot, it will turns
out to be unhealthy because it doesn't move forward.

`etcdctl cluster-health` will reflect the healthy view in the raft level,
while connectivity checks reflects the healthy view in transport level.
2015-07-29 17:06:55 -07:00
a47e661fff discovery: print out detailed cluster error 2015-07-29 23:06:57 +08:00
5fa8652241 client: return cluster error if the etcd cluster is not avaliable
Add a new ClusterError type. It contians all encountered errors and
return ClusterNotAvailable as the error string.
2015-07-29 22:55:15 +08:00
6b8b507312 Merge pull request #3176 from yichengq/reject-high-election
etcdmain: reject unreasonably high values of -election-timeout
2015-07-28 10:33:58 -07:00
ec214030d0 etcdmain: reject unreasonably high values of -election-timeout
This helps users to detect setting problem early.
2015-07-28 10:07:57 -07:00
edfec45bf5 hack: TLS setup using cfssl
this demonstrates basic TLS setup with cfssl. it's much easier than other
available tools.
2015-07-27 14:51:17 -07:00
7831a30e46 Merge pull request #3180 from shafreeck/master
Update libraries-and-tools.md
2015-07-27 14:45:31 -07:00
6184e271a4 Merge pull request #3164 from yichengq/pin-endpoint
client: pin itself to an endpoint that given
2015-07-27 14:35:51 -07:00
6fc9dbfe56 Merge pull request #3114 from yichengq/clean-raft-init
etcdserver: clean up start and stop logic of raft
2015-07-27 14:19:25 -07:00
ea2347a40f client: pin itself to an endpoint that given
1. When reset endpoints, client will choose a random endpoint to pin.
2. If the pinned endpoint is healthy, client will keep using it.
3. If the pinned endpoint becomes unhealthy, client will attempt other
endpoints and update its pin.
2015-07-27 13:36:53 -07:00
7696dd3280 etcdserver: clean up start and stop logic of raft
kill TODO and make it more readable.
2015-07-27 13:24:26 -07:00
5e3dc31e6f Merge pull request #3150 from gouyang/master
pkg/mflag: add modified flag package
2015-07-24 15:26:07 -07:00
a7eef376b7 Merge pull request #3183 from xiang90/txn
*: tnx -> txn
2015-07-25 01:48:06 +08:00
53a77fa519 *: tnx -> txn 2015-07-24 23:21:09 +08:00
c9769ee966 etcdmain: Don't print flags when flag parse error
At present it prints the whole usage and flags, which cause the exact
error message is hidden two screens above.

Fixes #3141

Signed-off-by: Guohua Ouyang <gouyang@redhat.com>
2015-07-24 21:29:21 +08:00
e75446ca27 docs: add cetcd into libraries-and-tools.md 2015-07-24 12:08:39 +00:00
b407f72766 Merge pull request #3166 from yichengq/publish-timeout
etcdserver: rename defaultPublishRetryInterval -> defaultPublishTimeout
2015-07-23 10:30:41 -07:00
b7892b20c1 etcdserver: rename defaultPublishRetryInterval -> defaultPublishTimeout
This makes code more readable and reasonable.
2015-07-23 10:09:28 -07:00
58bc617dd0 Merge pull request #3175 from xiang90/2.2-ctl-bug
etcdctl: fix exec watch command
2015-07-23 14:37:38 +08:00
448ca20cdc etcdctl: fix exec watch command
The previous flag parsing has a small issue. It uses
`recursive == true` and `after-index == 0` to determine
if user specifies the sub flags. This is incorrect since
user can specify `after-index = 0`. Then the flag parsing
would be confused.

This commit explicitly find the `--` in the remaining args
and determine the key and cmdArgs accordingly.
2015-07-23 13:13:15 +08:00
43f4b99d52 Merge pull request #3174 from xiang90/2.2_submit_bug
doc: add reporting bug doc
2015-07-23 13:08:35 +08:00
1b5e41e3f4 doc: add reporting bug doc 2015-07-23 12:55:38 +08:00
93002caca5 Merge pull request #3165 from yichengq/client-quorum
client: add Quorum option in getOption
2015-07-22 16:54:14 -07:00
b20b87893f client: add Quorum option in getOption 2015-07-22 15:19:34 -07:00
6be02ff5ec etcdmian: fix initialization confilct
Fix #3142

Ignore flags if etcd is already initialized.
2015-07-21 12:53:21 -07:00
24db661401 etcdmain: warn when listening on HTTP if TLS is set
If the user sets TLS info, this implies that he wants to listen on TLS.
If etcd finds that urls to listen is still HTTP schema, it prints out
warning to notify user about possible wrong setting.
2015-07-21 12:53:21 -07:00
604709cad7 etcdctl: update -peers to default to use schema
Change its default value from `127.0.0.1:4001,127.0.0.1:2379` to
`http://127.0.0.1:4001,http://127.0.0.1:2379`

Adding HTTP schema makes its format consistent with etcd's xxx-urls
flags.
2015-07-21 12:53:21 -07:00
d9c27138fa discovery: return bad discovery endpoint error 2015-07-21 12:53:21 -07:00
d2dac0fe59 client: consume json error and return ErrInvaildJSON
The default JSON error is not very readable. We let client
consume the error and return a more understandable error in
the context of etcd.

Fix #3120
2015-07-21 12:53:21 -07:00
6317abf7e4 pkg/transport: fix HTTPS downgrade bug for keepalive listener
If TLS config is empty, etcd downgrades keepalive listener from HTTPS to
HTTP without warning. This results in HTTPS downgrade bug for client urls.
The commit returns error if it cannot listen on TLS.
2015-07-21 12:53:21 -07:00
43437e21f9 etcdctl: added domain discovery flag
provided a domain, will look up SRV records for etcd endpoints

Fixes #2636
2015-07-21 12:53:21 -07:00
dc3f7f5d90 *: detect duplicate name for discovery bootstrap 2015-07-21 12:53:20 -07:00
b8279b3591 types: add len func for urlmaps 2015-07-21 12:53:20 -07:00
ee82ee05b4 etcdctl: support member update command 2015-07-21 12:53:20 -07:00
6e3769d39e client: add member update 2015-07-21 12:53:20 -07:00
9f9661f513 etcdctl: print out key and action when watching recursively 2015-07-21 12:53:20 -07:00
87ef0f0b3e godep: remove go-etcd dependency 2015-07-21 12:53:20 -07:00
071ad9f72b etcdctl: health use etcd/client 2015-07-21 12:53:20 -07:00
0b1ddce889 etcdctl: import snap use etcd/client 2015-07-21 12:53:20 -07:00
adeb101e04 etcdctl: remove old stuff 2015-07-21 12:53:20 -07:00
759c156e3e etcdctl: exec_watch use etcd/client 2015-07-21 12:53:20 -07:00
5b01b3877f etcdctl: watch use etcd/client 2015-07-21 12:53:20 -07:00
b20c06348d etcdctl: ls use etcd/client 2015-07-21 12:53:19 -07:00
ae1669de26 etcdctl: updatedir use etcd/client 2015-07-21 12:53:19 -07:00
f12ae45c6a etcdctl: update use etcd/client 2015-07-21 12:53:19 -07:00
58b19a7c1e etcdctl: rmdir use etcd/client 2015-07-21 12:53:19 -07:00
9d7a8dd2b0 etcdctl: mk use etcd/client 2015-07-21 12:53:19 -07:00
61befc7ce6 etcdctl: minor cleanup 2015-07-21 12:53:19 -07:00
e3fcc450cf etcdctl: make rm use etcd/client 2015-07-21 12:53:19 -07:00
9d9c3a7180 etcdctl: make setdir/mkdir use etcd/client 2015-07-21 12:53:19 -07:00
db4b18aee3 etcdctl: make set command use etcd/client 2015-07-21 12:53:19 -07:00
e9478ba630 etcdctl: make get command use etcd/client 2015-07-21 12:53:19 -07:00
147b14cfc0 *: bump to v2.1.1+git 2015-07-21 10:43:49 -07:00
6335fdc595 *: bump to v2.1.1 2015-07-21 10:41:26 -07:00
ca540b23dc Merge pull request #3158 from yichengq/exp-auth
docs: add experimental notice on auth doc
2015-07-21 10:24:11 -07:00
097ec0f25b docs: add experimental notice on auth doc
Reasons for the notice:
1. No users have reported about their feedback about auth feature so
far.
2. We haven't used it internally.
3. This is the first release that includes auth feature, so it is good
to be more cautious.
2015-07-21 10:23:23 -07:00
ed444419c0 Merge pull request #3160 from ryandoyle/docs-nss-etcd
docs: glibc NSS module for resolving names in etcd
2015-07-21 08:53:08 +08:00
d373645b8c docs: glibc NSS module for resolving names in etcd 2015-07-21 10:33:23 +10:00
d86e94b824 Merge pull request #3128 from yichengq/doc-watch-api
docs: update watch API doc for clarity
2015-07-20 14:54:26 -07:00
d52cb2e5d9 docs: add watch command and correct the example 2015-07-20 14:49:01 -07:00
40681bdf03 Merge pull request #3146 from a-robinson/snap
snap: Record the snapshot save duration on success rather than only on error
2015-07-17 06:03:33 +08:00
7d38115cb2 Merge pull request #3148 from yichengq/update-contact
Update contact section in README.md
2015-07-16 15:01:54 -07:00
f8baa4ebe0 Merge pull request #3138 from barakmich/auth_doc
documentation: Add authentication walkthrough with etcdctl. Fixes #2949
2015-07-16 16:41:15 -04:00
9b962c8350 README: let roadmap point to ROADMAP.md 2015-07-16 12:58:13 -07:00
c1aed32920 README: update irc channel to #etcd 2015-07-16 12:52:26 -07:00
57a5520157 snap: Record the snapshot save duration on success rather than only on error.
It makes more sense to record the latency of successes (or all attempts)
than of only a particular failure case.
2015-07-16 10:46:47 -07:00
452a327334 documentation: Add authentication walkthrough with etcdctl. Fixes #2949 2015-07-15 15:54:26 -04:00
ebbb0caff0 Merge pull request #3136 from yichengq/fix-proxy-doc
docs: fix wrong proxy command
2015-07-15 11:30:07 -07:00
d0e976ad4b docs: fix wrong proxy command 2015-07-15 08:37:10 -07:00
d0e3e2c992 Merge pull request #3131 from yichengq/remove-header-timeout
discovery: remove ResponseHeaderTimeout when discovery
2015-07-15 07:50:36 +08:00
1db176151b discovery: remove ResponseHeaderTimeout when discovery
The discovery service doesn't return HTTP header early when watch
starts. This may trigger ResponseHeaderTimeout and cause the watch
request failed.

The fix on discovery service may take some time. Remove the
ResponseHeaderTimeout first so it behaves as before.
2015-07-14 16:33:28 -07:00
f52db1c08e docs: add back original example w/index=prevIndex 2015-07-13 23:04:39 -07:00
b94f6595e6 docs: rewrite existing docs instead of adding a new section
@xiang90 pointed out my earlier commit duplicated a lot of things that
were mentioned earlier in the doc.

This time around I tried just making some gotchas more explicit in the
existing docs instead of just tacking new stuff onto the end.
2015-07-13 23:03:59 -07:00
953a59d554 Merge pull request #3127 from yanana/emend-error-message
etcdmain: emend configuration error message
2015-07-14 13:46:08 +08:00
d7276d6ace etcdmain: emend configuration error message
etcd shows an odd message on configuration error like this (partially):
```
... discovery or bootstrap flags are setChoose one of ...
                                      ^^^^^^^^^
```
This commit fixes the message format problem.
2015-07-14 14:42:49 +09:00
d80f4c8aa2 Merge pull request #3125 from yichengq/doc-tuning
docs: update tuning.md to match today's situation
2015-07-13 16:52:11 -07:00
8b7c600009 docs: update tuning.md to match today's situation
1. etcd requires that election-timeout >= 5 * heartbeat-interval
2. etcd doesn't have flag -snapshot
2015-07-13 16:35:30 -07:00
7a520bb80b Merge pull request #3121 from yichengq/extend-schedule
pkg/testutil: extend wait schedule time to 10ms
2015-07-13 15:23:36 -07:00
1624235bb3 pkg/testutil: extend wait schedule time to 10ms
Waiting 3ms is not long enough for schedule to work well. The test suite
may fail once per 200 times in travis due to this. Extend this to 10ms
to ensure schedule could work. Now it could run 1000 times successfully
in travis.
2015-07-13 09:05:40 -07:00
5be545b872 Merge pull request #3077 from yichengq/fix-test-sync
etcdserver: init raft internal var early
2015-07-10 14:44:52 -07:00
c7a949349e Merge pull request #3113 from xiang90/fix_proxy_bt
etcdmain: proxy ignores discovery if it is initialized
2015-07-10 14:12:45 -06:00
dedabddcb3 etcdmain: proxy ignores discovery if it is initialized 2015-07-10 12:52:24 -07:00
61e9b99edb Merge pull request #2417 from kelseyhightower/improve-etcdctl-ls-command-help
etcdctl: update the ls subcommand help to match behavior
2015-07-09 11:33:19 -06:00
4631b727c0 Merge pull request #3105 from xiang90/rd
doc: add rolling upgrade doc for 2.1
2015-07-09 11:27:05 -06:00
11452585bb doc: add rolling upgrade doc for 2.1 2015-07-07 13:20:41 -07:00
8ab388fa56 Merge pull request #3001 from mwitkow-io/feature/rich_metrics
Etcd Rich Metrics
2015-07-07 08:12:06 -07:00
7bca757d09 *: add metrics to store and proxy. 2015-07-07 16:01:51 +01:00
573f62f7a5 Merge pull request #3101 from yichengq/check-err
integration: always check error for function calls
2015-07-06 18:10:31 -07:00
e7ed7a7b7a integration: always check error for function calls 2015-07-06 17:44:36 -07:00
121ff4684c Merge pull request #3097 from philips/tls-churn-faq
Documentation/security: add FAQ about peer TLS and etcd 2.0.x
2015-07-04 15:30:42 -07:00
83fe8187f4 Documentation/security: add FAQ about peer TLS and etcd 2.0.x
etcd 2.0.x TLS can appear not to work on smaller machines with less
horse-power or lots of other work going on. Document the timeout
workaround.
2015-07-04 15:28:47 -07:00
09b9c30beb pkg/transport: include debug output for trusted-ca
since --peer-ca-file is deprecated we need to update the debug output

before:

```
$ etcd ... --peer-cert-file infra1.crt -peer-key-file
 infra1.key.insecure -peer-trusted-ca-file ca.crt --client-cert-auth
etcdmain: peerTLS: cert = infra1.crt, key = infra1.key.insecure, ca =
```

after:

```
$ etcd ... --peer-cert-file infra1.crt -peer-key-file
 infra1.key.insecure -peer-trusted-ca-file ca.crt --client-cert-auth
etcdmain: peerTLS: cert = infra1.crt, key = infra1.key.insecure, ca = , trusted-ca = ca.crt
```
2015-07-04 14:28:18 -07:00
cbe00e4415 Merge pull request #2967 from webner/feature/proxy-config
proxy: added endpoint refresh and timeout configuration values
2015-07-03 11:51:15 -07:00
954e416bf6 proxy: fixed director.go formatting 2015-07-03 14:11:40 +02:00
883bb47dcf Merge pull request #3074 from xiang90/storage_restore
storage: correctly restore create and ver
2015-06-30 09:20:19 -07:00
eff67afc60 Merge pull request #3081 from xiang90/storage_fix
storage: fix small issues
2015-06-29 22:05:46 -07:00
585e74a1b1 Merge pull request #3080 from xiang90/rpc
add gRPC etcd service
2015-06-29 22:04:47 -07:00
f8b947a00b storage: fix small issues 2015-06-29 22:02:21 -07:00
2fb8347d36 etcdserver: add rpc proto 2015-06-29 20:00:09 -07:00
436bacd77a *: introduce grpc dependency 2015-06-29 18:59:00 -07:00
718cb18ca2 Merge pull request #3079 from xiang90/gogo
*: resolve proto warnings
2015-06-29 18:50:49 -07:00
581ef05bab *: resolve proto warnings 2015-06-29 18:39:46 -07:00
621b43bacb Merge pull request #3078 from xiang90/gogo
update gogoprotobuf dependency
2015-06-29 16:59:08 -07:00
13f44e4b79 *: update generated proto code 2015-06-29 16:45:25 -07:00
59b479e59b godep: update gogo version 2015-06-29 16:08:04 -07:00
7f95780bfb etcdserver: init raft internal var early
Its `stopped`/`done` should be created always before being used
in defer in server loop.

It fixes the race detected when running TestSyncTrigger.
2015-06-29 15:34:15 -07:00
235aef5365 *: bump to v2.1.0-rc.0+git 2015-06-29 14:02:40 -07:00
00c32ef022 *: bump to v2.1.0-rc.0 2015-06-29 14:02:39 -07:00
9884c9d977 Merge pull request #3075 from yichengq/fix-windows
Godeps/capnslog: bump to 99f6e6b8f8ea30b0f82769c1411691c44a66d015
2015-06-29 14:02:16 -07:00
207b67c72a Godeps/capnslog: bump to 99f6e6b8f8ea30b0f82769c1411691c44a66d015
It fixes windows building problem.
2015-06-29 13:47:21 -07:00
433f2ee1bc storage: correctly restore create and ver
Add a restore func to correctly restore create reversion and
version of keys for the index.
2015-06-29 13:44:43 -07:00
8d3e3ff25a Merge pull request #3073 from xiang90/storage_ver
storage: save version
2015-06-29 13:19:02 -07:00
ccca2b04da storage: save version 2015-06-29 13:15:09 -07:00
bd84e678e6 Merge pull request #3061 from yichengq/fix-stream-test
rafthttp: fix TestStream uses outdated stream
2015-06-29 11:15:29 -07:00
f421eaeff7 Merge pull request #3071 from yichengq/rename-rafthttp-metrics
rafthttp: message_sent_latency metrics: channel -> sendingType
2015-06-29 10:58:36 -07:00
e01d53b853 Merge pull request #2979 from xiang90/fix_sendapp
raft: fix panic in send app
2015-06-29 10:49:04 -07:00
28342ae097 rafthttp: avoid TestStream to use outdated stream
The original test code before fb4b0b5cf0
doesn't work because reader side may update the
stream, while writer side writes message to the old stream and fails.

This PR removes unnecessary call to set term, and avoids this problem to
happen on term > 1 in the future.
2015-06-29 10:46:54 -07:00
2afa6688ab Merge pull request #3069 from yichengq/init-term
rafthttp: support to init term when adding peer
2015-06-29 10:45:53 -07:00
606876154d rafthttp: message_sent_latency metrics: channel -> sendingType
Better naming.
2015-06-29 10:44:40 -07:00
4430a80c0f Merge pull request #3063 from yichengq/fix-create-root
etcdserver/auth: fix return value when creating root user
2015-06-29 10:29:23 -07:00
bb287fa22e Merge pull request #3051 from yichengq/doc-rafthttp-metrics
docs: doc metrics used in rafthttp package
2015-06-29 10:22:50 -07:00
fb4b0b5cf0 rafthttp: support to init term when adding peer
So it doesn't need to build term-0 stream with the remote first, then update it.
2015-06-29 10:20:48 -07:00
2e41b4f9e1 etcdserver/auth: fix return value when creating root user
Before:

```
$ curl http://127.0.0.1:4001/v2/auth/users/root -XPUT -d '{"user": "root",
"password": "root"}'
{"user":"root","roles":null}
```

After:

```
{"user":"root","roles":["root"]}
```
2015-06-27 23:16:54 -07:00
c069119abe Merge pull request #3067 from xiang90/storage_created_mod
storage: save created index and modified index
2015-06-27 23:11:05 -07:00
fcdd9779e9 docs: explain label in rafthttp metrics 2015-06-26 15:51:39 -07:00
4581064060 storage: save created index and modified index 2015-06-26 12:10:26 -07:00
3e455ed104 Merge pull request #3062 from yichengq/fix-auth-doc
docs: fix typos in auth_api.md
2015-06-25 17:54:05 -07:00
9c695dce25 docs: fix typos in auth_api.md 2015-06-25 17:37:16 -07:00
acca9cc3a9 Merge pull request #3047 from barakmich/auth_cov
auth: improve test coverage
2015-06-25 14:47:22 -04:00
39c10d1fe4 auth: improve test coverage 2015-06-25 14:25:08 -04:00
3d4642c2c4 Merge pull request #3059 from yichengq/fix-wait-stress-test
pkg/wait: extend timeout to check closed channel
2015-06-25 11:16:54 -07:00
35d0839909 Merge pull request #3057 from yichengq/fix-snap-test
etcdserver: fix TestTriggerSnap
2015-06-25 10:51:36 -07:00
a347e1ecf5 Merge pull request #3058 from yichengq/fix-purge
pkg/fileutil: fix TestPurgeFile
2015-06-25 10:50:36 -07:00
eea7f28be4 pkg/wait: extend timeout to check closed channel
It is possible to trigger the time.After case if the timer went off
between time.After setting the timer for its channel and the time that
select looked at the channel. So it needs to be longer.

refer: https://groups.google.com/forum/#!topic/golang-nuts/1tjcV80ccq8
2015-06-25 10:43:12 -07:00
4c8408f92f docs: doc metrics used in rafthttp package 2015-06-25 10:38:36 -07:00
107263ef9f pkg/fileutil: fix TestPurgeFile
It needs to wait longer for file to be detected and removed sometimes.
2015-06-25 10:09:20 -07:00
5d131acfba etcdserver: fix TestTriggerSnap
Before checking, it needs to wait for snapshot goroutine to finish its
work.
2015-06-25 09:58:36 -07:00
2ace10626d Merge pull request #3050 from yichengq/doc-bench-tool
docs/benchmarks: doc benchmark tool
2015-06-25 08:15:02 -07:00
ca2ea1bc7d Merge pull request #3048 from ecnahc515/documentation_improvements
Documentation: Refer back between name and initial-cluster options
2015-06-24 15:22:46 -07:00
0949cc06e6 docs/benchmarks: doc benchmark tool 2015-06-24 15:11:08 -07:00
ea2c203aee Documentation: Refer back between name and initial-cluster options 2015-06-24 14:10:42 -07:00
44fda7985a Merge pull request #3046 from xiang90/metrics
refactor metrics
2015-06-24 13:58:28 -07:00
9aeb181d75 snap: add namespace and subsystem fields for metrics 2015-06-24 13:46:43 -07:00
c221844d6b Merge pull request #3024 from xiang90/fix_discovery
discovery: add timeouts for discovery client
2015-06-24 13:44:21 -07:00
52c2a5731f etcdserver: fix typo in metrics.go 2015-06-24 12:42:40 -07:00
b3cb5f9e4e Merge pull request #3043 from xiang90/update_auth_doc
auth: update the auth doc
2015-06-23 23:19:02 -07:00
96c0c7a202 Merge pull request #3044 from xiang90/fix_auth_update_role
auth: do not allow update root role
2015-06-23 22:43:28 -07:00
030d1bbf2d auth: do not allow update root role 2015-06-23 20:15:08 -07:00
403fad14ae auth: update the auth doc 2015-06-23 20:02:48 -07:00
c0b5cc6c52 Merge pull request #3041 from xiang90/auth_u
etcdhttp: improve user endpoint validation
2015-06-23 15:58:03 -07:00
94f8152487 Merge pull request #3042 from yichengq/fix-addr-in-use
integration: fix bind-addr-in-use
2015-06-23 15:57:50 -07:00
88b69a5979 Merge pull request #3030 from yichengq/fix-fallback-case
etcdmain: fix the check in fallback-to-proxy case
2015-06-23 14:48:45 -07:00
8e79fd85cb integration: fix bind-addr-in-use
The bug happens when restarted member wants to listen on its original
port, but finds out that it has been occupied by some client.

Use well-known port instead of ephemeral port, so client cannot occupy
the listen port anymore.
2015-06-23 14:47:21 -07:00
e291dfd748 etcdhttp: improve user endpoint validation
Giving both roles and grant/revoke is not allowed.
Creating an existing user is not allowed.
Updating a non-existing user is not allowed.
2015-06-23 14:38:44 -07:00
2d426b518a Merge pull request #3035 from yichengq/update-term
rafthttp: update term when AddPeer
2015-06-23 14:05:37 -07:00
37933cffa4 Merge pull request #3040 from xiang90/fix_auth
Fix auth
2015-06-23 13:47:25 -07:00
cf050ee21d Merge pull request #2943 from yichengq/fix-client-test
client: fix TestSimpleHTTPClientDoCancelContextResponseBodyClosed
2015-06-23 13:43:07 -07:00
e25e368321 rafthttp: update term when AddPeer
Update term when AddPeer, or the term in peer will not be updated until
the term is changed. This fixes the log flood happended when the v2.1
follower applies the snapshot from v2.0 leader:

```
rafthttp: cannot attach out of data stream server [0 / 17]
```
or
```
rafthttp: server streaming to 6e3bd23ae5f1eae0 at term 0 has been
stopped
```
2015-06-23 13:42:21 -07:00
c8628c8fe5 auth: separate the role create and update path
Giving both permission and grant/revoke is not allowed.
Creating an existing role is not allowed.
Updating a non-existing is not allowed.
2015-06-23 13:15:32 -07:00
36c5fd6265 etcdmain: fix the check in fallback-to-proxy case
advertise-client-urls has to be set if listen-client-urls is set when
fallbacking to proxy, which breaks the behavior. Loosen the check to fix
it.
2015-06-23 13:08:56 -07:00
bc61056912 etcdhttp: use correct http status const when writing http error 2015-06-23 12:40:30 -07:00
4f47a6ebfb Merge pull request #3032 from xiang90/refactor_update_role
auth: refactor updateRole
2015-06-23 11:17:45 -07:00
240e121792 Merge pull request #3039 from xiang90/update_auth
doc: update auth_api.md
2015-06-23 11:12:47 -07:00
aaf802f321 doc: update auth_api.md 2015-06-23 11:08:04 -07:00
ad7124599d Merge pull request #3033 from barakmich/strip_pass
etcdhttp: Always strip password hash when returning users
2015-06-22 18:39:50 -07:00
7f7e2cc79d Merge pull request #3034 from philips/replace-maximal-with-maximum
*: docs and code %s%maximal%maximum%g
2015-06-22 16:24:01 -07:00
740187f199 *: docs and code %s%maximal%maximum%g
maximum is a more common word, use it instead
2015-06-22 16:06:57 -07:00
028a1d6dd4 Merge pull request #2994 from webner/feature/cancel-proxy-request
proxy: handle canceled proxy request gracefully
2015-06-22 16:06:05 -07:00
d5a0e3ac6a etcdhttp: Always strip password hash when returning users 2015-06-22 18:39:16 -04:00
979f531261 auth: refactor updateRole
We will return error if revoke or grant fails to update the role.
No need to check if revoke or grant is nil or not.
2015-06-22 15:16:10 -07:00
462baedcd4 Merge pull request #3031 from xiang90/fix_auth
auth: do not allow to grant duplicate role or revoke ungranted role
2015-06-22 15:13:26 -07:00
3f82e7b116 auth: do not allow to grant duplicate role or revoke ungranted role to a user 2015-06-22 15:11:09 -07:00
51a65599dd Merge pull request #3021 from xiang90/auth_err
etcdserver: use correct http status code for auth error
2015-06-22 14:58:33 -04:00
c39aad0e92 etcdserver: use correct http status code for auth error 2015-06-22 09:28:47 -07:00
3e4479b0cd Merge pull request #3022 from xiang90/aut_type
etcdhttp: fix the response type for auth
2015-06-21 15:06:35 -07:00
ebd4102578 Merge pull request #3026 from xiang90/better_logging
etcdserver: better log message for url mismatch
2015-06-19 19:39:33 -07:00
d295d21349 etcdserver: better log message for url mismatch 2015-06-19 19:36:26 -07:00
1381b44adf discovery: add timeouts for discovery client 2015-06-19 16:50:44 -07:00
cad757efa0 etcdhttp: fix the response type for auth 2015-06-19 15:19:00 -07:00
b26b827780 Merge pull request #3020 from xiang90/auth_doc
auth: minor fix for user section
2015-06-19 15:08:51 -07:00
b1dbab2b6b auth: minor fix for user section 2015-06-19 14:30:04 -07:00
9f984ea6ae Merge pull request #3015 from xiang90/auth_doc
doc: move enable section to the top in auth_api.md
2015-06-19 14:13:19 -07:00
4f0f57b322 doc: move enable section to the top in auth_api.md 2015-06-19 14:08:29 -07:00
7ee4fb6181 Merge pull request #3011 from philips/fixup-discovery-info-output
discovery: fixup logline
2015-06-19 13:25:08 -04:00
e71dc2e565 discovery: fixup logline
before:

```
discovery: duringcluster status checkconnection tohttps://discovery.etcd.iotimed out, retrying in2s
```

after:

```
discovery: cluster status check: connection to https://discovery.etcd.io timed out, retrying in 2s
```
2015-06-19 13:19:09 -04:00
a6e6186477 proxy: always set requestClosed flag when client closes the connection prematurely 2015-06-19 08:45:45 +02:00
5787fabe5f Merge pull request #3008 from yichengq/storage-index-test
storage: add range and tombstone test for index
2015-06-18 19:29:31 -07:00
b20598eea0 storage: add range and tombstone test for index 2015-06-18 18:05:37 -07:00
1a7a5fd45d Merge pull request #3006 from yichengq/storage-kvstore-test
storage: remove unnecessary ForceCommit in kvstore.Close
2015-06-18 13:57:27 -07:00
9f2e4c8a57 storage: remove unnecessary ForceCommit in kvstore.Close
s.b.Close will commit pending ops, so there is no need to FroceCommit
it in kvstore.Close()
2015-06-18 13:36:23 -07:00
789e2f3426 Merge pull request #3003 from yichengq/storage-kvstore-test
storage: add restore test and fix some bug
2015-06-18 12:19:05 -07:00
7cba42fb73 storage: wait for compact goroutine to exit before close backend
If backend is closed, the operations on backend in compact
goroutine will panic. So this PR waits for compact goroutine to exit
before close backend.

This fixes the TestWorkflow failure too.
2015-06-18 12:18:39 -07:00
5e31854afd proxy: use atomic operations for requestCanceled flag 2015-06-18 20:56:28 +02:00
864ce5f946 proxy: handle canceled proxy request gracefully
when a client of the proxy server cancels a request the proxy should not
set the endpoint state to unavailable
2015-06-18 20:52:52 +02:00
148394f66f storage: fix schedule compaction bug in recover process
It uses wrong schedule compaction reversion before.
2015-06-18 11:11:37 -07:00
26a09d8479 storage: enhance TestRestore and kill TODO 2015-06-18 10:37:12 -07:00
0ef53ee500 Merge pull request #2999 from yichengq/storage-rev-test
storage: add reversion test
2015-06-18 07:39:18 -07:00
74fbf9d6a7 storage: add reversion test 2015-06-17 18:06:42 -07:00
06ca914429 Merge pull request #2998 from yichengq/storage-kvstore-test
storage: add kv range test
2015-06-17 17:49:55 -07:00
80a59f00b7 storage: fix limit mismatch in Range func 2015-06-17 17:43:08 -07:00
93f477944b storage: return ErrFutureRev if rev is a future one 2015-06-17 17:42:43 -07:00
94924d04db storage: add TestRangeBadRev 2015-06-17 16:22:28 -07:00
9ad5e1e64f storage: kill TODO in TestRange 2015-06-17 15:58:28 -07:00
05228729a3 Merge pull request #2996 from yichengq/storage-workflow-test
storage: add TestWorkflow
2015-06-17 15:05:12 -07:00
500894dfe5 storage: add TestWorkflow 2015-06-17 14:38:21 -07:00
7b1a93e1ef storage: put storage info keys into information bucket
They used to be in key bucket, and make recover failed because they
cannot be parsed as normal key.
2015-06-17 14:37:29 -07:00
d0f6432b51 *: bump to v2.1.0-alpha.1+git 2015-06-16 22:02:00 -07:00
c4a5088bbc *: bump to v2.1.0-alpha.1 2015-06-16 22:00:17 -07:00
2efbc76689 Merge pull request #2993 from xiang90/md
doc: add doc for metrics feature
2015-06-16 14:22:16 -07:00
c599e81d46 doc: add proposal into glossary.md 2015-06-16 14:19:18 -07:00
5c1d4544fc doc: add doc for metrics feature 2015-06-16 14:18:22 -07:00
cdcae2d6a5 Merge pull request #2991 from barakmich/security_rename
*: Rename `security` to `auth`
2015-06-16 14:41:34 -04:00
7716bdf981 client: fix TestSimpleHTTPClientDoCancelContextResponseBodyClosed
This fixes the bug that the test may hang forever because RoundTrip is
blocked. fixes #2449
2015-06-16 11:29:54 -07:00
aeeae25d87 proxy: documentation for disabling the proxy timeout 2015-06-16 12:18:16 +02:00
5854d0e8a9 proxy: removed unused refreshInterval variable in director structure 2015-06-16 12:17:08 +02:00
64ec8af91b *: Rename security to auth 2015-06-15 18:18:50 -04:00
b4022899eb raft: fix panic in send app
sendApp accesses the storage several times. Perviously, we
assume that the storage will not be modified during the read
opeartions. The assumption is not true since the storage can
be compacted between the read operations. If a compaction
causes a read entries error, we should not painc. Instead, we
can simply retry the sendApp logic until succeed.
2015-06-15 14:23:33 -07:00
e20b487904 Merge pull request #2978 from xiang90/fix_backup
*:fix point-in-time backup
2015-06-15 13:19:29 -07:00
f59da0e453 *:fix point-in-time backup
Backup process should be able to read all WALs until io.EOF to
generate a point-in-time backup.

Our WAL file is append-only. And the backup process will lock all
files before start reading, which can prevent the gc routine from
removing any files in the middle.
2015-06-15 11:12:28 -07:00
b69d52e5ac Merge pull request #2988 from xiang90/raft-doc
raft: fix usage section of doc
2015-06-15 10:39:40 -07:00
2f0169c3ab raft: fix usage section of doc
We recently added a config struct to start raft. Update
our doc accordingly.
2015-06-15 10:26:10 -07:00
5618adff99 Merge pull request #2977 from nikfoundas/patch-1
docs: add etcd-viewer into libraries-and-tools.md
2015-06-14 08:53:06 -07:00
3fc8d48421 Merge pull request #2982 from aybabtme/etcdserver/wrong-log-func
etcdserver: use Infof to print formatted argument
2015-06-14 06:53:20 -07:00
270487d340 etcdserver: use Infof to print formatted argument 2015-06-14 20:22:21 +07:00
dadbc03171 docs: add etcd-viewer into libraries-and-tools.md
I've been working on this project for a few weeks and I believe it has some features that could assist maintaining etcd registries. Please check it out and I hope you would like to include it in your list of etcd tools.
Kind regards,
Nikos
2015-06-14 02:25:42 +03:00
1264dbe24d proxy: added endpoint refresh and timeout configuration values
the default dial timeout was set to 30 seconds this made the proxy a pain to use
in failure scenarios.

fixes 2862
2015-06-13 09:42:18 +02:00
8e7fa9e201 Merge pull request #2976 from yichengq/fix-lock-test
pkg/fileutil: wait longer for relock
2015-06-12 15:20:18 -07:00
7723b91c06 pkg/fileutil: wait longer for relock
multiple cpu running makes it slower, so it waits longer for relock.
2015-06-12 15:17:28 -07:00
219d304291 Merge pull request #2968 from yichengq/fix-stream-reader-init
rafthttp: always init streamReader before return from newPeer
2015-06-12 14:51:05 -07:00
288cce0d76 Merge pull request #2975 from yichengq/fix-purge-test
pkg/fileutil: wait longer before checking purge results
2015-06-12 14:38:55 -07:00
7ff1fa36f2 rafthttp: always init streamReader before return from newPeer
Or etcd will panic if someone calls `setTerm()`, which uses streamReader
internally, before streamReader is inited.
2015-06-12 14:38:14 -07:00
75f91bab5c pkg/fileutil: wait longer before checking purge results
multiple cpu running may be slower than single cpu running, so it may
take longer time to remove files.
Increase from 5ms to 20ms to give it enough time.
2015-06-12 14:36:15 -07:00
684c721307 Merge pull request #2970 from yichengq/fix-stream-test
rafthttp: use buffered channel as recv/prop chan
2015-06-12 14:34:52 -07:00
dccec11bb4 Merge pull request #2973 from yichengq/fix-recv-log
rafthttp: fix the misformat logging line, and rename internal var for more clarity
2015-06-12 14:27:17 -07:00
36f75cf062 rafthttp: use buffered channel as recv/prop chan
So it ensures that the message will not be discarded because the receive
side has not been ready, which happens easily in multiple core test.

Use log.fatal instead of log.error. The test exits when there is
something wrong because the error may affect following test cases.
2015-06-12 14:25:11 -07:00
2f05b24d6d rafthttp: {from, to} -> {local, remote} in stream
{from, to} nameings are confused when it both dials and receives
messages from the remote. Change it to {local, remote} for better
clarity.
2015-06-12 14:17:30 -07:00
bcc1aadea9 rafthttp: fix the misformat logging line
before:
```
2015/06/12 20:06:19 rafthttp: dropped MsgApp from %!s(uint64=2) since
receiving buffer is full
```

after:
```
2015/06/12 13:51:38 rafthttp: dropped MsgProp from 2 since receiving
buffer is full
```
2015-06-12 14:12:49 -07:00
ae42371ee2 Merge pull request #2965 from yichengq/fix-issue2904
integration: fix TestIssue2904 in multiple cores
2015-06-12 13:53:00 -07:00
b98aa3a9e0 Merge pull request #2972 from yichengq/test-longer
test: extend integration timeout to 10m
2015-06-12 13:42:54 -07:00
768cb437bc test: extend integration timeout to 10m
We test with `-cpu 1,2,4` now, and it takes longer time.
2015-06-12 13:41:35 -07:00
796d99c390 integration: fix TestIssue2904 when multiple cores
Do not wait for the cluster view of removed member to match with
expected view, since removed member does not apply entries after it is
removed.
2015-06-12 10:20:27 -07:00
ea3c7d1d31 Merge pull request #2960 from yichengq/fix-drop-flood
rafthttp: pretty print message drop info
2015-06-12 09:23:23 -07:00
0de0e4b77c rafthttp: pretty print message drop info 2015-06-12 09:14:53 -07:00
e46fa0a213 Merge pull request #2957 from yichengq/fix-pipeline-test
rafthttp: fix TestStopBlockedPipeline
2015-06-12 08:03:12 -07:00
c21cc5b39b rafthttp: fix TestStopBlockedPipeline
Refactor the fake cancel implementation.

The old one may cancel other in-flight message in random, which leaves
the original target message blocked forever.
2015-06-12 07:55:12 -07:00
29dca49cb5 rafthttp: wait 1ms before enabling cancel
CancelRequest only effects on in-flight request, so we need to wait
for Do(request) called before enabling cancel.
2015-06-12 07:55:06 -07:00
d8e1950d4e Merge pull request #2963 from xiang90/fix_discovery_error
etcdmain: exit if discovery fails
2015-06-11 16:11:59 -07:00
6c8b32d316 etcdmain: exit if discovery fails
Fix #2919

If discovery fails, etcd will hang there and does nothing. This
commit fixes the problem.
2015-06-11 15:45:00 -07:00
3e706c745c Merge pull request #2953 from yichengq/etcdmain-plog
etcdmain: var log -> plog
2015-06-11 15:30:18 -07:00
1c19eb47b5 Merge pull request #2956 from xiang90/log
all pkgs use leveled log
2015-06-11 15:29:44 -07:00
2c5ab7ff8b discovery: fix infoln -> info 2015-06-11 14:22:14 -07:00
8ad7ed321e *:godep log pkg 2015-06-11 14:22:14 -07:00
2373fd8426 wal: fix the left logging using default log 2015-06-11 14:22:14 -07:00
2db8b53c4b discovery: use leveled log 2015-06-11 14:22:14 -07:00
f013a627a4 etcdserver/stats: use leveled log 2015-06-11 14:22:14 -07:00
cf7cb2b8a9 etcdserver/security: use leveled log 2015-06-11 14:22:14 -07:00
2f795e42d0 httptypes: use leveled log 2015-06-11 14:19:53 -07:00
4b5dbeff9b pkg/pbutil: use leveled log 2015-06-11 14:19:53 -07:00
865a5ffc61 pkg/osutil: use leveled log 2015-06-11 14:19:53 -07:00
a45f53986f pkg/netutil: use leveled log 2015-06-11 14:19:52 -07:00
69819d334a pkg/flags: use leveled log 2015-06-11 14:19:52 -07:00
7bf0479e66 Merge pull request #2882 from barakmich/security_client_new
*: Add security/authorization to etcd/client and etcdctl
2015-06-11 13:40:32 -04:00
1764837783 etcdmain: clean up plog.Printf
Put it into different log levels.
2015-06-11 10:24:02 -07:00
ecdf0a8146 Merge pull request #2959 from yichengq/fix-update-member
rafthttp: fix TestUpdateMember
2015-06-11 10:02:13 -07:00
1af2b4cad7 rafthttp: fix TestUpdateMember
Before this PR, it may error like this:

```
--- FAIL: TestUpdateMember-2 (0.00s)
		server_test.go:950: action =
		[{ApplyConfChange:ConfChangeUpdateNode []}
{ProposeConfChange:ConfChangeUpdateNode []}], want
[{ProposeConfChange:ConfChangeUpdateNode []}
{ApplyConfChange:ConfChangeUpdateNode []}]
```

This fixes the test by recording the proposal event in time.
2015-06-11 09:45:34 -07:00
cd629c9b44 Merge pull request #2939 from yichengq/fix-update-attr
etcdserver: allow to update attributes of removed member
2015-06-10 16:53:39 -07:00
8725e69cf7 etcdserver: allow to update attributes of removed member
There exist the possiblity to update attributes of removed member in
reasonable workflow:
1. start member A
2. leader receives the proposal to remove member A
2. member A sends the proposal of update its attribute to the leader
3. leader commits the two proposals
So etcdserver should allow to update attributes of removed member.
2015-06-10 16:52:18 -07:00
743ac73b11 Merge pull request #2954 from xiang90/fix_test
proxy: fix test
2015-06-10 16:44:58 -07:00
ed1c5a73d1 Merge pull request #2951 from yichengq/fix-proxy-acurls
etcdmain: fix that advertise-client-urls is required in proxy mode
2015-06-10 16:42:06 -07:00
612ecbc89d proxy: fix test 2015-06-10 16:31:42 -07:00
cf7c83b304 etcdmain: fix that advertise-client-urls is required in proxy mode
etcd proxy doesn't need to set advertise-client-urls because the flag is
not used.
2015-06-10 16:22:32 -07:00
5a9c2851a7 etcdmain: var log -> plog
So the variable name doesn't mess up with standard package name.
2015-06-10 16:19:06 -07:00
0a3a2720a1 Merge pull request #2923 from yichengq/rafthttp-status
rafthttp: pretty print connection error
2015-06-10 16:17:07 -07:00
f64a8214f7 Merge pull request #2952 from xiang90/fileutil
fileutil: use leveled logging
2015-06-10 16:01:24 -07:00
dc87454487 fileutil: return on error and send it to error chan 2015-06-10 15:59:24 -07:00
e2c2f098bc fileutil: use leveled logging 2015-06-10 15:57:59 -07:00
d92c89516b rafthttp: fix capnslog package name 2015-06-10 15:43:54 -07:00
1dbe72bb74 rafthttp: pretty print connection error
1. print out the status change of connection with peer
2. only print the first error for repeated ones
2015-06-10 15:43:49 -07:00
30db41e031 Procfile: use -listen-client-urls instead of -bind-addr
-bind-addr is etcd 0.4 flag, and we should deprecate it.

Moreover, this makes Procfile fit the workflow we mention in the doc,
which helps ourselves find the problem first.
2015-06-10 15:13:33 -07:00
37f9534109 Merge pull request #2950 from xiang90/test_cpu
test: run with cpu = 1,2,4
2015-06-10 15:09:45 -07:00
4e79abcfeb Merge pull request #2944 from yichengq/fix-2procs
pkg/testutil: ForceGosched -> WaitSchedule
2015-06-10 14:44:32 -07:00
018fb8e6d9 pkg/testutil: ForceGosched -> WaitSchedule
ForceGosched() performs bad when GOMAXPROCS>1. When GOMAXPROCS=1, it
could promise that other goroutines run long enough
because it always yield the processor to other goroutines. But it cannot
yield processor to goroutine running on other processors. So when
GOMAXPROCS>1, the yield may finish when goroutine on the other
processor just runs for little time.

Here is a test to confirm the case:

```
package main

import (
	"fmt"
	"runtime"
	"testing"
)

func ForceGosched() {
	// possibility enough to sched up to 10 go routines.
	for i := 0; i < 10000; i++ {
		runtime.Gosched()
	}
}

var d int

func loop(c chan struct{}) {
	for {
		select {
		case <-c:
			for i := 0; i < 1000; i++ {
				fmt.Sprintf("come to time %d", i)
			}
			d++
		}
	}
}

func TestLoop(t *testing.T) {
	c := make(chan struct{}, 1)
	go loop(c)
	c <- struct{}{}
	ForceGosched()
	if d != 1 {
		t.Fatal("d is not incremented")
	}
}
```

`go test -v -race` runs well, but `GOMAXPROCS=2 go test -v -race` fails.

Change the functionality to waiting for schedule to happen.
2015-06-10 14:37:41 -07:00
2d21904cfd test: run with cpu = 1,2,4 2015-06-10 14:26:17 -07:00
a4d1a5a6e5 *: Add security/auth support to etcdctl and etcd/client
add godep for speakeasy and auth entry parsing
add security_user to client
add role to client
add role commands
add auth support to etcdclient and etcdctl(member/user)
add enable/disable to etcdctl
better error messages, read/write/readwrite
Bump go-etcd to include codec changes, add new dependency
verify the error for revoke/add if nothing changed, remove security-merging prefix
2015-06-10 16:58:10 -04:00
97709b202d Merge pull request #2930 from xiang90/storage_restore
storage: initial snapshot and restore
2015-06-10 11:38:57 -07:00
ba9a46aa02 storage: initial snapshot and restore
Snapshot takes an io.Writer and writes the entire backend data to
the given writer. Snapshot writes a consistent view and does not
block other storage operations.

Restore restores the in-memory states (index and book keeping) of
the storage from the backend data.
2015-06-10 11:32:10 -07:00
1403783326 Merge pull request #2911 from yichengq/rafthttp-plog
rafthttp: use leveled logger
2015-06-09 16:16:33 -07:00
f1e995b070 rafthttp: use leveled logger 2015-06-09 16:15:02 -07:00
19ef3a0982 Merge pull request #2934 from xiang90/etcdserver_log
etcdserver: use leveled logging
2015-06-09 15:53:52 -07:00
e0f9796653 etcdserver: use leveled logging
Leveled logging for etcdserver pkg.
2015-06-09 13:53:07 -07:00
9fbd2599ad Merge pull request #2940 from yichengq/improve-raft-loop
etcdserver: stop raft loop when receiving stop signal
2015-06-09 11:24:53 -07:00
0814966ca2 etcdserver: stop raft loop when receiving stop signal
When it waits for apply to be done, it should stop the loop if it
receives stop signal.

This helps to print out panic information. Before this PR, if the panic
happens when server loop is applying entries, server loop will wait for
raft loop to stop forever.
2015-06-09 11:11:53 -07:00
ebb767765e Merge pull request #2941 from bakins/http-log
Simple debug HTTP request logging
2015-06-09 10:52:13 -07:00
d8a836e618 Simple debug HTTP request logging 2015-06-09 13:40:37 -04:00
1ff86556b7 Merge pull request #2937 from xiang90/http_log
etcdhttp: use leveled logging
2015-06-09 09:35:17 -07:00
0adeee2965 etcdhttp: use leveled logging 2015-06-09 09:26:57 -07:00
3390f38bba Merge pull request #2925 from yichengq/doc-gomaxprocs
docs: document cpu cores deployment
2015-06-08 13:49:28 -07:00
471cf82905 docs: document maximal OS threads 2015-06-08 12:00:33 -07:00
e0d5116683 Merge pull request #2926 from xiang90/raft_log
raft: make the repeated log message under bad path debug level
2015-06-08 10:57:12 -07:00
1279e495f0 raft: make the repeated log message under bad path debug level 2015-06-05 17:29:24 -07:00
05b55d9d75 Merge pull request #2921 from xiang90/fix_watch_cancel
client: fix cancel watch
2015-06-05 15:46:16 -07:00
15ac4f08f8 client: fix cancel watch
ioutil.ReadAll is a blocking call, we need to wait cancelation
during the call.
2015-06-05 15:40:43 -07:00
976ac65c86 Merge pull request #2894 from xiang90/refactor_keyIndex
Storage initial compaction
2015-06-05 12:38:11 -07:00
511f323424 Merge pull request #2916 from luan/build-script-git-fallback
Unexpected dependency in build script
2015-06-05 10:17:15 -07:00
17d5381059 build: default git sha to GitNotFound in case git fails 2015-06-05 10:09:50 -07:00
f47ed4a364 storage: initial compact 2015-06-05 09:22:44 -07:00
60ca9ebab1 Merge pull request #2915 from jonboulle/master
docs: readme/branch-management cleanup
2015-06-04 16:54:15 -07:00
048a948eca docs: readme/branch-management cleanup 2015-06-04 16:41:32 -07:00
75ddf05ca1 Merge pull request #2910 from xiang90/etcdctl
etcdctl: cleanup
2015-06-03 10:53:13 -07:00
f9c67daee5 Merge pull request #2912 from xiang90/client-curl
client: support printing cURL command
2015-06-03 10:15:00 -07:00
4f2df84a38 client: support printing cURL command 2015-06-03 10:02:37 -07:00
9e8d589163 Merge pull request #2906 from yichengq/fix-pipeline-stop
rafthttp: fix pipeline.stop may block
2015-06-03 08:47:17 -07:00
f0edf06b6d etcdctl: minor cleanup 2015-06-02 19:50:37 -07:00
079e7c10a0 etcdctl: move format to format.go 2015-06-02 19:29:05 -07:00
26682b663d etcdctl: cleanup etcdctl exit code 2015-06-02 19:01:41 -07:00
7f8925e172 rafthttp: fix pipeline.stop may block
This PR makes pipeline.stop stop quickly. It cancels inflight requests,
and stops sending messages in the buffer.
2015-06-02 17:15:44 -07:00
627929d2f4 Merge pull request #2909 from xiang90/logger
*: rename logger to plog
2015-06-02 15:03:28 -07:00
711451ce2d *: rename logger to plog 2015-06-02 14:58:24 -07:00
28878e34ff Merge pull request #2903 from xiang90/chord_rafthttp
rafhttp: clean up logging messages
2015-06-02 14:44:40 -07:00
b74082c06c Merge pull request #2889 from yichengq/version-runtime-enforce
rafthttp: version enforcement on rafthttp messages
2015-06-02 14:37:38 -07:00
c371d8c65c rafthttp: version enforcement on rafthttp messages
This PR sets etcd version and min cluster version in request header,
and let server check version compatibility. rafthttp server
will reject any message from peer with incompatible version(too low
version or too high version), and print out warning logs.
2015-06-02 13:33:18 -07:00
2bf64b4adf Merge pull request #2898 from xiang90/raft_log
raft use leveled logger
2015-06-02 13:04:02 -07:00
1561b85bf3 raft: drop the raft prefix in logging 2015-06-02 12:50:42 -07:00
3af4a45d7b etcdserver: make raft use leveled logger 2015-06-02 12:50:42 -07:00
89f6f988cb Godeps: update logger pkg 2015-06-02 12:50:42 -07:00
46b5eb051e Merge pull request #2896 from xiang90/wal_log
wal: use leveled logger
2015-06-02 11:39:25 -07:00
59dd1eeaf0 Merge pull request #2897 from xiang90/snapshot_logger
snap: use leveled logger
2015-06-02 11:39:17 -07:00
a8af787971 Merge pull request #2902 from BlueDragonX/bug-proxyreq-closed
Reuse a bytes buffer as proxy request body.
2015-06-02 10:37:48 -07:00
4e85f932e0 proxy: Reuse a bytes buffer as proxy request body.
The call to transport.RoundTrip closes the request body regardless of
the value of request.Closed. This causes subsequent calls to RoundTrip
using the same request body to fail.

Fixes #2895
2015-06-02 10:27:20 -07:00
2b5f417113 Merge pull request #2901 from xiang90/fix_urlpick
rafthttp: move mu to the top in urlPicker struct
2015-06-01 23:53:57 -07:00
1cd5c7efee Merge pull request #2900 from yichengq/proxy-maxidle
etcdmain: increase maxIdleConnsPerHost in proxy transport
2015-06-01 23:31:35 -07:00
a7a4233f0b rafhttp: clean up logging messages 2015-06-01 17:18:37 -07:00
b660ee408f rafthttp: move mu to the top in urlPicker struct
mutex protects all the fields.
2015-06-01 16:40:18 -07:00
0589afe605 etcdmain: increase maxIdleConnsPerHost in proxy transport
This PR set maxIdleConnsPerHost to 128 to let proxy handle 128 concurrent
requests in long term smoothly.
If the number of concurrent requests is bigger than this value,
proxy needs to create one new connection when handling each request in
the delta, which is bad because the creation consumes resource and may
eat up your ephemeral port.
2015-06-01 16:19:36 -07:00
ae5f7c943b snap: use leveled logger 2015-06-01 14:07:30 -07:00
185d2bced4 wal: use leveled logger 2015-06-01 13:38:50 -07:00
8825af47a0 Merge pull request #2893 from eparis/unfuck-godeps
godeps: fix and update dependencies
2015-06-01 10:16:58 -07:00
af5286c63b Fix godeps to be usable
Godeps should allow me to do
  godep restore
  godep save -r ./...

But that doesn't work. Try it.

This requires update to the following packages:
github.com/prometheus/client_golang/
github.com/prometheus/procfs
github.com/matttproud/golang_protobuf_extensions/

There were 2 major problems.

1. godeps have code.google.com/p/goprotobuf but that repo doesn't exist
2. prometheus/client_golang/_vendor moved to other packages and godep
(with -r) can't handle it.

At the end of this we should be able to use godeps again without tons of
black magic.  uggh.  what a pain in the ass.

The black magic to actually get godeps back in shape was:

```bash
 # remove code.google.com/p/goprotobuf (doesn't exist)
 # remove all _vendor lines from prometheus (we still have other
 # prometheus lines so restore still works)
vi Godeps/Godeps.json

 # remove all the crazy vendoring crud because godep doesn't handle it
 # correctly
find . -name \*.go | xargs sed -i
's|github.com/coreos/etcd/Godeps/_workspace/src/||'

 # ok now, restore as best we can (everything except it wines about
 # goprotobuf
godep restore

 # now update the packages which were using the old (dead) goprotobuf
go get -u github.com/prometheus/client_golang/
go get -u github.com/matttproud/golang_protobuf_extensions/
 # update prometheus procfs because prometheus/client_golang/ has a
 # dependancy on this update
go get -u github.com/prometheus/procfs

 # get rid of Godeps directory entirely
git rm -rf Godeps

 # ok, now, rewrite the Godeps directory and redo the path rewrites
godep  save -r ./...

 # now put Godeps back into git
git add Godeps/

 # commit the new code
git commit -aA

 # And now, you can use godeps!
godep restore
godep save -r ./...
git diff
 # nothing!!
```
2015-05-31 23:52:16 -04:00
d417b36e5d storage: refactor key_index 2015-05-31 15:24:04 -07:00
7735501407 Merge pull request #2874 from xiang90/storeAPI
kv api of stroage
2015-05-31 15:17:20 -07:00
815fe327dd Merge pull request #2890 from xiang90/fix_raft_comment
raft: remove wrong invariant
2015-05-30 13:28:13 -07:00
77c3613d94 build: use posix shell 2015-05-30 09:34:54 +03:00
0ca6be31f8 raft: remove wrong invariant
The commit > unstable might not true for follower. The leader only need
to ensure the entry is stored on the majority of nodes to commit an
entry. So the minority of the cluster might receive commit > unstable
append request. This is normal.
2015-05-29 18:48:59 -07:00
871107c65a Merge pull request #2883 from alexaltair/master
etcdmain: use double-dash in message flag
2015-05-28 14:33:14 -07:00
4e97305df0 Merge pull request #2878 from xiang90/fix_raft_node
raft: fix raft node start bug
2015-05-28 14:31:25 -07:00
6f8c36c2ab etcdmain: use double-dash in message flag 2015-05-28 13:09:44 -07:00
ce5e14e713 Merge pull request #2881 from barakmich/go-etcd-update
Godep: update go-etcd version
2015-05-28 14:10:50 -04:00
f6f7ef6b3a Godep: update go-etcd version 2015-05-28 14:02:14 -04:00
6c207b9277 stroage: kill todo 2015-05-27 14:46:59 -07:00
de1c9c08e1 Merge pull request #2842 from SpencerBrown/SpencerBrown-patch-2
docs: add client flags to examples in clustering.md
2015-05-27 14:28:38 -07:00
69d02410cf stroage: adopt KV interface 2015-05-27 14:24:23 -07:00
6f0558b999 Merge pull request #2871 from xiang90/cluster_id
rafthttp: print out log when clusterID mismatch instead of exiting
2015-05-27 13:34:27 -07:00
085447ed85 raft: fix raft node start bug
raft node should set initial prev hard state to empty.
Or it will not send the first hard coded state to application
until the state changes again.

This commit fixs the issue. It introduce a small overhead, that
the same tate might send to application twice when restarting.
But this is fine.
2015-05-27 13:32:04 -07:00
cbb8b9bb08 stroage: add tnx id 2015-05-27 10:35:51 -07:00
7ad2b22498 Merge pull request #2876 from xiang90/little_fix
etcdmian: remove main prefix in logging
2015-05-27 10:11:34 -07:00
1d6e9fd387 Merge pull request #2875 from yichengq/verbose-integration
test: run integration tests in verbose mode
2015-05-27 10:09:56 -07:00
7875de7d2f etcdmian: remove main prefix in logging
We are using new log pkg, which adds the prefix for us.
2015-05-27 10:01:22 -07:00
9c1aec6877 storage: add rangeKeys func 2015-05-27 09:58:21 -07:00
fde7a7a10c test: run integration tests in verbose mode
Travis doesn't print out the final result of integration tests
sometimes, and verbose mode helps us debug.
2015-05-27 09:57:44 -07:00
4e0b28f1ca Merge pull request #2872 from bprashanth/log_gomax
etcdmain: explicitly set gomaxprocs and log its value
2015-05-27 09:57:12 -07:00
1e15b05e4c etcdmain: explicitly set gomaxprocs and log its value 2015-05-27 09:53:05 -07:00
fb12a4e412 storage: fix a deadlock in batch tx 2015-05-27 09:31:11 -07:00
93ecf36855 storage: support tnx 2015-05-27 09:31:11 -07:00
9db360387d storage: support Range 2015-05-27 09:31:11 -07:00
7bb388ed52 storage: initial kv api 2015-05-27 09:31:11 -07:00
9be6a7c8fd Merge pull request #2831 from xiang90/index
storage: initial index and key index
2015-05-27 09:29:42 -07:00
49da7b6556 storage: add boltdb as dependency 2015-05-27 09:24:49 -07:00
0d3d4c5b01 rafthttp: print out log when clusterID mismatch instead of exiting
We have heard from several users that they do not expect a clusterID
mismatch to kill the cluster.
2015-05-26 16:05:58 -07:00
5d741e4945 Merge pull request #2797 from yichengq/stream-2.0
rafthttp: try stream msgappV1 handler if msgappV2 is unsupported
2015-05-26 15:09:51 -07:00
19fc1a7137 rafthttp: update streamReader term in time
Because etcd 2.1 will build stream to any existing peers and etcd 2.0
requires the remote to provide most updated term, it is
necessary for streamReader to know the latest term.
2015-05-26 14:52:42 -07:00
fad2c09fa8 rafthttp: not log expected timeout as error
The network timeout from stream with etcd 2.0 is expected because etcd
2.0 doesn't heartbeat on idle connections.
2015-05-26 14:52:41 -07:00
38b8e848ac rafthttp: try stream msgappV1 handler if msgappV2 is unsupported
This helps etcd 2.1 connect to msgappV1 handler when the remote member
doesn't support msgappV2. And it doesn't print out unsupported handler
error to make log clean.
2015-05-26 14:52:41 -07:00
42fe370b35 Merge pull request #2848 from xiang90/metrics
*: use namespace and subsystem in metrics
2015-05-26 14:44:54 -07:00
60c8719d08 Merge pull request #2782 from yichengq/not-close-stream
rafthttp: only close streamMsgApp when updating term
2015-05-26 14:41:22 -07:00
34ac145b38 *: use namespace and subsystem in metrics
Fix #2841.

From Prometheus developer:
```
the recommended way for etcd as an open source project and under
consideration of its size would be etcd_<subsystem>_<name>.
```

We made the naming change accordingly.
2015-05-26 14:39:04 -07:00
3028edd7dc Merge pull request #2856 from xiang90/mrefactor
etcdserver: refactore member.go
2015-05-26 14:37:37 -07:00
4d8be39fd1 Merge pull request #2870 from yichengq/enable-travis-govet
travis: stop install tools cover and vet
2015-05-26 11:59:42 -07:00
c951c22fff Merge pull request #2861 from barakmich/2859
etcdserver: fix go vet. Fixes #2859
2015-05-26 11:06:55 -07:00
90ad78aa46 travis: stop install tools cover and vet
There is no need to install them separately because they have been
downloaded in the default go root directory.
2015-05-26 11:03:53 -07:00
1be69b1391 Merge pull request #2864 from schmichael/mention-metafora
docs: mention metafora distributed task library
2015-05-22 13:24:20 -07:00
e93242967c docs: mention metafora distributed task library
Metafora uses etcd as a task broker, command channel, and state store.
2015-05-22 13:17:05 -07:00
0e49a0a3ef docs: add client flags to examples in clustering.md
to make it a complete functional example
2015-05-22 14:18:14 -05:00
9ef098c5ed etcdserver: fix go vet. Fixes #2859 2015-05-22 13:54:54 -04:00
58eefda72d Merge pull request #2840 from yichengq/revert-url-equal
Revert "Treat URLs have same IP address as same"
2015-05-21 19:27:19 -07:00
4a72d3a8bb etcdserver: refactore member.go 2015-05-21 09:19:29 -07:00
e332e86b5d storage: address barak's comments 2015-05-20 17:47:35 -07:00
0ad6d7e3ba Merge pull request #2853 from bdarnell/status
raft: MultiNode.Status returns nil for non-existent groups.
2015-05-20 13:07:23 -07:00
d58fac453d raft: MultiNode.Status returns nil for non-existent groups.
Previously it would panic if the group did not exist.
2015-05-20 15:45:38 -04:00
781eccb337 Merge pull request #2852 from bdarnell/hex-node-id
raft: Format node IDs as hex in DescribeMessage.
2015-05-20 12:34:35 -07:00
ef721db247 raft: Format node IDs as hex in DescribeMessage.
This is how they are printed in all other log messages.
2015-05-20 15:32:56 -04:00
260aad5468 Merge pull request #2830 from xiang90/join_checking
checking cluster version compatibility before joining the existing cluster
2015-05-20 12:25:50 -07:00
aa417ab644 etcdserver: log the per endpoint error in getVersion 2015-05-20 12:10:10 -07:00
db7db689a6 etcdserver: check cluster version compability when joining 2015-05-19 10:19:41 -07:00
845cb61213 storage: add kv and event proto 2015-05-18 14:35:10 -07:00
00ed4fe778 Merge pull request #2764 from barakmich/2755
security: Lazily create the security directories. Fixes #2755.
2015-05-18 17:34:13 -04:00
a88a53274f security: Lazily create the security directories. Fixes #2755, may find new instances for #2741
revert the kv integration test

fix nits

amend security mention of GUEST
2015-05-18 17:28:04 -04:00
6ee5cd9105 Merge pull request #2675 from xiang90/v3rfc
doc: v3api rfc
2015-05-18 13:52:54 -07:00
7c879ee576 doc: v3api rfc 2015-05-18 13:48:16 -07:00
3153e635d5 Revert "Treat URLs have same IP address as same"
This reverts commit f8ce5996b0.

etcd no longer resolves TCP addresses passed in through flags,
so there is no need to compare hostname and IP slices anymore.
(for more details: a3892221ee)

Conflicts:
	etcdserver/cluster.go
	etcdserver/config.go
	pkg/netutil/netutil.go
	pkg/netutil/netutil_test.go
2015-05-16 03:21:10 -07:00
b3e6ad136a docs: add node-etcd-config to libs and tools doc 2015-05-16 02:02:44 -07:00
9575cc4258 storage: add delete example 2015-05-15 19:33:59 -07:00
2e43ac8463 rafthttp: add test for streamReader.updateMsgAppTerm 2015-05-15 11:21:54 -07:00
8637a4bf69 rafthttp: only close streamMsgApp when updating term
In all stream types, streamMsgApp needs to be closed when
updating term because its stream connection can only be used under
a certain term. But there is no need to close other streams, which
may waste time and reduce performance.
2015-05-15 11:21:54 -07:00
9699a501f3 Merge pull request #2833 from yichengq/rename-closer
rafthttp: resetCloser -> close
2015-05-15 11:18:58 -07:00
8e0992a28b rafthttp: resetCloser -> close
name 'close' is shorter and more straightforward.
2015-05-14 22:24:05 -07:00
fc4543a3fd Merge pull request #2628 from yichengq/improve-msgappv2
rafthttp: reduce allocs in msgappv2
2015-05-14 21:18:16 -07:00
4b0d9f69c7 storage: add a simple backend and kv example 2015-05-14 20:43:32 -07:00
d611904a41 Merge pull request #2828 from yichengq/cluster-health-log
etcdctl/cluster_health: improve output if failed to get leader stats
2015-05-14 19:01:48 -07:00
3d8fe3b3ca etcdctl/cluster_health: improve output if failed to get leader stats
When failing to get leader stats, it said 'cluster is unhealthy' before.
This is confusing when it cannot get stats because advertised client urls
are set wrong and the cluster is healthy.
2015-05-14 18:52:10 -07:00
9d831e3075 *: godep btree 2015-05-14 17:59:55 -07:00
660fd5e3e1 storage: add comment around compact 2015-05-14 17:55:54 -07:00
ee47973199 storage: initial index 2015-05-14 17:53:41 -07:00
32d44aa3b2 storage: initial key index 2015-05-14 17:35:12 -07:00
556713739c Merge pull request #2823 from alexwlchan/master
docs: small fixes to spelling and similar
2015-05-14 15:41:14 -07:00
9f8342dba4 etcdserver: do not get local version via HTTP 2015-05-13 17:19:32 -07:00
988c30bfba etcdserver: getVersion returns both server and cluster version 2015-05-13 17:04:46 -07:00
1a9dcd2f72 Merge pull request #2826 from yichengq/fix-wait-test
pkg/wait: fix TestWaitTestStress
2015-05-13 15:56:26 -07:00
132b12f8db Merge pull request #2827 from xiang90/cluster_v
etcdhttp: version endpoint also returns cluster version.
2015-05-13 15:54:54 -07:00
6296054ff6 etcdhttp: version endpoint also returns cluster version. 2015-05-13 15:48:10 -07:00
256a7cfe8c pkg/wait: fix TestWaitTestStress
The test may fail if two consequent time.Now() returns the same value.
Sleep 1ns to avoid this situation.
2015-05-13 13:41:34 -07:00
75ee7f4aa1 Merge pull request #2821 from yichengq/private-cluster
etcdserver: stop exposing Cluster struct
2015-05-13 10:26:48 -07:00
2690535f8a Merge pull request #2820 from xiang90/cap
version capability checking
2015-05-13 10:16:49 -07:00
d3b1d5c008 etcdhttp: support capability checking
etcdhttp will check the cluster version and update its
capability version periodically.

Any new handler's after 2.0 needs to wrap by capability handler
to ensure it is not accessable until rolling upgrade finished.
2015-05-13 10:11:35 -07:00
a6a649f1c3 etcdserver: stop exposing Cluster struct
After this PR, only cluster's interface Cluster is exposed, which makes
code much cleaner. And it avoids external packages to rely on cluster
struct in the future.
2015-05-13 10:01:25 -07:00
19ab1cb2a9 Merge pull request #2822 from xiang90/rm_log
etcdserver: remove unnecessary around detect datadir
2015-05-13 09:27:21 -07:00
0c63e16ae0 docs: small fixes to spelling and similar
This commit is a collection of fixes to spelling, capitalisation
and spacing. No substantial changes.
2015-05-13 11:45:00 +01:00
f2905f2828 etcdserver: remove unnecessary around detect datadir
The log is super unhelpful. When I have a 2.1.0 etcd, it prints out
`2.0.1 vaild dir`. I have no idea why the data dir of a 2.1.0 etcd is
2.0.1.
2015-05-12 22:06:42 -07:00
f4c51cb5a1 Merge pull request #2766 from yichengq/345
*: extract types.Cluster from etcdserver.Cluster
2015-05-12 15:52:24 -07:00
032db5e396 *: extract types.Cluster from etcdserver.Cluster
The PR extracts types.Cluster from etcdserver.Cluster. types.Cluster
is used for flag parsing and etcdserver config.

There is no need to expose etcdserver.Cluster public, which contains
lots of etcdserver internal details and methods. This is the first step
for it.
2015-05-12 14:53:11 -07:00
197437316f Merge pull request #2804 from xiang90/vv
etcdserver: support update cluster version through raft
2015-05-12 14:31:27 -07:00
e866314b94 etcdserver: support update cluster version through raft
1. Persist the cluster version change through raft. When the member is restarted, it can recover
the previous known decided cluster version.

2. When there is a new leader, it is forced to do a version checking immediately. This helps to
update the first cluster version fast.
2015-05-12 11:44:34 -07:00
f1502e970a Merge pull request #2813 from sckott/r-library
Documentation: add the R client etseed to libraries-and-tools.md
2015-05-12 10:43:59 -07:00
93b610ac8d Merge pull request #2809 from xiang90/fix_discovery_err
discovery: do not return raw error from etcd store
2015-05-12 09:59:56 -07:00
b764f07e34 Merge pull request #2811 from mischief/plan9-lock
pkg/fileutil: add plan9 lockfile support
2015-05-11 17:42:40 -07:00
91cbf47a2a etcdmain: better error msg when detected duplicate id in discovery 2015-05-11 17:34:44 -07:00
5203de5566 Documentation: add the R client etseed to libraries-and-tools.md
etseed is an R client for etcd.
2015-05-11 15:43:31 -07:00
2e8c932ab0 pkg/fileutil: add plan9 lockfile support 2015-05-11 13:24:01 -07:00
e9931fb8b1 discovery: do not return error from etcd
We used to return `key not found` directly to the
user due to a bug. We fixed the bug and added a test
case in this commit.
2015-05-11 10:49:57 -07:00
3d242695b3 Merge pull request #2775 from yichengq/proxy-doc
docs: proxy needs accessible advertise client urls
2015-05-10 10:18:40 -07:00
42783c1faa Merge pull request #2805 from MSamman/more_version_info
version: added more version information
2015-05-08 20:28:10 -07:00
3914defd8a version: added more version information
added more version information output to aid debugging
print etcd Version, Git SHA, Go runtime version, OS
and architecture

Fixes #2560
2015-05-09 03:21:10 +00:00
1abf2636b5 docs: proxy needs accessible advertise client urls
Users cannot use proxy if -advertise-client-urls is set correctly.
Especially mention this in the doc to help them bypass the wrong
settings.
2015-05-07 22:53:42 -07:00
b24dd8e4e6 Merge pull request #2792 from ecnahc515/client_create_dir
client: Support creating directory through KeysAPI
2015-05-07 11:13:49 -07:00
48e144ae2e client: Support creating directory through KeysAPI
Creating a directory is done using the Set() method and a SetOptions
struct with it's Dir field set to true.
2015-05-07 10:47:18 -07:00
eb930c3298 Merge pull request #2787 from bcwaldon/ttldur
client: add Node.TTLDuration()
2015-05-05 15:21:44 -07:00
ee9e336fd4 client: add Node.TTLDuration() 2015-05-05 15:03:24 -07:00
d101568ac9 Merge pull request #2788 from barakmich/roadmap
*: Initial roadmap
2015-05-05 16:43:06 -04:00
d4bd57229d *: Initial roadmap 2015-05-05 16:05:35 -04:00
0b082b7bd4 Merge pull request #2771 from sorah/close-ongoing-conn
Fix connection leak when client disconnected
2015-04-29 20:46:13 -07:00
a68efe7d1e proxy: Fix connection leak when client disconnect
established connections were leaked when client disconnected before
proxyreq completes. This happens all time for wait=true requests.
2015-04-30 11:41:42 +09:00
0a6f481ca5 Merge pull request #2773 from yichengq/add-flag-help
tools/functional-testing: add help message for flags
2015-04-29 14:18:32 -07:00
e71d43b58e tools/functional-testing: add help message for flags
Help users to understand what these flags are for.
2015-04-29 13:59:55 -07:00
0fbf90b1e0 Merge pull request #2774 from xiang90/cluster
etcdserver: rename StoreAdminPrefix to StoreClusterPrefix
2015-04-29 12:20:04 -07:00
94ffd72c7e etcdserver: rename StoreAdminPrefix to StoreClusterPrefix
We store cluster related key in StoreAdminPrefix for some
historical reason. The previous API is called admin. But now,
the admin name is gone and `cluster` is a more clear and correct
name.
2015-04-29 12:05:51 -07:00
a4e35f4650 Merge pull request #2718 from xiang90/version
support cluster-wide version sync
2015-04-29 11:45:21 -07:00
6699107f61 *: add cluster version and cluster version detection.
Cluster version is the min major.minor of all members in
the etcd cluster. Cluster version is set to the min version
that a etcd member is compatible with when first bootstrapp.

During a rolling upgrades, the cluster version will be updated
automatically.

For example:

```
Cluster [a:1, b:1 ,c:1] -> clusterVersion 1

update a -> 2, b -> 2

after a detection

Cluster [a:2, b:2 ,c:1] -> clusterVersion 1, since c is still 1

update c -> 2

after a detection

Cluster [a:2, b:2 ,c:2] -> clusterVersion 2
```

The API/raft component can utilize clusterVersion to determine if
it can accept a client request or a raft RPC.

We choose polling rather than pushing since we want to use the same
logic for cluster version detection and (TODO) cluster version checking.

Before a member actually joins a etcd cluster, it should check the version
of the cluster. Push does not work since the other members cannot push
version info to it before it actually joins. Moreover, we do not want our
raft RPC system (which is doing the heartbeat pushing) to coordinate cluster version.
2015-04-29 11:31:59 -07:00
33febb979c Merge pull request #2761 from yichengq/344
etcdmain: advertise-client-urls must be set if listen-client-urls is set
2015-04-29 10:27:10 -07:00
3f90394fbb etcdmain: advertise-client-urls must be set if listen-client-urls is set
Before this PR, people can set listen-client-urls without setting
advertise-client-urls, and leaves advertise-client-urls as default
localhost value. The client libraries which sync the cluster info
fetch wrong advertise-client-urls and cannot connect to the cluster.
This PR avoids this case and provides better UX.

On the other hand, this change is safe because people always want to set
advertise-client-urls if listen-client-urls is set. The default localhost
advertise url cannot be accessed from the outside, and should always be
set except that etcd is bootstrapped with no flag.
2015-04-29 09:52:15 -07:00
beb606f066 Merge pull request #2704 from philips/build-aci-port-mountpoint
scripts: build-aci update to have mountPoint and ports
2015-04-29 07:30:44 -07:00
6c77e7a737 Merge pull request #2768 from coreos/docs-formatting
docs: fix code block formatting
2015-04-28 14:02:30 -07:00
2a50f7a1aa Merge pull request #2770 from barakmich/new_logger
etcdmain: fix logging flag documentation
2015-04-28 16:53:58 -04:00
ad8e3ea5dc etcdmain: fix logging flag documentation 2015-04-28 16:31:19 -04:00
2299e35d99 Merge pull request #2769 from barakmich/new_logger
etcdmain: New logger
2015-04-28 16:06:51 -04:00
b369cf037a etcdmain: New Logging Package
use capnslog

Vendor capnslog and set the flags in etcd main

remove package prefix from etcdmain
2015-04-28 15:42:32 -04:00
bfd4a29f67 docs: fix code block formatting 2015-04-28 11:17:13 -07:00
0d6e062b5b Merge pull request #2738 from sublimino/patch-1
docs: fix link to etcd-migrate in README.md
2015-04-27 22:12:57 -07:00
eafdd3b718 Merge pull request #2730 from yichengq/tester-key-param
main: parameterize stress key size and key suffix range
2015-04-27 17:02:36 -07:00
057d21cf79 main: parameterize stress key size and key suffix range
It faciliates tester to adjust the size of each request, the number of
keys in the store and the size of snapshot.
2015-04-27 16:46:56 -07:00
33f3bb3074 Merge pull request #2754 from xiang90/member_change
integration: add a test case for a full cluster rotation
2015-04-27 15:44:15 -07:00
077c8397d2 integration: add a test case for a full cluster rotation 2015-04-27 15:38:06 -07:00
d080c33c07 Merge pull request #2762 from yichengq/343
rafthttp: stop etcd if it is found removed when stream dial
2015-04-27 15:10:39 -07:00
1c1cccd236 rafthttp: stop etcd if it is found removed when stream dial
The original process is stopping etcd only when pipeline message finds itself
has been removed. After this PR, stream dial has this functionality too.
It helps fast etcd stop, which doesn't need to wait for stream break to
fall back to pipeline, and wait for election timeout to send out message
to detect self removal.
2015-04-27 15:10:00 -07:00
be6f49ba32 Merge pull request #2758 from lavagetto/master
docs: clarify the disaster recovery guide
2015-04-25 10:54:17 -07:00
968f3d9711 docs: clarify the disaster recovery guide
A bit was missing from the documentation on disaster recovery, the reset
of the advertised peer urls for the node recovered from backup. Without
that, any subsequent server joining the cluster would not be able to
speak to the first node.
2015-04-25 18:54:29 +02:00
f31a57d02e Merge pull request #2757 from yichengq/fix-typo
client: fix test name typo
2015-04-24 18:06:59 -07:00
39dae50e71 client: fix test name typo
This is introduced at d89a862
2015-04-24 18:05:18 -07:00
f244ae4aa5 Merge pull request #2756 from xiang90/client_gone
client: 410 is a vaild response for member.Remove
2015-04-24 17:17:12 -07:00
91c45c3243 client: 410 is a vaild response for member.Remove
When removing a member, etcdserver might return 410 that indicates
the member has been removed. To client, 410 is a vaild response since
the client might do internal retry.
2015-04-24 17:01:23 -07:00
b6aa31a5b6 Merge pull request #2750 from xiang90/member_test
integration: add tests around the membership change issues
2015-04-24 13:22:19 -07:00
a42b9708ae integration: add tests around the membership change issues 2015-04-24 13:07:43 -07:00
ebecee34e0 Merge pull request #2701 from yichengq/rafthttp-anon
rafthttp: add remotes
2015-04-24 13:04:37 -07:00
49f4c17767 Merge pull request #2751 from akolb1/solaris_fix3
pkg/fileutil: add filelock support for solaris
2015-04-24 12:50:13 -07:00
39c7060d3b pkg/fileutil: add filelock support for solaris 2015-04-24 12:18:08 -07:00
9f19b5660f rafthttp: add AddRemote
Add remotes to rafthttp, who help newly joined members catch up the
progress of the cluster. It supports basic message sending to remote, and
has no stream connection for simplicity. remotes will not be used
after the latest peers have been added into rafthttp.
2015-04-24 11:49:23 -07:00
41c7b43dc5 Merge pull request #2749 from junxu/master
raft: fix typo in raftlog
2015-04-24 07:47:01 -07:00
6b7891c643 raft: fix typo in raftlog
fix typo in String() method of raftlog which will misorder
the "committed" and "unstable.offset" output.
2015-04-24 03:28:57 -04:00
b5d4d9ae9b Merge pull request #2713 from xiaost/etcdserver-skip-empty-entry
etcdserver: apply: skip empty Entry
2015-04-23 21:24:25 -07:00
cab1e9a723 etcdserver: skip noop entry in apply 2015-04-24 12:15:51 +08:00
0d25b20fc0 *: bump to v2.1.0-alpha.0+git 2015-04-23 15:02:51 -07:00
c1608bcdb4 *: bump to v2.1.0-alpha.0 2015-04-23 15:02:18 -07:00
01d9c9ce17 Merge pull request #2739 from xiang90/fix_wal
wal: change io.EOF returned by readFull to io.ErrUnexpectedEOF
2015-04-23 14:21:19 -07:00
0efcfcb87b Merge pull request #2654 from barakmich/update_security
security: Update security
2015-04-23 16:16:31 -04:00
fa74e702d8 security: Improve the security api as per the suggestions list in #2384
Subcommits:

decouple root and security enable/disable

create root role

prefix matching

godep: bump go-etcd to include credentials

add godep for speakeasy and auth entry parsing

appropriate errors for security enable/disable

WIP adding to etcd/client all the security client methods

add guest access

minor ui return tweaks

revert client changes

respond to comments, log more security operations

fix major ensure() bug, add better UX

block recursive access

fix some boneheaded mistakes

fix integration test

last comments

fix up security_api.md

philips nits

fix docs
2015-04-23 16:11:38 -04:00
d1d7feacc9 wal: change io.EOF returned by readFull to io.ErrUnexpectedEOF
Decoder should return error for any broken block including the
one that only contains the length field. We should change io.EOF
to io.ErrUnexpectedEOF before return the error.
2015-04-23 09:53:36 -07:00
efb0b6e5c8 Fix link to etcd-migrate in README.md 2015-04-23 17:03:08 +01:00
5cd6eead51 Merge pull request #2735 from robszumski/docs-migrate-link
docs: add absolute link to readme
2015-04-22 15:15:04 -07:00
c9878f4765 docs: add absolute link to readme 2015-04-22 13:59:08 -07:00
25d857bb47 Merge pull request #2732 from robszumski/relative-links
docs: remove absolute links to other docs
2015-04-22 11:54:30 -07:00
bd54f46d1b docs: remove absolute links to other docs 2015-04-22 11:47:52 -07:00
4953e490f6 Merge pull request #2731 from yichengq/tester-wait-long
tools/etcd-tester: wait longer for health
2015-04-22 11:25:58 -07:00
46d743f389 Merge pull request #2726 from yichengq/init-sstat
etcdserver: init server stats before passing it as argument
2015-04-22 08:39:47 -07:00
1d96de459a etcdserver: init server stats before passing it as argument
It is more reasonable to init the variable before passing it as an
argument.

It fixes a bug that etcdserver may panic on server stats when processing
a message from rafthttp streamReader before server stats is initialized
in server.Start().
2015-04-22 08:28:08 -07:00
3127a3b659 tools/etcd-tester: wait longer for health
It dramatically reduce the probability that follower failed to catch up
the leader.
2015-04-21 17:55:24 -07:00
b99c80874f Merge pull request #2721 from philips/add-extended
etcdctl: add extended as output format
2015-04-21 12:16:00 -07:00
57270ec0b7 etcdctl: add extended as output format
extended wasn't documented in the help as one of the output formats, fix
this!
2015-04-21 10:22:58 -07:00
f077092bc1 Merge pull request #2715 from xiang90/version
*: serve json version on both client and peer url
2015-04-20 16:52:14 -07:00
5ad559b503 *: serve json version on both client and peer url 2015-04-20 16:23:51 -07:00
9dd7c1c60b Merge pull request #2708 from judwhite/patch-1
README.md: change setDir -> setdir
2015-04-20 13:56:35 -07:00
1811701427 Revert "etcdserver: fix cluster fallback recovery"
This reverts commit cff005777a.

Conflicts:
	etcdserver/server.go
2015-04-19 11:34:33 -07:00
88224f6f4e Revert "etcdserver: not apply stale conf change in cluster and transport"
This reverts commit 40197f0698.
2015-04-19 11:08:03 -07:00
4eae0e06e5 Merge pull request #2709 from justinsb/specify_bash_in_genproto
genproto assumes bash; specify bash
2015-04-18 15:31:00 -07:00
117cb995a5 script: genproto assumes bash; specify bash 2015-04-18 15:13:35 -07:00
d0f1bf9f8e README.md: change setDir -> setdir 2015-04-18 05:33:32 -05:00
90a7978474 Merge pull request #2666 from philips/check-error-in-store
store: always check the error
2015-04-17 20:14:32 -07:00
00044cd3bd scripts: build-aci update to have mountPoint and ports
Expose the etcd ports and data-dir mountPoint for future releases.
2015-04-17 14:57:15 -04:00
61e94ae16c Merge pull request #2625 from bakins/client-srv
Initial SRV discovery for clients
2015-04-17 08:07:32 -07:00
c4899c201e client: Discovery via SRV lookups
Based on code from discovery/srv.go.  The returns the target as DNS
returns it. In the case of SSL, certs are tied to the hostname and not
the IP address generally.

Solves #2547
2015-04-17 10:57:01 -04:00
2a675c08c2 store: always check the error
Ensure that we propogate any errors out of the node.Remove operation
back to the user. There is no reason to assume here.
2015-04-16 17:22:57 -07:00
54c4d5005d Merge pull request #2673 from ecnahc515/create_in_order
client: Add CreateInOrder method to client.KeysAPI
2015-04-16 13:34:09 -07:00
ee54aa3f02 Merge pull request #2697 from coreos/robszumski-patch-1
docs: size up all headers by 2
2015-04-16 10:10:35 -07:00
df32fe63c8 docs: size up all headers by 2 2015-04-16 09:55:46 -07:00
38a373ede9 Merge pull request #2692 from philips/add-migration-guide
Documentation: add migration notes to backward compatibility
2015-04-16 07:05:07 -07:00
a223fd532b Documentation: add migration notes to backward compatibility
Add thorough notes on both the data directory migration and the snapshot
migration options.
2015-04-15 20:42:12 -07:00
3e5d1cd873 Merge pull request #2678 from xiang90/fix_snapshot
snap: load should only return ErrNoSnapshot
2015-04-15 09:53:17 -07:00
f697916793 snap: load should only return ErrNoSnapshot
If there is no available snapshot, load should return
ErrNoSnapshot. etcdserver might recover from that error
if it still have complete WAL files.
2015-04-15 09:41:07 -07:00
0c3a92f855 Merge pull request #2663 from xiang90/wal_b
wal: report throughput in wal bench
2015-04-15 09:32:17 -07:00
da098ad713 Merge pull request #2685 from xiang90/fix_server
etcdserver: prevExist=true + condition is compareAndSwap
2015-04-15 09:17:13 -07:00
98f8dfbc9d etcdserver: prevExist=true + condition is compareAndSwap
PrevExist indicates the key should exist. Condition compares with
an existing key. So PrevExist+condition = CompareAndSwap not Update.
2015-04-14 23:44:06 -07:00
3aa7a31771 Merge pull request #2680 from xiang90/fix_backup
etcdctl: backup tool should use the new layout
2015-04-14 11:50:14 -07:00
d3778b1286 etcdctl: backup tool should use the new layout 2015-04-14 11:49:54 -07:00
d89a8628c6 client: Add CreateInOrder method to client.KeysAPI
Allows creating nodes within a given directory with atomically increasing
keys
2015-04-13 17:23:17 -07:00
f480a8b051 Merge pull request #2665 from xiaost/fix-minor-bug-in-etcdserver-send
etcdserver: fix minor bug in EtcdServer.send
2015-04-13 07:27:12 -07:00
eab2c2224a etcdserver: fix minor bug in EtcdServer.send
it seems to nothing serious.
after deleted peers, the log may output:
"etcdserver: send message to unknown receiver %s"
2015-04-13 20:35:58 +08:00
aed18395c9 wal: report throughput in wal bench 2015-04-12 21:35:08 -07:00
25f1feceb5 Merge pull request #2645 from xiang90/fix_more
wal: never leave a corrupted wal file
2015-04-09 10:30:54 -07:00
852213879b Merge pull request #2633 from yichengq/deprecate
etcdmain: deprecate --ca-file and --peer-ca-file
2015-04-09 10:22:30 -07:00
2f7b9a2232 etcdmain: deprecate --ca-file and --peer-ca-file
1. Print out DEPRECATE warning when running and configuration doc.
2. Use new flags for security example.
2015-04-09 10:14:32 -07:00
89242d4659 wal: better log msg 2015-04-09 09:54:20 -07:00
6a9e414961 Merge pull request #2603 from xiang90/dnssrv
*: stop using resolved tcp addr
2015-04-09 09:46:56 -07:00
9b65ff6959 discovery: drop trailing . from srv target 2015-04-09 07:08:22 -07:00
f5d4c86153 discovery: add a test case for srv
During srv discovery, it should try to match local member with
resolved addr and return unresolved hostnames for the cluster.
2015-04-09 07:07:27 -07:00
a3892221ee *: stop using resolved tcp addr
We start to resolve host into tcp addrs since we generate
tcp based initial-cluster during srv discovery. However it
creates problems around tls and cluster verification. The
srv discovery only needs to use resolved the tcp addr to
find the local node. It does not have to resolve everything
and use the resolved addrs.

This fixes #2488 and #2226
2015-04-09 07:01:48 -07:00
486eb8f6a8 Merge pull request #2641 from yichengq/fix-build-release
scripts: not put etcd-migrate into release dir
2015-04-08 17:22:18 -07:00
53792ccbdc wal: never leave a corrupted wal file
If the process dies during wal.cut(), it might leave a corrupted wal
file. This commit solves the problem by creating a temp wal file first,
then atomically rename it to a wal file when we are sure it is vaild.
2015-04-08 15:57:20 -07:00
2141308524 Merge pull request #2631 from yichengq/metrics-fd
etcdserver: metrics and monitor number of file descriptor
2015-04-08 11:28:58 -07:00
7a7e1f7a7c etcdserver: metrics and monitor number of file descriptor
It exposes the metrics of file descriptor limit and file descriptor used.
Moreover, it prints out warning when more than 80% of fd limit has been used.

```
2015/04/08 01:26:19 etcdserver: 80% of the file descriptor limit is open
[open = 969, limit = 1024]
```
2015-04-08 11:17:48 -07:00
252a931666 Merge pull request #2642 from yichengq/protect-wal
wal: allow at most one WAL function called at one time
2015-04-08 09:42:00 -07:00
44de670de7 wal: allow at most one WAL function called at one time
SaveSnap and Save are called in separate goroutines now. Allow at most
one WAL function being called at one time to protect internal fields and
guarantee execution order.
Or one possible bug is that the new cut file is started with snapshot
entry instead of crc entry.
2015-04-08 00:34:30 -07:00
91e9a24289 scripts: not put etcd-migrate into release dir
etcd-migrate has been integrated with etcd, and there is no need to put
it into release dir any more.
2015-04-07 16:04:52 -07:00
c66777f80f Merge pull request #2640 from xiang90/import
etcdctl: refactor message in import command
2015-04-07 15:09:34 -07:00
8c0b01d35b etcdctl: refactor message in import command 2015-04-07 15:08:07 -07:00
1b4bcedf99 Merge pull request #2637 from bakins/proxy-randomize-endpoints
proxy: shuffle endpoints
2015-04-07 14:12:50 -07:00
1fa511b995 Clarify that it is the proxy doing the shuffle. 2015-04-07 17:05:17 -04:00
74fd2b0536 Merge pull request #2638 from xiang90/import
etcdctl: import hidden keys
2015-04-07 12:53:18 -07:00
2c647409b9 etcdctl: import hidden keys 2015-04-07 12:41:05 -07:00
e1622cd22c proxy: shuffle endpoints
Shuffle endpoitns to avoid being "stuck" to a single cluster member.
2015-04-07 15:40:29 -04:00
8e9f2bb9e6 Merge pull request #2634 from xiang90/client-new
client: add dir/ttl fields into node
2015-04-07 09:11:19 -07:00
ec1fab3dc1 Merge pull request #2635 from yichengq/fix-doc
docs: fix broken link for migration tool
2015-04-07 09:03:30 -07:00
552acd8c37 docs: fix broken link for migration tool 2015-04-06 22:55:37 -07:00
666a97271d client: add dir/ttl fields into node 2015-04-06 21:47:20 -07:00
374a18130a Merge pull request #2629 from crawford/ports
*: update to use IANA-assigned ports
2015-04-06 13:57:18 -07:00
d9ad6aa2a9 *: update to use IANA-assigned ports 2015-04-06 13:49:43 -07:00
739db062d4 Merge pull request #2630 from yichengq/remove-coreos-pkg
pkg: remove unused pkg/coreos
2015-04-06 13:41:03 -07:00
2b830dd64b pkg: remove unused pkg/coreos
The package was used in upgrade path, and is not used anywhere now.
2015-04-06 13:33:42 -07:00
7d10385ec6 Merge pull request #2617 from yichengq/add-tls-test
integration: add TestTLSClusterUsingDiscovery and TestDoubleTLSCluster
2015-04-06 09:46:08 -07:00
51548acb4f rafthttp: reduce allocs in msgappv2
The patch decreases the allocs when sending one AppEntry in msgappv2
stream from 30 to 9. This helps reduce CPU load when etcd is under
high write load.
2015-04-06 09:45:39 -07:00
27083093d3 Merge pull request #2627 from mateusbraga/patch-2
osutil: fix InterruptHandler comment position
2015-04-04 09:06:55 -07:00
cec8466ad2 osutil: fix InterruptHandler comment position 2015-04-04 11:32:42 -04:00
c777516a5d Merge pull request #2620 from yichengq/new-rafthttp-msgapp
rafthttp: introduce msgappv2 stream format
2015-04-03 17:13:05 -07:00
0d88e0d111 rafthttp: introduce msgappv2 stream format
msgappv2 stream is used to send all MsgApp, and replaces the
functionality of msgapp stream. Compared to v1, it has several
advantanges:
1. The output message is exactly the same with the input one, which
cannot be done in v1.
2. It uses one connection to stream persistently, which prevents message
reorder and saves the time to request stream.
3. It transmits 10 addiontional bytes in the procedure of committing one
proposal, which is trivia for idle time.
4. It transmits less bytes when committing mutliple proposals or keep
committing proposals.
2015-04-03 17:08:56 -07:00
89495f9194 Merge pull request #2626 from yichengq/fix-raft-status
raft: generate correct json-format status
2015-04-03 13:54:46 -07:00
fa96e64b43 Merge pull request #2624 from yichengq/fix-raft-storage
raft: lock storage when compact it
2015-04-03 13:51:06 -07:00
3d32c059dd raft: generate correct json-format status
Current json-format string misses the double quote around status field.

Use %q for better clearance.
2015-04-03 13:49:46 -07:00
422cb7cb06 Merge pull request #2621 from yichengq/fix-inflight
raft: fix freeTo fails to free
2015-04-03 13:28:29 -07:00
d91ea7f199 raft: fix freeTo fails to free
If freeTo is called when to is set to the lastest inflight, freeTo
fails to free the slots.
2015-04-03 13:21:26 -07:00
c6de464587 raft: lock storage when compact it
etcd now compact raft storage asynchronously, and append entry to raft
storage may happen at the same time. Add the lock to fix the bug that
the entries saved in storage may be organized in a wrong way.
2015-04-03 11:38:01 -07:00
471aa1aa89 Merge pull request #2622 from xiang90/fix_watcher
store: fix watcher removal
2015-04-03 10:39:03 -07:00
999917010d store: fix watcher removal 2015-04-03 10:13:43 -07:00
c38a6a38bb Merge pull request #2619 from kelseyhightower/update-docker-docs
Documentation: update docker docs to use new image and mount certs
2015-04-02 13:39:24 -07:00
3db33d19e9 Documentation: update docker docs to use new image and mount certs 2015-04-02 13:22:27 -07:00
73936d1874 integration: add TestDoubleTLSCluster 2015-04-02 10:08:40 -07:00
ccb0934e22 integration: add TestTLSClusterUsingDiscovery 2015-04-02 00:01:39 -07:00
39633850d1 Merge pull request #2610 from yichengq/add-tls-test
integration: add TestTLSClusterOf3
2015-04-01 21:57:44 -07:00
d2efa2a615 integration: add TestTLSClusterOf3 2015-04-01 20:55:00 -07:00
a719f78046 Merge pull request #2616 from yichengq/stop-raft
etcdserver: stop raft node goroutine before stop server
2015-04-01 11:53:24 -07:00
9e5743c816 etcdserver: stop raft node goroutine before stop server
Stop raftNode goroutine before stopping server goroutine, so
server.Stop does stop all underlying stuffs elegantly now. This fixes
the problem that previous-round lock on WAL may not be released when
etcd is restarted.
2015-04-01 11:20:51 -07:00
2c7a8c2216 Merge pull request #2615 from yichengq/fix-upgrade-test
integration: fix upgrade test
2015-04-01 09:44:01 -07:00
f3baf4517b integration: fix upgrade test
Upgrade test listens on a fixed port, which may fail with 'bind address
already in use' if the port was just used to send tcp sockets.

The commit makes it listen on a random available port to avoid this.
2015-03-31 16:17:58 -07:00
9ad2eaf16c Merge pull request #2614 from barakmich/typos
etcdctl: fix import typos
2015-03-31 16:43:43 -04:00
ad7a12066f etcdctl: fix import typos 2015-03-31 16:41:35 -04:00
8ac7639459 Merge pull request #2612 from yichengq/fix-isolate
pkg/netutil: fix DropPort and RecoverPort in linux
2015-03-31 11:58:12 -07:00
a4fefd7f73 Merge pull request #2613 from xiang90/fix_import
etcdctl: wait for goroutine existing
2015-03-31 11:56:35 -07:00
1024f587e0 etcdctl: main routine of import command should wait for goroutine existing 2015-03-31 11:55:19 -07:00
46cfbb3a26 Merge pull request #2605 from xiang90/build
build: do not build internal debugging tool
2015-03-31 11:47:00 -07:00
a9157ce6d3 build: do not build internal debugging tool
We are still playing around with the dump-log tool.
Stop building it publicly until we are happy with its
ux and functionality.
2015-03-31 11:45:12 -07:00
b67ee7d222 Merge pull request #2608 from xiang90/walallocation
wal: reduce allocation when encoding int64
2015-03-31 10:55:20 -07:00
44665fc055 Merge pull request #2611 from xiang90/ctlport
etcdct: adopt new client port by default
2015-03-31 10:47:06 -07:00
24f9ba8ee8 pkg/netutil: fix DropPort and RecoverPort in linux
The iptables commands in DropPort do not work because setting
destination-port flag without specifying the protocol is invalid.
2015-03-31 10:39:31 -07:00
8ac565bc38 etcdct: adopt new client port by default
etcdserver uses both 4001 and 2379 for serving client requests by
default. etcdctl supports both ports by default.
2015-03-31 09:56:42 -07:00
8bcaa2bfdf wal: reduce allocation when encoding int64 2015-03-30 20:41:31 -07:00
2990c29a71 Merge pull request #2607 from xiang90/walallocation
wal: reduce allocation when encoding entries
2015-03-30 20:31:00 -07:00
c32cca3a4f wal: reduce allocation when encoding entries 2015-03-30 19:20:46 -07:00
4cbbbb6c46 Merge pull request #2606 from xiang90/update
*: update context pkg
2015-03-30 18:59:39 -07:00
73adb20166 *: update context pkg 2015-03-30 18:58:44 -07:00
77a04cda0c Merge pull request #2597 from xiang90/wal-repair
wal: fix the unexpectedEOF error in the last wal.
2015-03-30 13:49:05 -07:00
3e9a033cd2 wal: repair decoder needs to update its crc 2015-03-30 13:45:23 -07:00
253f7c4ae1 Merge pull request #2522 from xiang90/user_pw
etcdserver/etcdhttp: do not return back the password of a user
2015-03-30 13:42:41 -07:00
80d08ca280 Merge pull request #2521 from xiang90/sec_remove_lastmodified
doc/rfc: remove unimplemented stuff
2015-03-30 13:42:31 -07:00
c0f7ca26a3 Merge pull request #2587 from xiang90/ctl
etcdctl: add import command
2015-03-30 13:42:01 -07:00
fbfa6ba86a Merge pull request #2598 from xiang90/raft_bench
raft: node bench matches reality
2015-03-30 09:55:13 -07:00
81750ab2d7 Merge pull request #2600 from yichengq/failure-isolate
tools/functional-tester: add isolate failures
2015-03-29 22:43:51 -07:00
0b9a318e68 etcdserver: make the wal repairing logic clear 2015-03-29 21:10:28 -07:00
ee2833111d Merge pull request #2599 from yichengq/etcd-tester
tools/etcd-agent: stop etcd only if it is running when cleanup
2015-03-29 21:07:24 -07:00
e3e11aa1b1 Merge pull request #2584 from kalabiyau/patch-1
Update README.md
2015-03-29 20:59:13 -07:00
684ebd95ae wal: backup broken wal before repairing 2015-03-29 15:42:59 -07:00
1231f82f22 etcdserver: save snapshot into wal first 2015-03-29 14:23:05 -07:00
04a62dd54b tools/functional-tester: add isolate failures 2015-03-29 00:29:47 -07:00
8b4eed29e5 wal: fix the unexpectedEOF error in the last wal.
It is safe to repair the unexpectedEOF error in the last wal. raft
will not send out message before the entry successfully comitted
into wal. Thus we can safely truncate the last entry in the wal
to repair.
2015-03-28 21:08:14 -07:00
097a56fe01 tools/etcd-agent: stop etcd only if it is running
Stop etcd only if it is running, and not report error when stopping etcd
which is not started.
2015-03-28 19:31:06 -07:00
3f867bc6ed raft: node bench matches reality 2015-03-28 14:53:42 -07:00
84cf0843bf etcdctl: add migratesnap command 2015-03-27 19:23:38 -07:00
9a33678878 Merge pull request #2596 from yichengq/revert-internal-version
Revert "etcdhttp: add internalVersion"
2015-03-27 17:02:02 -07:00
60efd4d96e Revert "etcdhttp: add internalVersion"
This reverts commit a77bf97c14.

Conflicts:
	version/version.go
2015-03-27 16:53:55 -07:00
09f8dbad98 Merge pull request #2594 from xiang90/rm_upgrade
*: remove upgrading related stuff
2015-03-27 15:37:47 -07:00
45032480f1 *: remove upgrading related stuff 2015-03-27 15:28:00 -07:00
dd92a2b484 Merge pull request #2556 from yichengq/fix-apply-conf
etcdserver: not apply stale conf change
2015-03-27 14:00:30 -07:00
a16d15aafc Merge pull request #2591 from kelseyhightower/cleanup-etcdserver-stats
etcdserver: add stats.FollowerLatencyStats and stats.FollowerCountsStats...
2015-03-27 13:59:40 -07:00
538d624cfa etcdserver: add stats.LatencyStats and stats.CountsStats types 2015-03-27 13:42:44 -07:00
40197f0698 etcdserver: not apply stale conf change in cluster and transport 2015-03-27 12:53:34 -07:00
2439adf945 Merge pull request #2589 from mateusbraga/patch-1
docs: add clarity about the 1000 events history
2015-03-27 10:04:27 -07:00
7f833ced2b docs: add clarity about the 1000 events history
When talking about missing events on a particular key, the 1000 event history 
limit can be understood as being per key, instead of etcd-wide events. Make it 
clear that it is across all etcd keys.
2015-03-27 13:02:48 -04:00
635e4db6d9 Merge pull request #2582 from xiang90/cluster-check
etcdserver: loose member validation for joining existing cluster
2015-03-25 14:37:13 -07:00
424c29eacc Update README.md 2015-03-25 22:01:02 +01:00
e3817adb5b etcdserver: loose member validation for joining existing cluster 2015-03-25 13:59:22 -07:00
e5f2f40145 Merge pull request #2579 from xiang90/update-proto
*: update protobuf
2015-03-25 10:59:34 -07:00
05e240b892 *: update protobuf 2015-03-25 10:14:35 -07:00
bbcee5f506 Merge pull request #2577 from yichengq/fix-wal-test
wal: fix missing import
2015-03-24 22:58:43 -07:00
3dd6e0b88f wal: fix missing import 2015-03-24 22:53:15 -07:00
ea24b397bf Merge pull request #2576 from xiang90/fix_wal
wal: releastTo should work with large release index
2015-03-24 22:35:04 -07:00
6e6669d696 wal: releastTo should work with large release index 2015-03-24 22:34:26 -07:00
f940a34e60 Merge pull request #2575 from yichengq/343
version: not return err NotExist in Detect
2015-03-24 20:26:53 -07:00
16183bc22b version: not return err NotExist in Detect 2015-03-24 20:19:42 -07:00
d40ecad617 Merge pull request #2572 from bdarnell/multinode-config
raft: Use raft.Config in MultiNode.
2015-03-24 19:28:28 -07:00
f03ccd1120 Merge pull request #2573 from yichengq/fix-detect-wal
print out extra files in data dir instead of erroring
2015-03-24 19:17:01 -07:00
5e0077cc0c etcdserver: print out extra files in data dir instead of erroring 2015-03-24 18:56:22 -07:00
c9d507df11 raft: Use raft.Config in MultiNode. 2015-03-24 15:37:13 -04:00
866a9d4e41 Merge pull request #2568 from xiang90/raftnode
raft: make node configurable
2015-03-24 11:18:22 -07:00
b3fb052ad4 raft: make peers a prviate field in raft.Config 2015-03-24 11:10:07 -07:00
ea78f5d1aa Merge pull request #2552 from yichengq/fix-2396
etcdserver: check -initial-cluster in join case
2015-03-23 22:46:38 -07:00
abcd828114 etcdserver: add join-existing check 2015-03-23 22:31:20 -07:00
abddef0f28 raft: make node configurable 2015-03-23 21:20:49 -07:00
5ba85cb58d Merge pull request #2565 from coreos/philips-patch-1
raft: design: fixup markdown
2015-03-23 14:06:05 -07:00
057978bbc6 raft: design: fixup markdown
Need a space between `1.` for markdown to render as a list.
2015-03-23 14:01:17 -07:00
bcf001fe76 Merge pull request #2563 from yichengq/343
etcdmain: print error when non-flag args remain
2015-03-23 11:26:31 -07:00
0ac05e310e etcdmain: print error when non-flag args remain 2015-03-23 11:23:47 -07:00
e201f4b824 Merge pull request #2561 from xiang90/raft-configurable
raft: make raft configurable
2015-03-23 09:55:48 -07:00
d9b5b56c82 raft: make raft configurable 2015-03-23 09:55:19 -07:00
823c6d678c Merge pull request #2557 from yichengq/fix-windows-binary
scripts: add .exe extension on windows binaries
2015-03-22 22:58:44 -07:00
454b66edde Merge pull request #2558 from kelseyhightower/add-basic-auth
netutil: add BasicAuth function
2015-03-20 22:34:06 -07:00
a552722f03 Merge pull request #2544 from xiang90/raft-inflight
raft: add flow control for progress
2015-03-20 20:12:31 -07:00
4a64373225 raft: add flow control for progress
Each progress has a inflighs sliding window. When the progress
is in replicate state, inflights will control the sending speed
of the leader.

The leader can have at most maxInflight number of inflight
messages for each replicate progress. Receving a appResp moves
forward the sliding window. Heartbeat response free one
slot if the window is full.
2015-03-20 20:04:33 -07:00
09a86cb9b9 Merge pull request #2553 from xiang90/raft-design
raft: add progress state machine graph
2015-03-20 19:57:51 -07:00
4611c3b2d7 netutil: add BasicAuth function
etcd ships it's own BasicAuth function and no longer requires
Go 1.4 to build.
2015-03-20 17:32:33 -07:00
431fcc60ab scripts: add .exe extension on windows binaries 2015-03-20 16:45:29 -07:00
86622537a1 raft: add progress state machine graph 2015-03-20 15:28:50 -07:00
b7bbeefbff Merge pull request #2551 from yichengq/remove-starter
migrate: remove starter code
2015-03-20 13:07:23 -07:00
02be882c8f migrate: remove starter code
It has been moved to github.com/coreos/etcd-starter.
2015-03-20 10:51:42 -07:00
44d9209990 Merge pull request #2548 from xiang90/raft-design
raft: add our very first design.md
2015-03-20 09:07:44 -07:00
6e557c58c7 Merge pull request #2532 from yichengq/342
raft: print out data and time in log
2015-03-20 08:03:23 -07:00
f455de281c Merge pull request #2537 from buaazp/fix_store_stats_clone
fixed clone error for store stats.
2015-03-20 07:56:57 -07:00
afed8cf044 store: fixed clone error for store stats. 2015-03-20 12:31:47 +08:00
59d8089295 raft: add our very first design.md 2015-03-19 21:00:47 -07:00
2a980ee336 Merge pull request #2503 from yichengq/339
docs/security: fix peer TLS communication example
2015-03-19 17:16:09 -07:00
ea764dcdf7 Merge pull request #2542 from yichengq/etcd-tester
tools/etcd-tester: stress cluster using 50MB snapshot
2015-03-19 14:52:57 -07:00
d920c5b801 tools/etcd-tester: stress cluster using 50MB snapshot 2015-03-19 14:52:27 -07:00
ed81ccc1bb Merge pull request #2540 from xiang90/raft-progress
raft: move progress to progress.go
2015-03-19 10:09:54 -07:00
2adb58f9de raft: move progress to progress.go 2015-03-19 10:05:04 -07:00
a475e90c9c Merge pull request #2531 from xiang90/raft-limit
raft: limit the size of msgApp
2015-03-19 09:55:36 -07:00
125a033c72 Merge pull request #2534 from philips/initial-cluster-name
etcdmain: let user provide a name w/o initial-cluster update
2015-03-18 18:55:58 -07:00
b29eaed9ce Merge pull request #2533 from philips/grammar-unsafe-flags
Documentation: fixup grammar around the unsafe flags
2015-03-18 18:27:28 -07:00
82adf0b039 Merge pull request #2536 from philips/fixup-wal-201-starter
migrate: detect version 2.0.1
2015-03-18 18:23:50 -07:00
86ee3e3452 migrate: detect version 2.0.1
Without this code a second start will crash:

```
$ ./bin/etcd -name foobar --data-dir=foobar
2015/03/18 18:06:28 starter: detect etcd version 2.0.1 in foobar
2015/03/18 18:06:28 starter: unhandled etcd version in foobar
panic: starter: unhandled etcd version in foobar

goroutine 1 [running]:
log.Panicf(0x594770, 0x25, 0x208927c70, 0x1, 0x1)
	/usr/local/go/src/log/log.go:314 +0xd0
github.com/coreos/etcd/migrate/starter.checkInternalVersion(0x20889a480, 0x0, 0x0)
	/Users/philips/src/github.com/coreos/etcd/gopath/src/github.com/coreos/etcd/migrate/starter/starter.go:160 +0xf2f
github.com/coreos/etcd/migrate/starter.StartDesiredVersion(0x20884a010, 0x3, 0x3)
	/Users/philips/src/github.com/coreos/etcd/gopath/src/github.com/coreos/etcd/migrate/starter/starter.go:77 +0x2a9
main.main()
	/Users/philips/src/github.com/coreos/etcd/gopath/src/github.com/coreos/etcd/main.go:46 +0x25e

goroutine 9 [syscall]:
os/signal.loop()
	/usr/local/go/src/os/signal/signal_unix.go:21 +0x1f
created by os/signal.init·1
	/usr/local/go/src/os/signal/signal_unix.go:27 +0x35
```
2015-03-18 18:09:46 -07:00
ea72f2637c etcdmain: let user provide a name w/o initial-cluster update
Currently this doesn't work if a user wants to try out a single machine
cluster but change the name for whatever reason. This is because the
name is always "default" and the

```
./bin/etcd -name 'baz'
```

This solves our problem on CoreOS where the default is `ETCD_NAME=%m`.
2015-03-18 17:24:52 -07:00
408cfc4f28 Documentation: fixup grammar around the unsafe flags 2015-03-18 16:39:45 -07:00
7571b2cde2 raft: limit the size of msgApp
limit the max size of entries sent per message.
Lower the cost at probing state as we limit the size per message;
lower the penalty when aggressively decrease to a too low next.
2015-03-18 15:59:30 -07:00
0634cf2cfe raft: print out data and time in log
Keep the default log setting consistent with other packages.
2015-03-18 15:49:06 -07:00
7e7bc76038 Merge pull request #2514 from yichengq/340
raft: introduce progress states
2015-03-18 09:40:30 -07:00
67194c0b22 raft: introduce progress states 2015-03-18 08:16:32 -07:00
35fddbc5d0 Merge pull request #2526 from xiang90/fix_proxy_restart
etcdserver: etcd should fall back to proxy again if proxy data is detected
2015-03-17 16:22:23 -07:00
1ab68902a9 etcdmain: identify data dir type 2015-03-17 16:10:58 -07:00
d17f3a4452 Merge pull request #2519 from bdarnell/multinode-commit
raft: Use the correct commit index when advancing in MultiNode.
2015-03-17 10:31:53 -07:00
cd1ff78ff3 raft: Elaborate a little more about committed entries in commitReady. 2015-03-17 13:22:36 -04:00
5bfb4ed4fb Merge pull request #2520 from funkygao/funky
fix godoc bug
2015-03-17 08:00:10 -07:00
0b912c0faf raft: fix godoc about starting a node 2015-03-17 17:35:18 +08:00
9d28f94005 etcdserver/etcdhttp: do not return back the password of a user 2015-03-16 22:35:01 -07:00
263e55e2ff doc/rfc: remove unimplemented stuff 2015-03-16 22:22:34 -07:00
271d911c32 raft: Use the correct commit index when advancing in MultiNode.
This fixes an issue when restoring from a snapshot and brings
MultiNode closer to Node.
2015-03-16 18:40:51 -04:00
8a589d11d5 Merge pull request #2518 from xiang90/security_write_error
etcdserver/etcdhttp: write the http error to response writer
2015-03-16 15:25:35 -07:00
f3e4dbf967 etcdserver/etcdhttp: write the http error to response writer 2015-03-16 15:24:19 -07:00
bba7f75562 Merge pull request #2517 from yichengq/fix-sec2
security: fix var shadowing in CreateOrUpdateUser
2015-03-16 15:08:55 -07:00
8335a5407b security: fix var shadowing in CreateOrUpdateUser 2015-03-16 14:59:05 -07:00
98ef65ce77 Merge pull request #2516 from yichengq/fix-sec
security: fix var shadowing in CreateOrUpdate
2015-03-16 14:56:38 -07:00
d7780cf293 security: fix var shadowing in CreateOrUpdate 2015-03-16 14:55:04 -07:00
b65a7ed18b Merge pull request #2434 from barakmich/acl
security: Add saving of users and roles through the v2 API
2015-03-16 16:28:29 -04:00
001efa0639 security: Implement RBAC security for etcd
stub out security

further wip

Last stub before CRUD for roles

Complete role merging

start tests

add Godep for golang.org/x/crypto/bcrypt

first round of comments

add tests, remove root addition (will be added back as part of creation)

Add security checks for /v2/machines and /v2/keys

Allow non-root to determine if security is enabled, get machine list.

Responding to comments, remove multiple verbs (like /v2/security/user/foo/password)

add some prefixes to the logging
2015-03-16 16:23:11 -04:00
f8aaa6a161 Merge pull request #2510 from xiang90/tester-rp
tools/functional-tester/etcd-tester: report agent status
2015-03-14 10:09:52 -07:00
9c74f98b97 Merge pull request #2502 from kelseyhightower/trusted-ca-and-client-auth
etcd: server SSL and client cert auth configuration is more explicit
2015-03-14 09:40:53 -07:00
6b1eb296e0 Merge pull request #2509 from yichengq/341
docs: add branch management
2015-03-13 15:35:06 -07:00
45d790c345 docs: add branch management 2015-03-13 15:33:59 -07:00
46ebb83b90 tools/functional-tester/etcd-tester: report agent status 2015-03-13 15:29:57 -07:00
1f470fd1c6 Merge pull request #2507 from xiang90/agent-log
tools/funcational-tester/etcd-agent: log the error for dubgging
2015-03-13 13:28:41 -07:00
83bb02e320 tools/funcational-tester/etcd-agent: log the error for dubgging 2015-03-13 12:08:08 -07:00
a9ecf0caff Merge pull request #2498 from xiang90/agent-status
tools/functional-tester/etcd-agent: add status rpc
2015-03-13 10:56:02 -07:00
e46beb75c8 tools/functional-tester/etcd-agent: add status rpc 2015-03-13 10:48:06 -07:00
8dd8b1cdc2 etcd: server SSL and client cert auth configuration is more explicit
etcd does not provide enough flexibility to configure server SSL and
client authentication separately. When configuring server SSL the
`--ca-file` flag is required to trust self-signed SSL certificates
used to service client requests.

The `--ca-file` has the side effect of enabling client cert
authentication. This can be surprising for those looking to simply
secure communication between an etcd server and client.

Resolve this issue by introducing four new flags:

    --client-cert-auth
    --peer-client-cert-auth
    --trusted-ca-file
    --peer-trusted-ca-file

These new flags will allow etcd to support a more explicit SSL
configuration for both etcd clients and peers.

Example usage:

Start etcd with server SSL and no client cert authentication:

    etcd -name etcd0 \
    --advertise-client-urls https://etcd0.example.com:2379 \
    --cert-file etcd0.example.com.crt \
    --key-file etcd0.example.com.key \
    --trusted-ca-file ca.crt

Start etcd with server SSL and enable client cert authentication:

    etcd -name etcd0 \
    --advertise-client-urls https://etcd0.example.com:2379 \
    --cert-file etcd0.example.com.crt \
    --key-file etcd0.example.com.key \
    --trusted-ca-file ca.crt \
    --client-cert-auth

Start etcd with server SSL and client cert authentication for both
peer and client endpoints:

    etcd -name etcd0 \
    --advertise-client-urls https://etcd0.example.com:2379 \
    --cert-file etcd0.example.com.crt \
    --key-file etcd0.example.com.key \
    --trusted-ca-file ca.crt \
    --client-cert-auth \
    --peer-cert-file etcd0.example.com.crt \
    --peer-key-file etcd0.example.com.key \
    --peer-trusted-ca-file ca.crt \
    --peer-client-cert-auth

This change is backwards compatible with etcd versions 2.0.0+. The
current behavior of the `--ca-file` flag is preserved.

Fixes #2499.
2015-03-12 23:09:54 -07:00
b53bfd2b40 docs/security: fix peer TLS communication example 2015-03-12 22:40:39 -07:00
862c16e821 Merge pull request #2500 from xiang90/fix-panic
etcdmain: verify heartbeat and election flag
2015-03-12 18:06:38 -07:00
ed8c3534e9 etcdmain: verify heartbeat and election flag 2015-03-12 17:45:49 -07:00
38df712777 Merge pull request #2496 from bdarnell/patch-2
raft: correctly pass arguments to Logger.Panicf()
2015-03-12 14:39:17 -07:00
5e19adcf70 raft: correctly pass arguments to Logger.Panicf() 2015-03-12 16:15:43 -04:00
6103a05ed1 Merge pull request #2495 from yichengq/337
rafthttp: report snapshot failure when dropping MsgSnap
2015-03-12 13:10:00 -07:00
d9cb77aad5 rafthttp: report snapshot failure when dropping MsgSnap 2015-03-12 13:06:43 -07:00
f9ee8ecb3a Merge pull request #2478 from kmeaw/master
Support IPv6 address for ETCD_ADDR and ETCD_PEER_ADDR
2015-03-12 13:04:32 -07:00
d537ef3de9 Merge pull request #2494 from xiang90/ft
tools/functional-tester: add http status reporter
2015-03-12 12:50:13 -07:00
462f32a81b tools/functional-tester: add http status reporter 2015-03-12 12:49:48 -07:00
ab20a5e12d Merge pull request #2491 from endocode/iaguis/fix-test
rafttest: fix build error
2015-03-12 08:02:30 -07:00
e698192e4a rafttest: fix build error
raftLogger is not exported so we can't access it from here. Go back to
using log.
2015-03-12 11:47:13 +01:00
00a22891ee pkg/flags: Add support for IPv6 addresses
Support IPv6 address for ETCD_ADDR and ETCD_PEER_ADDR

pkg/flags: Support IPv6 address for ETCD_ADDR and ETCD_PEER_ADDR

pkg/flags: tests for IPv6 addr and bind-addr flags

pkg/flags: IPAddressPort.Host: do not enclose IPv6 address in square brackets

pkg/flags: set default bind address to [::] instead of 0.0.0.0

pkg/flags: we don't need fmt any more

also, one minor fix: net.JoinHostPort takes string as a port value

pkg/flags: fix ipv6 tests

pkg/flags: test both IPv4 and IPv6 addresses in TestIPAddressPortString

etcdmain: test: use [::] instead of 0.0.0.0
2015-03-12 11:30:53 +03:00
32105e6ed0 Merge pull request #2484 from yichengq/336
rafthttp: drop messages in channel when disconnection
2015-03-11 14:55:10 -07:00
e41cbeda5d rafthttp: drop messages in channel when disconnection
The messages in channel are outdated, and there is no need to send
them in the future. It also reports unreachable if there are messages
in the channel.
2015-03-11 14:42:06 -07:00
62a7e2f41f Merge pull request #2483 from yichengq/335
rafthttp: report unreachable when dropping messages
2015-03-11 14:41:15 -07:00
39731724ff Merge pull request #2485 from yichengq/337
raft: fall back to bad path when unreachable
2015-03-11 14:16:39 -07:00
a230003255 rafthttp: report unreachable when dropping messages 2015-03-11 14:11:41 -07:00
be0bf2a2bd raft: fall back to bad path when unreachable 2015-03-11 13:21:23 -07:00
2ca981d8cb Merge pull request #2482 from xiang90/fix-raft
raft: reply with the commit index when receives a smaller append message
2015-03-11 10:34:25 -07:00
c643967a41 raft: reply with the commit index when receives a smaller append message
Follower should not reject the append message with a smaller index than its commit
index. Or it will trigger the leader's resending logic, which might have a high cost.
2015-03-10 22:32:36 -07:00
b1ff6ddd88 Merge pull request #2446 from xiang90/apply-routine
etcdserver: separate apply and raft routine
2015-03-10 18:40:52 -07:00
d015610da5 etcdserver: separate apply and raft routine 2015-03-10 13:34:24 -07:00
9a9d00b482 Merge pull request #2453 from yichengq/334
tools/etcd-tester: add kill one member tests
2015-03-10 13:17:57 -07:00
24a210ab20 tools/etcd-tester: add kill one member tests 2015-03-10 11:38:54 -07:00
83496c3966 Merge pull request #2474 from xiang90/fix-wal
wal: fix ReleaseLockTo
2015-03-09 20:12:24 -07:00
b66eb3d81c wal: fix ReleaseLockTo
ReleaseLockTo should not release the lock on the WAL
segment that is right before the given index. When
restarting etcd, etcd needs to read from the WAL segment
that has a smaller index than the snapshot index.

The correct behavior is that ReleaseLockTo releases
the locks w is holding so that w only holds one lock
that has an index smaller than the given index.
2015-03-09 19:52:54 -07:00
4e525e63a4 Merge pull request #2459 from yichengq/335
rafthttp: use dedicated go-routine for MsgProp process
2015-03-09 14:17:28 -07:00
51397a6423 rafthttp: use go-routine for MsgProp processing
MsgProp process is blocking when there is no leader, which blocks the peer
loop totally.
2015-03-09 14:11:16 -07:00
a2be25cba4 Merge pull request #2460 from xiang90/raft-logger
raft: introduce logger interface
2015-03-09 08:00:21 -07:00
97579e2e1d raft: introduce logger interface 2015-03-08 21:36:32 -07:00
17ba06b5cd Merge pull request #2461 from xiang90/fix-raft
raft: do not reset vote if term is not changed
2015-03-08 11:39:35 -07:00
7fe608532a raft: do not reset vote if term is not changed
raft MUST keep the voting information for the same term. reset
should not reset vote if term is not changed.
2015-03-07 22:31:20 -08:00
b374f93bb8 Merge pull request #2456 from xiang90/tls
pkg/transport: fix downgrade https to http bug in transport
2015-03-06 11:39:44 -08:00
3c9581adde pkg/transport: fix downgrade https to http bug in transport
If the TLS config is empty, etcd downgrades https to http without a warning.
This commit avoid the downgrade and stoping etcd from bootstrap if it cannot
listen on TLS.
2015-03-06 10:42:23 -08:00
964c61916d Merge pull request #2455 from kelseyhightower/add-benchmarks
Documentation: add initial benchmarks
2015-03-06 09:34:05 -08:00
4a38788b2f Documentation: add initial benchmarks 2015-03-06 09:32:24 -08:00
ba20016f0f tools/etcd-tester: reorganize failures 2015-03-05 21:14:41 -08:00
daea484a9f Merge pull request #2451 from xiang90/fix_wal
wal: do not race reader and writer
2015-03-05 20:57:25 -08:00
ab72c3ec88 wal: do not race reader and writer 2015-03-05 20:19:17 -08:00
eba6daef4b Merge pull request #2450 from yichengq/335
tools/functional-tester: add cleanup rpc
2015-03-05 16:36:16 -08:00
181ee445c1 better dir name 2015-03-05 16:34:14 -08:00
b96ecfcc07 Merge pull request #2448 from yichengq/334
tools/etcd-tester: add kill majority test
2015-03-05 15:59:34 -08:00
8e76ccf979 Merge pull request #2439 from xiang90/metrics
Metrics
2015-03-05 15:55:34 -08:00
2152447361 tools/functional-tester: add cleanup rpc 2015-03-05 15:55:28 -08:00
4314b19a2e tools/etcd-agent: recycle etcd zombie when termination 2015-03-05 15:51:11 -08:00
267313a3f8 tools/etcd-tester: add kill majority test 2015-03-05 15:14:14 -08:00
8b770f8a1a Merge pull request #2447 from yichengq/334
etcd-tester: initial stresser
2015-03-05 13:33:51 -08:00
3cffc910de tools/etcd-tester: use stresser 2015-03-05 13:21:49 -08:00
eec52738d8 etcd-tester: initial stresser 2015-03-05 11:06:43 -08:00
0a04eec481 Merge pull request #2441 from yichengq/334
tools/functional-tester: make it work basically
2015-03-05 10:30:38 -08:00
d5957aebfd tools/etcd-tester: add failure killall 2015-03-05 10:24:21 -08:00
530dd891be tools/etcd-tester: make it work
1. add cluster support
2. add failureNo case
3. add main func
2015-03-05 10:24:21 -08:00
8d3d737993 tools/etcd-agent/client: fix rpc Dial 2015-03-05 10:24:21 -08:00
061baad611 tools/etcd-agent: write etcd log into log file 2015-03-05 10:24:13 -08:00
0ab24d4606 Merge pull request #2444 from bdarnell/multinode-report
Add ReportUnreachable and ReportSnapshot to MultiNode.
2015-03-05 10:05:15 -08:00
725c411346 Add ReportUnreachable and ReportSnapshot to MultiNode.
Add ReportSnapshot requirement to doc.go.
2015-03-05 12:39:52 -05:00
6b9b695167 Merge pull request #2435 from bdarnell/multinode
raft: Introduce MultiNode.
2015-03-04 21:27:20 -08:00
008bbd2b84 tools/etcd-agent: log rpc actions 2015-03-04 18:29:23 -08:00
9e69aba7aa tools/etcd-agent: add main func 2015-03-04 17:22:56 -08:00
a32abdbb0f rafthttp: make metrics naming consistent 2015-03-04 16:12:53 -08:00
ab33c068b7 rafthttp: record the number of failed messages 2015-03-04 16:09:50 -08:00
c2d4d8c64e Merge pull request #2415 from yichengq/333
rafthttp: support multiple peer urls
2015-03-04 16:00:25 -08:00
933ab1e4f7 rafthttp: peer.newURLc -> peer.newURLsC 2015-03-04 15:00:47 -08:00
0fe9861197 rafthttp: support multiple peer urls 2015-03-04 15:00:07 -08:00
c3f32504ec Merge pull request #2431 from bdarnell/raft-docs
raft: Expand doc.go
2015-03-04 13:29:35 -08:00
c824c867ec raft: more doc updates.
Including parallelism of persist and send, cancellation of
ConfChanges, and the risks of two-node clusters.
2015-03-04 15:48:35 -05:00
4e74d81bbb raft: Introduce MultiNode.
MultiNode is an alternative to raft.Node that is more efficient
when a node may participate in many consensus groups. It is currently
used in the CockroachDB project; this commit merges the
github.com/cockroachdb/etcd fork back into the mainline.
2015-03-04 15:30:21 -05:00
ecf9d1232d Merge pull request #2433 from xiang90/metrics
rafthttp: add metrics for sending message
2015-03-04 11:29:25 -08:00
17aa3cf7db rafthttp: add metrics for sending message 2015-03-04 11:18:16 -08:00
80146e2ccf Merge pull request #2427 from xiang90/etcd-smoketest
tools/functional-tester: inital commit
2015-03-04 10:30:49 -08:00
ebf253bad9 Merge pull request #20 from yichengq/etcd-smoketest
etcd-tester: fix build
2015-03-04 10:30:36 -08:00
30e6d49bec etcd-tester: fix build 2015-03-04 10:22:53 -08:00
250970cc23 raft: Expand doc.go
Includes more details on the required caller behavior and the safety of
membership changes.

Closes #2397
2015-03-04 13:18:02 -05:00
c7146bd5f2 Merge pull request #2421 from xiang90/cleanup-rafthttp
Cleanup rafthttp
2015-03-03 22:35:01 -08:00
44e53953c9 rafthttp: add comments for Transporter interface 2015-03-03 22:34:47 -08:00
2bfd266a81 tools/functional-tester: inital commit 2015-03-03 20:12:20 -08:00
559466e996 Merge pull request #2422 from xiang90/fix_etcdctl
etcdctl: mark unstarted member
2015-03-03 11:13:39 -08:00
b218fc67e4 etcdctl: mark unstarted member 2015-03-03 11:00:40 -08:00
2558b1d31b Merge pull request #2420 from xiang90/kill-todo
rafthttp: kill connection timeout TODO
2015-03-03 10:15:27 -08:00
cb105c626c rafthttp: kill connection timeout TODO 2015-03-03 09:49:01 -08:00
3a132ad8ef Merge pull request #2413 from xiang90/refactor-peer
rafthttp: add comment for timeout
2015-03-03 06:40:24 -08:00
a3b3fc5e87 Merge pull request #2414 from xiang90/fix_max_host
pkg/transport: set the maxIdleConnsPerHost to -1
2015-03-03 06:30:46 -08:00
b15806e189 etcdctl: update the ls subcommand help to match behavior
Currently the `etcdctl ls` subcommand help output is a bit misleading.
It mentions that using the `--recursive` flag will output all keys and
values for a given path:

    --recursive  returns all values for key and child keys

This is inaccurate. The `--recursive` will only output the key names
under the given path. Fix the issue by updating the help string for
the `--recursive` flag.

    --recursive  returns all key names recursively for the given path

Fixes #2379.
2015-03-03 06:25:22 -08:00
1271b01069 Merge pull request #2406 from yichengq/333
rafthttp: add functional tests
2015-03-02 22:51:55 -08:00
e50d43fd32 pkg/transport: set the maxIdleConnsPerHost to -1
for transport that are using timeout connections, we set the
maxIdleConnsPerHost to -1. The default transport does not clear
the timeout for the connections it sets to be idle. So the connections
with timeout cannot be reused.
2015-03-02 21:52:03 -08:00
115b045505 rafthttp: add comment for timeout 2015-03-02 16:52:19 -08:00
24fbad7bd8 Merge pull request #2412 from xiang90/refactor-peer
rafhttp: refactor peer.go
2015-03-02 16:24:35 -08:00
88bde91716 rafhttp: refactor func peer.pick in peer.go 2015-03-02 15:17:14 -08:00
81c67eed9c rafthttp: add functional tests 2015-03-02 14:22:20 -08:00
4dd3be0f05 Merge pull request #2401 from yichengq/331
rafthttp: add unit tests and SendMsgApp benchmark
2015-03-02 13:55:16 -08:00
fc2d7019e5 rafthttp: {nopProcessor, errProcessor} -> fakeRaft 2015-03-02 13:31:56 -08:00
ee8325d62c test: not run race test on rafthttp pkg 2015-03-02 13:30:34 -08:00
f59b60671e rafthttp: add peer tests 2015-03-02 13:30:30 -08:00
45d6b76eea rafthttp: add stream tests 2015-03-02 13:29:05 -08:00
8ec28f27d1 rafthttp: streamReader roundtrip -> dial 2015-03-02 13:26:48 -08:00
a299f68e09 rafthttp: add transport benchmark test 2015-03-02 13:25:32 -08:00
9d445d2fcf rafthttp: add transport tests 2015-03-02 13:25:30 -08:00
399e3cdf81 rafthttp: add stream http tests 2015-03-02 13:24:50 -08:00
31666cdbff Merge pull request #2408 from yichengq/335
rafthttp: report MsgSnap status
2015-03-02 09:43:08 -08:00
b4b9b9118a rafthttp: report MsgSnap status 2015-03-02 09:38:11 -08:00
78aa251ab2 rafthttp: only use pipeline to send MsgSnap
The size of MsgSnap may be very big, e.g., 1G.
If its size is big and general streaming is used to send it, it may block
the following messages for several ten seconds, which interrupts the
heartbeat heavily.
Only use pipeline to send MsgSnap.
2015-03-02 09:35:54 -08:00
9989bf1d36 Merge pull request #2407 from yichengq/334
rafthttp: report unreachable status of the peer
2015-03-02 09:35:35 -08:00
dcd125e7a6 Merge pull request #2382 from philips/add-faq
Documentation: add implementation faq
2015-03-01 20:24:50 -08:00
9b986fb4c1 rafthttp: report unreachable status of the peer
When it failed to send message to the remote peer, it reports unreachable
to raft.
2015-03-01 16:48:26 -08:00
09f181f585 raft: log unreachable remote node 2015-03-01 16:47:49 -08:00
dfa625407f Merge pull request #2400 from xiang90/rm_acl
acl: remove acl pkg
2015-03-01 15:28:58 -08:00
199c1eaab6 Merge pull request #2403 from xiang90/keep_entries
etcdserver: keep a min number of entries in memory
2015-03-01 10:18:21 -08:00
428b77afc3 etcdserver: keep a min number of entries in memory
Do not aggressively compact raft log entries. After a snapshot,
etcd server can compact the raft log upto snapshot index. etcd server
compacts to an index smaller than snapshot to keep some entries in memory.
The leader can still read out the in memory entries to send to a slightly
slow follower. If all the entries are compacted, the leader will send the
whole snapshot or read entries from disk if possible.
2015-03-01 10:12:13 -08:00
a4018f25c9 Merge pull request #2405 from mikael84/patch-1
Documentation: fix "Missing infra1="
2015-02-28 21:48:01 -08:00
22c8d781ef Documentation: fix "Missing infra1="
Documentation: fix "Missing infra1="
2015-03-01 09:44:25 +04:00
6d81009b26 acl: remove acl pkg 2015-02-28 15:02:47 -08:00
fbd5c81139 raft: remove shadowing of variables from test 2015-02-28 12:09:33 -08:00
d459ae0df3 store: remove unused ACL field 2015-02-28 11:46:21 -08:00
a4dab7ad75 *: do not block etcdserver when encoding store into json
Encoding store into json snapshot has quite high CPU cost. And it
will block for a while. This commit makes the encoding process non-
blocking by running it in another go-routine.
2015-02-28 11:41:58 -08:00
9b4d52ee73 raft: do not resend snapshot if not necessary
raft relies on the link layer to report the status of the sent snapshot.
If the snapshot is still sending, the replication to that remote peer will
be paused. If the snapshot finish sending, the replication will begin
optimistically after electionTimeout. If the snapshot fails, raft will
try to resend it.
2015-02-28 11:41:58 -08:00
2185ac5ac8 raft: cleanup unreachable 2015-02-28 11:35:16 -08:00
eeaf12beb1 rafthttp: use /raft/stream for MsgApp stream
New rafthttp uses /raft/stream/msgapp for MsgApp stream, but v2.0 rafthttp
cannot understand it. Use the old endpoint /raft/stream instead for backward
compatibility, and plan to move to new endpoint in the version after the
next one.
2015-02-28 11:35:16 -08:00
758ff26dd8 rafthttp: add copyright header 2015-02-28 11:35:16 -08:00
1fdbbb959f rafthttp: add util, msgapp, message test 2015-02-28 11:35:16 -08:00
dee3001086 rafthttp: add back tests that commentted out 2015-02-28 11:35:16 -08:00
87e3de8b8b integration: fix decrease cluster tests 2015-02-28 11:35:16 -08:00
1c5a507761 rafthttp: refactor peer and add general stream 2015-02-28 11:35:16 -08:00
2c94e2d771 *: make dial timeout configurable
Dial timeout is set shorter because
1. etcd is supposed to work in good environment, and the new value is long
enough
2. shorter dial timeout makes dial fail faster, which is good for
performance
2015-02-28 11:18:59 -08:00
55cd03ff4b rafthttp: add run loop for peer 2015-02-28 11:18:59 -08:00
86429264fb wal: support auto-cut in wal
WAL should control the cut logic itself. We want to do falloc to
per allocate the space for a segmented wal file at the beginning
and cut it when it size reaches the limit.
2015-02-28 11:18:59 -08:00
c3d3ad931b snap: add save latency metrics 2015-02-28 11:16:42 -08:00
95bba154d6 etcdserver: add propose summary 2015-02-28 11:16:42 -08:00
83c953b153 etcdhttp: move /stats to /debug/vars 2015-02-28 11:16:42 -08:00
a776064a8b etcdmain: fix godeps on osx 2015-02-28 11:16:41 -08:00
7bf615aee0 *: drop old metrics pkg 2015-02-28 11:16:41 -08:00
84485643fe *: expose wal metrics at /metrics 2015-02-28 11:06:11 -08:00
fb1a28c65d *: vendor prometheus 2015-02-28 11:06:11 -08:00
d8a9e11e22 rafthttp: extract pipeline from peer 2015-02-28 11:06:11 -08:00
2af33fd494 raft: add reportUnreachable 2015-02-28 10:45:22 -08:00
ba7215d7a8 acl: initial interface 2015-02-28 10:45:22 -08:00
9fe78c8bc4 client: don't use nested actions 2015-02-28 10:45:21 -08:00
25cf916a80 client: ensure Response closed on cancel 2015-02-28 10:45:21 -08:00
b41d6bc416 client: set hard limit on redirect checks 2015-02-28 10:45:21 -08:00
50a9b2d9c8 client: rm naked return from httpClusterClient.Do 2015-02-28 10:45:21 -08:00
99aa0e1fcc client: test httpClusterClient.reset failure cases 2015-02-28 10:45:21 -08:00
ed173a2a76 client: fix bad URL fixture 2015-02-28 10:45:21 -08:00
cd777b2966 client: test httpClusterClient.Sync 2015-02-28 10:45:21 -08:00
ae062a0825 client: move lock so MembersAPI.List doesn't deadlock 2015-02-28 10:45:21 -08:00
83930ac113 client: test DefaultCheckRedirect 2015-02-28 10:45:21 -08:00
943c7ef307 client: test httpKeysAPI's Create and Update methods 2015-02-28 10:45:21 -08:00
115e758c32 client: test httpKeysAPI.Delete 2015-02-28 10:45:21 -08:00
ece03fb987 client: drop unnecessary field deleteAction.Value 2015-02-28 10:45:21 -08:00
6fc209e574 client: test httpKeysAPI.Get 2015-02-28 10:45:21 -08:00
32bfcca5a8 client: test httpKeysAPI.Set 2015-02-28 10:45:20 -08:00
14b3f96091 client: test httpKeysAPI.Watcher 2015-02-28 10:45:20 -08:00
cd85451971 client: clarify relationship of AfterIndex and waitIndex 2015-02-28 10:45:20 -08:00
09017af35e client: test httpWatcher 2015-02-28 10:38:47 -08:00
11a6cb68a6 client: test unmarshaling of failure responses 2015-02-28 10:38:47 -08:00
9378413283 client: exhaustive member-related testing 2015-02-28 10:38:47 -08:00
32ff3ce26f client: test for non-integer X-Etcd-Index 2015-02-28 10:38:47 -08:00
8a6b72b08d client: tweak test fields 2015-02-28 10:38:47 -08:00
b174732812 client: introduce Error type 2015-02-28 10:38:47 -08:00
8fdc6b154e client: document PrevExistType 2015-02-28 10:38:47 -08:00
39b5b083c0 client: document Member fields 2015-02-28 10:38:47 -08:00
27de5eec76 client: document Response and Node structs 2015-02-28 10:38:47 -08:00
4a77760f56 client: break dependency on httptypes pkg 2015-02-28 10:38:46 -08:00
9b334e07a6 client: allow caller to decide HTTP redirect policy 2015-02-28 10:38:46 -08:00
1c03df62a5 client: WaitIndex -> AfterIndex 2015-02-28 10:38:46 -08:00
a834f297f9 client: document KeysAPI methods 2015-02-28 10:22:52 -08:00
2b5589ddcd client: encourage error handling in package doc 2015-02-28 10:22:52 -08:00
6fd105d554 client: document using a custom context 2015-02-28 10:22:52 -08:00
479a17dcbf client: add GetOptions.Sort 2015-02-28 10:22:52 -08:00
84ede6fbec client: use options struct for KeysAPI.Get 2015-02-28 10:22:52 -08:00
8621caf3e2 client: define a DefaultTransport 2015-02-28 10:22:52 -08:00
ce4486ff85 client: document Client methods 2015-02-28 10:22:52 -08:00
1773d0a18b client: simplify CancelableTransport doc 2015-02-28 10:22:52 -08:00
19dd4a0f3c client: document Config 2015-02-28 10:22:52 -08:00
6d82472275 client: move http.go into client.go 2015-02-28 10:22:52 -08:00
bfbf672ce4 client: document MembersAPI methods 2015-02-28 10:22:52 -08:00
7255fb1b62 client: alias etcdserver/etcdhttp/httptypes.Member 2015-02-28 10:22:52 -08:00
932351a00d client: document Watcher.Next 2015-02-28 10:22:52 -08:00
aee95468ba client: document MembersAPI/KeysAPI constructors 2015-02-28 10:22:51 -08:00
e885c6c5f4 client: document *Options 2015-02-28 10:22:51 -08:00
88cea415a7 client: NewDiscoveryKeysAPI -> NewKeysAPIWithPrefix 2015-02-28 10:22:51 -08:00
89070fd237 client: package-level doc 2015-02-28 10:22:51 -08:00
3d4e1f59dc client: drop unnecessary Nodes type 2015-02-28 10:22:51 -08:00
7ff84351f5 client: centralize exported variables 2015-02-28 10:22:51 -08:00
a9f605e5fe client: unexport defaultV2MembersPrefix 2015-02-28 10:22:51 -08:00
bb9f016b91 client: unexport defaultV2KeysPrefix 2015-02-28 10:22:51 -08:00
3fdda06602 client: s/SyncableHTTPClient/Client/g 2015-02-28 10:22:51 -08:00
bac1d2f420 client: unexport httpClient interface 2015-02-28 10:22:51 -08:00
52288fa748 client: remove CancelableTransport arg from httpClientFactory 2015-02-28 10:22:51 -08:00
3b41b77cd7 client: ClientConfig -> Config 2015-02-28 10:22:51 -08:00
2aecbaf165 client: unexport httpAction 2015-02-28 10:22:51 -08:00
3f5e827e3c client: httpClient -> simpleHTTPClient 2015-02-28 10:22:51 -08:00
f037cb9f65 client: collapse unnecessary constructor 2015-02-28 10:22:50 -08:00
62054dfb5e client: don't cache httpClients in httpClusterClient 2015-02-28 10:22:50 -08:00
99d63eb62e client: protect httpClusterClient with RWMutex 2015-02-28 10:22:50 -08:00
0943831b8e client: establish httpClusterClient.reset 2015-02-28 10:22:50 -08:00
74fe28c5e0 client: exchange ClientConfig for SyncableHTTPClient 2015-02-28 10:22:50 -08:00
942f0f6b9e client: accept TTL through KeysAPI.Set 2015-02-28 10:22:50 -08:00
3d53e9bfaa client: pass around options as pointers 2015-02-28 10:22:50 -08:00
0a7e0875d5 client: copy DeleteOptions onto deleteAction 2015-02-28 10:19:05 -08:00
025ee0379c client: copy SetOptions onto setAction 2015-02-28 10:19:05 -08:00
01fc01ec69 client: KeysAPI.[R]Watch -> Watcher w/ opts struct 2015-02-28 10:19:04 -08:00
bc32060b1d client: support PrevIndex in SetOptions & DeleteOptions 2015-02-28 10:14:25 -08:00
7ccf5eb476 client: support PrevValue in SetOptions & DeleteOptions 2015-02-28 10:14:25 -08:00
0f31f403d1 client: add KeysAPI.Delete 2015-02-28 10:14:25 -08:00
2f479c8721 client: assert method in tests 2015-02-28 10:14:25 -08:00
84e495e51e client: s/assertResponse/assertRequest/ 2015-02-28 10:14:25 -08:00
6e637f2f75 client: add KeysAPI.Set 2015-02-28 10:14:25 -08:00
8b3d05f661 client: add KeysAPI.RGet 2015-02-28 10:14:25 -08:00
6d89e6217d client: rename KeysAPI.RecursiveWatch to RWatch 2015-02-28 10:14:25 -08:00
4e5c015fe9 client: add Update method 2015-02-28 10:14:25 -08:00
c6d955f4c1 client: drive Create with setAction; drop TTL 2015-02-28 10:12:35 -08:00
99840c9697 *: cleanup import 2015-02-28 10:12:35 -08:00
9e63b1fb63 wal: record metrics 2015-02-28 10:12:35 -08:00
2e078582f9 etcdmain: expose runtime metrics 2015-02-28 10:11:53 -08:00
9b6fcfffb6 *: replace our own metrics with codahale/metrics 2015-02-28 10:11:53 -08:00
33afbfead6 etcdserver: remove the dep on metrics. first step towards removing metrics pkg from etcd. 2015-02-28 10:09:55 -08:00
feaabde125 Godeps: bump golang.org/x/net/context to b8c11bbe 2015-02-28 10:09:55 -08:00
cbef6ab152 raft: clean up storage 2015-02-28 10:09:07 -08:00
8fb6eb6c70 Update libraries-and-tools.md
Added a distributed r/w lock in addition to the master election implementation.
2015-02-28 10:09:07 -08:00
5ede18be74 raft: separate compact and createsnap in memory storage 2015-02-28 10:08:30 -08:00
cea3448438 *: bump to v2.0.4+git 2015-02-27 12:25:50 -08:00
1a2c6d3f2f *: bump to v2.0.4 2015-02-26 22:01:24 -08:00
53fda9d558 Documentation: add implementation faq
Add some notes on the design discussion around the `--initial` flags. If
anything is wrong let me know.
2015-02-26 09:52:45 -08:00
ecf7c27697 Merge pull request #2374 from wellbehavedsoftware/fix-2373
etcdtcl: fix etcdctl cluster-health ignores SSL settings
2015-02-25 07:44:10 -08:00
05ecdbc617 etcdtcl: fix etcdctl cluster-health ignores SSL settings
etcdctl reconnects to the leader, but was not picking up ssl settings in this
case, which causes it to show unhealthy when this is not the case.

Fixes #2373
2015-02-25 13:19:07 +01:00
6648b7e302 Merge pull request #2363 from yichengq/329
migrate/starter: fix v2 data dir checking
2015-02-24 22:44:10 -08:00
194105e02c Merge pull request #2369 from jonsyu1/master
Documentation fixes for proxy
2015-02-24 21:39:20 -08:00
31bfffaa48 Documentation: standardize on url over URL
url and URL both appear in this doc. Choose url due to higher frequency
2015-02-24 16:26:27 -05:00
1fbaf9dbb7 Documentation: fix discovery flag for proxy docs
It seems that the -discovery flag used to be -discovery-url. Updated this to use
the currently documented and supported -discovery flag.
2015-02-24 16:25:18 -05:00
3fd9136740 migrate/starter: fix v2 data dir checking 2015-02-24 11:47:56 -08:00
a560c52815 Merge pull request #2354 from xiang90/wait_time
pkg/wait: add WaitTime
2015-02-23 14:29:39 -08:00
53d20a8a29 pkg/wait: add WaitTime
WaitTime waits on deadline instead of id.
2015-02-23 14:26:42 -08:00
4b72095bd3 Merge pull request #2350 from jonsyu1/master
Fixed sample command flags in proxy docs
2015-02-23 09:19:15 -08:00
28e150e50e Documentation: fix sample command flags for proxy
The docs mention the listen-client-urls flag, but the examples use
client-listen-urls, which is an invalid flag.
2015-02-23 11:15:42 -05:00
4d0472029a Merge pull request #2348 from yichengq/326
etcdserver: fix cluster fallback recovery
2015-02-21 12:16:08 -08:00
e54fdfd9cc Merge pull request #2349 from yichengq/327
rafthttp: fix panic on receiving empty ents
2015-02-20 15:15:43 -08:00
ca390560f9 rafthttp: fix panic on receiving empty ents
2.0 rc may send empty ents. Fix it for backward compatibility.
2015-02-20 15:07:27 -08:00
cff005777a etcdserver: fix cluster fallback recovery
Cluster and transport may recover to old states when new node joins
the cluster. Record cluster last modified index to avoid this.
2015-02-20 14:30:00 -08:00
d57e07dcde Merge pull request #2347 from bdarnell/fix-nyet-test
Fix test for existence of go-nyet.
2015-02-20 14:07:55 -05:00
79bc3f4774 Fix test for existence of go-nyet.
When the file is not found, `which` returns an empty string,
which passes the -f test. `command -v` is the most portable alternative
to `which` per
http://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script/677212#677212
2015-02-20 14:02:43 -05:00
d2b0dd2419 Merge pull request #2345 from bdarnell/normal-entry-formatter
Only use the EntryFormatter for normal entries.
2015-02-20 11:00:12 -08:00
b53dc0826e Only use the EntryFormatter for normal entries.
ConfChange entries also have a Data field but the application-supplied
formatter won't know what to do with them.
2015-02-20 13:51:14 -05:00
0ea2173a7e Merge pull request #2343 from xiang90/fix_kill
osutil: pid 1 should exit directly instead of trying to kill itself
2015-02-20 09:01:49 -08:00
7ae94f2bf0 osutil: pid 1 should exit directly instead of trying to kill itself 2015-02-19 20:27:50 -08:00
4228c703a7 Merge pull request #2341 from yichengq/326
migrate/starter: fix flag parsing
2015-02-19 11:02:07 -08:00
10629c40e1 migrate/starter: fix flag parsing 2015-02-18 23:47:52 -08:00
e2928cd97a Merge pull request #2242 from barakmich/acl_doc
docs: Add v2 ACL RFC
2015-02-18 23:31:26 -08:00
40365c4f8d docs: add Security RFC
docs: Add v2 ACL RFC

Add workflow, fix terminology, make the API JSON, and general cleanup

fixes from xiang90s comments

add permissions struct

update regarding glob matches

rename file
2015-02-18 14:34:00 -05:00
88994f9ec8 Merge pull request #2335 from xiang90/dump-tool
tool: dump tool supports index
2015-02-18 09:35:49 -08:00
d6f8a30f7c tool: dump tool supports index 2015-02-18 09:13:47 -08:00
7c65857283 Merge pull request #2327 from barakmich/remove_shadowing
*: remove shadowing of variables from etcd and add travis test
2015-02-17 17:46:41 -05:00
92dca0af0f *: remove shadowing of variables from etcd and add travis test
We've been bitten by this enough times that I wrote a tool so that
it never happens again.
2015-02-17 16:31:42 -05:00
0a5707420b Merge pull request #2326 from yichengq/325
migrate/functional: fix `go build` failure
2015-02-17 10:46:39 -08:00
90b06f874d migrate/functional: fix go build failure 2015-02-17 10:35:30 -08:00
66199afb25 Merge pull request #2322 from kelseyhightower/add-etcd-docker-guide
doc: add etcd docker guide
2015-02-16 12:43:17 -08:00
217a1f0730 doc: add etcd docker guide
Fixes #2253
2015-02-16 11:44:41 -08:00
def62071f0 Merge pull request #2320 from xiang90/fix_error
etcdserver: fix error message when valide the discovery cluster
2015-02-16 09:53:24 -08:00
beb44ef6ba etcdserver: fix error message when valide the discovery cluster 2015-02-16 09:53:01 -08:00
d1ed54b734 Merge pull request #2317 from zhangbaitong/master
docs:small fix
2015-02-16 08:28:37 -08:00
518eb9fa2f docs:small fix
Signed-off-by: zhangbaitong <zhangbaitong@163.com>
2015-02-16 17:54:24 +08:00
73e67628d9 Merge pull request #2313 from xiang90/cluster_mu
etcdserver: move the mutex before what it guards
2015-02-14 23:05:53 -08:00
04bd06d20b etcdserver: move the mutex before what it guards 2015-02-14 22:26:12 -08:00
29f05bb217 Merge pull request #2307 from xiang90/refactor_cluster
etcdserver: getOtherPeerURLs -> getRemotePeerURLs
2015-02-14 20:59:38 -08:00
c5ca1218f3 etcdserver: GetClusterFromPeers -> GetClusterFromRemotePeers 2015-02-13 19:05:29 -08:00
f7540912d6 etcdserver: getOtherPeerURLs -> getRemotePeerURLs 2015-02-13 18:56:45 -08:00
0fcbadc10b Merge pull request #2305 from xiang90/fix_win
osutil: fix win build
2015-02-13 16:39:07 -08:00
e44dc0f3fe osutil: fix win build 2015-02-13 16:33:39 -08:00
4d728cc8c4 *: bump to v2.0.3 2015-02-13 15:27:24 -08:00
f7998bb2db Merge pull request #2304 from xiang90/fix_discovery_validation
etcdserver: validate discovery cluster
2015-02-13 14:41:09 -08:00
cfa7ab6074 etcdserver: validate discovery cluster 2015-02-13 14:32:24 -08:00
b59390c9c3 Merge pull request #2293 from barakmich/etcd_underscore
migrate: stop deleting _etcd
2015-02-13 17:10:14 -05:00
fdebf2b109 fix parent references 2015-02-13 16:54:15 -05:00
e9f4be498d migrate: decrease memory usage (only duplicate machines) 2015-02-13 15:26:54 -05:00
6d9d7b4497 Merge pull request #2302 from xiang90/fix_travis
integration: wait for slow travis
2015-02-13 11:49:37 -08:00
163ea3f5c5 integration: wait for slow travis 2015-02-13 11:41:03 -08:00
ea1e54b2a1 Merge pull request #2291 from ArtfulCoder/master
Added go build flag '-installsuffix cgo' to create a static library for etcd and etcdctl
2015-02-13 11:23:03 -08:00
b31109cfd7 Merge pull request #2290 from xiang90/fix_transport
etcdserver: recover transport when recovering from a snapshot
2015-02-13 10:23:29 -08:00
7a909c3950 Merge pull request #2282 from matishsiao/patch-1
add etcd-console tool to tools list
2015-02-13 10:20:31 -08:00
c16cc3a6a3 etcdserver: recover transport when recovering from a snapshot 2015-02-13 10:16:28 -08:00
d7840b75c3 Merge pull request #2301 from xiang90/fix_snap
integration: fix test
2015-02-13 10:03:45 -08:00
aed2c82e44 integration: fix test 2015-02-13 10:02:42 -08:00
39ee85470f Merge pull request #2300 from xiang90/fix_snap
etcdserver: fix snapshot
2015-02-13 09:56:19 -08:00
fbc4c8efb5 etcdserver: fix snapshot 2015-02-13 09:54:25 -08:00
12999ba083 Merge pull request #2298 from barakmich/issue2295
etcdserver: Unmask the snapshotter. Fixes #2295
2015-02-13 09:38:58 -08:00
a0e3bc9cbd etcdserver: Unmask the snapshotter. Fixes #2295 2015-02-13 11:56:00 -05:00
b06e43b803 Merge pull request #2289 from fabxc/feature/graceful_shutdown
main: shutdown gracefully.
2015-02-13 07:34:07 -08:00
8bf795dc3c etcdmain/osutil: shutdown gracefully, interrupt handling
The functionality in pkg/osutil ensures that all interrupt handlers finish
and the process kills itself with the proper signal.
Test for interrupt handling added.
The server shutsdown gracefully by stopping on interrupt (Issue #2277.)
2015-02-13 10:28:53 +01:00
02c52f175f migrate: stop deleting etcd 2015-02-12 19:35:33 -05:00
daf1a913bb Merge pull request #2287 from Amit-PivotalLabs/master
rafthttp/transport.go: Fix nil pointer dereference in RemovePeer
2015-02-12 14:49:12 -08:00
317e57a8a8 rafthttp: Panic informatively when removing unknown peer ID 2015-02-12 14:43:44 -08:00
5c0d3889f8 Added go build flag '-installsuffix cgo' to create a static library. This is needed when go 1.4 is used to build. 2015-02-12 14:08:02 -08:00
a71184424a *: bump to v2.0.2+git 2015-02-12 11:41:48 -08:00
409daceb73 *: bump to v2.0.2 2015-02-12 11:14:50 -08:00
c6cc276ef0 Merge pull request #2286 from barakmich/fix_migrations
etcdserver: Canonicalize migrations
2015-02-12 12:53:33 -05:00
cd50f0e058 etcdserver: Create MemberDir() and base {Snap,WAL}Dir() thereon. Audit DataDir. 2015-02-12 12:45:19 -05:00
fade9b6065 etcdserver: Refactor 2.0.1 directory rename into a proper migration
fix all instances

fix detection test
2015-02-12 11:53:19 -05:00
590205b8c0 Merge pull request #2284 from xiang90/cleanup
Cleanup
2015-02-11 16:21:10 -08:00
163f0f09f6 etcdserver: cleanup cluster_util 2015-02-11 16:20:38 -08:00
20497f1f85 etcdserver: move remote cluster retrive to cluster_util.go 2015-02-11 14:03:14 -08:00
4a0887ef7a Merge pull request #2283 from xiang90/etcd-dump
etcd dump
2015-02-11 11:24:05 -08:00
161b1d2e2e tools: etcd-dump-logs tool support dump from a given snapshot file 2015-02-11 10:50:04 -08:00
71bed48916 snap: add Read function 2015-02-11 10:21:19 -08:00
fe1d9565c2 *: bump to 2.0.1 2015-02-10 20:19:35 -08:00
fd90ec6c26 add etcd-console tool to tools list
i add etcd-console tool to tools list for reference
2015-02-11 10:43:21 +08:00
a81e147d8f Merge pull request #2281 from robszumski/docs-migrate
docs: add diagram and restructure for clarity
2015-02-10 17:45:24 -08:00
24b953a55d docs: add diagram and restructure for clarity 2015-02-10 17:34:23 -08:00
54bef0d2cd Merge pull request #2233 from yichengq/315
docs: add allow_legacy_mode.md
2015-02-10 15:46:52 -08:00
d0677a24dd docs: add allow_legacy_mode.md 2015-02-10 15:46:26 -08:00
bdc8cc1f54 Merge pull request #2278 from xiang90/ctl
etcdctl: add default peerurl for upgrade subcmd
2015-02-10 15:35:04 -08:00
b036c384a5 Merge pull request #2280 from gabesullice/typo-fix
documentation: fix typo in Documentation/clustering.md
2015-02-10 15:24:17 -08:00
df2a689d1c documentation: fix typo in Documentation/clustering.md
just an extra space needed to be removed.

Fixes #2279
2015-02-10 16:18:51 -07:00
f97a263a95 etcdctl: add default peerurl for upgrade subcmd 2015-02-10 15:13:12 -08:00
96ea0ff45c Merge pull request #2274 from xiang90/fix_stats
rafthttp: remove follower from leaderstats when it is removed from the c...
2015-02-10 11:27:29 -08:00
58112c4d2d rafthttp: remove follower from leaderstats when it is removed from the cluster 2015-02-10 11:22:33 -08:00
d74e74d320 Merge pull request #2261 from yichengq/322
migrate: fix setting commit index from snapshot
2015-02-10 09:57:24 -08:00
9834875d35 Merge pull request #2271 from yichengq/323
etcdmain: infer bind addr from addr in v1 flagset
2015-02-10 09:53:37 -08:00
9460b6efda Merge pull request #2267 from xiang90/fix_snapconf
etcdserver: save confstate when apply new snapshot
2015-02-10 09:44:10 -08:00
57dd8c18cc etcdmain: infer bind addr from addr in v1 flagset 2015-02-10 09:42:10 -08:00
9ec8ea47c8 Merge pull request #2272 from yichengq/324
rafthttp: not send 0-entry MsgApp using stream
2015-02-10 09:40:32 -08:00
6e1aecfc6f etcdserver: save confstate when apply new snapshot 2015-02-10 07:31:25 -08:00
96fde55a0f rafthttp: not send 0-entry MsgApp using stream
It is not sent out because it is useless to let remote raft step the
message.
Moreover, MsgApp stream reader can always assume that the length
of entries sent is > 0.
2015-02-10 00:02:22 -08:00
84dac75ed5 Merge pull request #2213 from yichengq/317
migrate/starter: fix --version output
2015-02-09 23:18:35 -08:00
1481ef9a5e Merge pull request #2264 from xiang90/pause
rafttest: support node pause
2015-02-09 18:54:56 -08:00
fa66055f66 rafttest: drop isPaused 2015-02-09 18:52:34 -08:00
085b608de9 rafttest: support node pause 2015-02-09 16:26:43 -08:00
3c9c4c4afa Merge pull request #2249 from xiang90/rttest
raftest: wait for network sending
2015-02-09 15:55:30 -08:00
279b216f9a raftest: wait for network sending 2015-02-09 15:52:16 -08:00
8788c74b48 Merge pull request #2263 from xiang90/cread
Documentation: document kv api change
2015-02-09 15:46:45 -08:00
8d663078bf Documentation: document kv api change 2015-02-09 15:35:15 -08:00
0242faa838 Merge pull request #2257 from yichengq/321
docs: fix stats response in api.md
2015-02-09 14:46:57 -08:00
9c850b7182 Merge pull request #2259 from xiang90/healthy
etcdctl: support healthy checking
2015-02-09 14:38:43 -08:00
db88d9764c migrate: fix setting commit index from snapshot 2015-02-09 14:38:38 -08:00
7bbdad9068 etcdctl: support healthy checking 2015-02-09 14:35:24 -08:00
af00536d71 Merge pull request #2252 from xiang90/raftdelay
rafttest: add network delay
2015-02-09 13:14:32 -08:00
c990099008 docs: fix stats response in api.md 2015-02-09 11:48:54 -08:00
65cd0051fe rafttest: add network delay 2015-02-06 15:01:07 -08:00
c94db98177 Merge pull request #2250 from xiang90/raftnt
rafttest: add network drop
2015-02-06 12:40:55 -08:00
d423946fa4 rafttest: add network drop 2015-02-06 10:50:55 -08:00
e2feafc741 Merge pull request #2241 from peterrosell/correct_defaults_in_tuning
Correct defaults for heartbeat and election
2015-02-06 07:41:47 -08:00
c8b5d47f24 Documentation: Correct defaults for heartbeat and election
Defaults for hearbeat-interval and election-timeout is updated according to configuration documentation.
2015-02-06 10:13:57 +01:00
d71be31e68 Merge pull request #2245 from xiang90/fix_store
store: fix modifiedindex in node clone
2015-02-05 22:42:07 -08:00
9776e6d082 store: fix modifiedindex in node clone 2015-02-05 22:26:52 -08:00
766e0ad901 Merge pull request #2236 from philips/remove-becomes
Small grammar fixes
2015-02-05 11:26:16 -08:00
a387e2a989 Merge pull request #2232 from yichengq/319
fix the problem of StoreKeysPrefix key in store
2015-02-05 07:58:49 -08:00
26dc5904a5 Merge pull request #2235 from yichengq/318
migrate/functional: add Upgrade TLS V1 cluster test
2015-02-04 21:56:42 -08:00
136e0b6e26 migrate/functional: add Upgrade TLS V1 cluster test 2015-02-04 21:49:42 -08:00
599e821309 etcdctl/upgrade: use peer flags for peer transport 2015-02-04 21:49:42 -08:00
1ce7f6e0d0 migrate/starter: fix --version output 2015-02-04 21:28:56 -08:00
860a8c8717 Documentation: grammar fixup in admin guide
Rephrase to avoid "becomes".
2015-02-04 21:28:43 -08:00
a4c4027dc7 rafthttp: becomes -> became in log line
Simple grammar fix.
2015-02-04 21:28:23 -08:00
3ac0298bd0 store: set readonly to pre-defined namespaces 2015-02-04 16:47:08 -08:00
f13c7872d5 etcdserver: register pre-defined namespaces in store 2015-02-04 16:33:40 -08:00
38038e476a Merge pull request #2230 from yichengq/315
pkg/osutil: add Unsetenv
2015-02-04 10:43:43 -08:00
871e92ef73 pkg/osutil: add Unsetenv
go1.4 doesn't support static link well, so we stay in go1.3 for a while.
Implement Unsetenv in go1.3 way.
2015-02-04 10:29:20 -08:00
58cb9a3b76 Merge pull request #2222 from yichengq/315
migrate/starter: unset discovery when setting initial-cluster
2015-02-03 23:27:43 -08:00
a0f8aa1add travis: use latest go tool repo 2015-02-03 23:23:02 -08:00
5c6ce0c18d travis: use go1.4 for new feature os.Unsetenv() 2015-02-03 23:11:08 -08:00
378fa46b7d Merge pull request #2224 from xiang90/raftt
rafttest: separate network interface and network
2015-02-03 23:11:01 -08:00
83edf0d862 rafttest: separate network interface and network 2015-02-03 22:50:27 -08:00
d0205519a8 migrate/starter: unset discovery when setting initial-cluster 2015-02-03 18:29:52 -08:00
fca9805f84 Merge pull request #2221 from yichengq/315
migrate/starter: fix default version dir
2015-02-03 14:57:27 -08:00
f109020b94 migrate/starter: fix default version dir 2015-02-03 14:56:26 -08:00
81d7eaf17f Merge pull request #2205 from yichengq/315
migrate: support standby mode upgrade
2015-02-03 11:07:49 -08:00
2d081bd3b9 migrate: support standby mode upgrade 2015-02-03 10:59:43 -08:00
f2f2adc663 migrate/functional: always run tests on CoreOS image 2015-02-03 10:59:43 -08:00
92b329fdb9 etcdmain: use symlink instead of link for v0.4 files
link doesn't support directory.
2015-02-03 10:59:43 -08:00
00eaf165a8 Merge pull request #2212 from xiang90/rt
raftest: add restart and related simple test
2015-02-03 10:15:23 -08:00
b147a6328d raftest: add restart and related simple test 2015-02-03 10:08:52 -08:00
afb14a3e7a Merge pull request #2210 from yichengq/316
etcdmain: use /member subdir to save member data
2015-02-02 17:06:30 -08:00
ce1d7a9fa9 etcdmain: use /member subdir to save member data 2015-02-02 17:01:19 -08:00
470be16c04 Merge pull request #2209 from xiang90/fix_proxy
etcd: fix proxy
2015-02-02 15:02:25 -08:00
fbabcedcc9 etcd: fix proxy
1. move proxy datadir to /proxy subdir.
2. delay update proxy's cluster after validation.
2015-02-02 14:58:45 -08:00
d16c5e1e81 Merge pull request #2203 from xiang90/raft_test
raft: add raft test suite
2015-02-01 14:57:09 -08:00
d65af21b73 raft: add raft test suite 2015-02-01 14:53:22 -08:00
bdcae31638 Merge pull request #2202 from xiang90/proxy
etcd: fix proxy updating
2015-01-30 17:00:07 -08:00
ae9f54c132 etcd: fix proxy updating 2015-01-30 16:56:41 -08:00
a3d0097908 Merge pull request #2201 from barakmich/member_suggestion
etcdctl: give more helpful suggestions on removal
2015-01-30 19:51:22 -05:00
37e8d608b3 add documentation link and describe the 404/500 errors better 2015-01-30 19:41:44 -05:00
c66176b538 etcdctl: give more helpful suggestions on removal 2015-01-30 19:23:19 -05:00
b6936a0079 docs: fix broken link 2015-01-30 15:37:26 -08:00
9961d5ca2b Merge pull request #2198 from xiang90/proxy
Proxy
2015-01-30 15:24:13 -08:00
dc7374c488 etcd: persist proxy cluster to disk 2015-01-30 15:18:26 -08:00
87a8ebd222 docs: expand description of -initial-cluster-state 2015-01-30 14:14:51 -08:00
27e5b9a394 docs: clarify reconfig options 2015-01-30 14:14:28 -08:00
f5afe3cc34 Fixed typo in API documentation. 2015-01-30 14:14:18 -08:00
3ee7a265f6 README: remove doozer and zookeeper mentions
doozer in particular is rather confusing to mention since the project
hasn't been worked on in years. While we are at it it might simplify
people's understanding if we remove zookeeper too.
2015-01-30 14:13:47 -08:00
d1f9f2f1b7 scripts: remove 2.0 Documentation from build-release
2.0 docs have been merged into the Documentation folder now.
2015-01-30 14:13:25 -08:00
894f1aadce Merge pull request #2199 from xiang90/coreos
mian: detects coreos
2015-01-30 12:10:23 -08:00
fce80136e3 main: detects coreos 2015-01-30 12:10:05 -08:00
ebf9daff74 Merge pull request #2190 from yichengq/308
migrate: support start desired version
2015-01-30 11:47:22 -08:00
ec5a6e8beb migrate: support start desired version 2015-01-30 00:35:53 -08:00
0945e487e7 docs: fix static clustering example
When using very similar flags to our examples, the cluster doesn't bootstrap due to mismatched protocols (`http` vs `https`) in the `-initial-advertise-peer-urls` and `initial-cluster` list:

```
./etcd -name infra0 -initial-advertise-peer-urls https://127.0.0.1:2380 \
>   -listen-peer-urls https://127.0.0.1:2380 \
>   -initial-cluster-token etcd-cluster-1 \
>   -initial-cluster infra0=http://127.0.0.1:2380,infra1=http://127.0.0.1:2381,infra2=http://127.0.0.1:2382 \
>   -initial-cluster-state new
2015/01/29 10:32:16 no data-dir provided, using default data-dir ./infra0.etcd
2015/01/29 10:32:16 etcd: listening for peers on https://127.0.0.1:2380
2015/01/29 10:32:16 etcd: listening for client requests on http://localhost:2379
2015/01/29 10:32:16 etcd: listening for client requests on http://localhost:4001
2015/01/29 10:32:16 etcd: stopping listening for client requests on http://localhost:4001
2015/01/29 10:32:16 etcd: stopping listening for client requests on http://localhost:2379
2015/01/29 10:32:16 etcd: stopping listening for peers on https://127.0.0.1:2380
2015/01/29 10:32:16 etcd: infra0 has different advertised URLs in the cluster and advertised peer URLs list
```
2015-01-29 13:44:13 -08:00
a65556abe2 Merge pull request #2189 from yichengq/314
support disaster recovery from rc1 data dir
2015-01-29 13:38:00 -08:00
e966e565c4 etcdctl/backup_command: handle datadir with missed snapshot mark
This helps to recover from the data dir created in v2.0.0-rc1.
2015-01-29 13:32:59 -08:00
7840d49ae0 etcdserver: not add self to transporter based on local ID
If this is decided by local name, it comes to trouble if the name is
duplicate in the cluster.
2015-01-29 12:35:47 -08:00
d0af96d558 etcdctl/backup_command: save snapshot mark in new wal 2015-01-29 12:35:39 -08:00
fd0c0c9263 Merge pull request #2185 from xiang90/fix_tls_keepalive
Fix tls keepalive
2015-01-29 10:36:11 -08:00
4960324876 pkg/transport: fix tlskeepalive 2015-01-29 09:42:48 -08:00
b606078e93 version: bump to 2.0.0 2015-01-27 23:08:58 -08:00
127fe322a4 Merge pull request #2172 from philips/README-updates
README: remove the etcd release candidate disclaimer
2015-01-27 23:04:09 -08:00
b377110c11 README: remove the etcd release candidate disclaimer
Remove the information about the v1 API since it has been removed.
Remove the disclaimer since we are no longer in release candidate mode.
2015-01-27 22:54:10 -08:00
7167cd6ccd Merge pull request #2149 from vdemedes/patch-1
Update README.md
2015-01-27 16:09:20 -08:00
bff2ccaa22 Merge pull request #2170 from xiang90/remove_log
raft: remove default verbose logging
2015-01-27 15:58:53 -08:00
553379e82b raft: remove default verbose logging 2015-01-27 15:57:44 -08:00
67d141a0af Merge pull request #2167 from bdarnell/send-after-response
raft: Send any waiting appends after receiving MsgAppResp.
2015-01-27 15:31:50 -08:00
0b2fde38d0 Merge pull request #2169 from philips/remove-CHANGELOG
CHANGELOG: remove unupdated changelog file
2015-01-27 15:03:47 -08:00
0c1329ace2 CHANGELOG: remove unupdated changelog file
We have been putting the changelog in the tags. Nuke this file.
2015-01-27 15:01:23 -08:00
43f1ccc88c version: bump to v2.0.0-rc.2 2015-01-27 14:48:30 -08:00
33d2400063 raft: Send any waiting appends after receiving MsgAppResp.
This addresses a problem that comes up in the cockroach tests,
in which the order of messages may lead to deadlocks (due to
the fact that we don't have regular heartbeat timers in most
of our tests).
2015-01-27 17:43:29 -05:00
4c33d12bf8 Merge pull request #2132 from xiang90/ctl
etcdctl: support upgrade
2015-01-27 14:18:16 -08:00
0f2582e0be Merge pull request #2042 from yichengq/279
docs: improve doc for server timeout
2015-01-27 14:12:42 -08:00
a03c906e9d docs: improve doc for server timeout 2015-01-27 14:12:27 -08:00
c530e6fc55 Merge pull request #2165 from yichengq/312
docs: fix details about 2.0
2015-01-27 13:53:20 -08:00
c5adff4988 docs: fix details about 2.0 2015-01-27 13:52:37 -08:00
91bd02dce1 Merge pull request #2161 from yichengq/311
migrate: set HardState.Term in migration
2015-01-27 13:59:26 -05:00
62b0fe50eb Merge pull request #2164 from barakmich/2160redux
migrate: convert 0.4 terms to start at 1
2015-01-27 13:59:20 -05:00
9eaa79a12a Merge pull request #2137 from jurmous/patch-2
Update libraries-and-tools.md
2015-01-27 10:54:49 -08:00
55c1635cee comment 2015-01-27 13:54:23 -05:00
7f91a35313 migrate: convert 0.4 terms to start at 1 2015-01-27 13:10:13 -05:00
517eb340dd migrate: set HardState.Term in migration 2015-01-26 23:41:21 -08:00
915c22292f Merge pull request #2140 from xiang90/raft_stats
etcdserver: support raft.status
2015-01-26 16:44:58 -08:00
276c9540b4 etcdserver: support raft.status 2015-01-26 16:39:33 -08:00
825107629a Merge pull request #2157 from yichengq/309
pkg/metrics: protect global vars in reset func
2015-01-26 16:24:00 -08:00
8c932ff719 pkg/metrics: protect global vars in reset func 2015-01-26 16:23:35 -08:00
f0c9a54edb Merge pull request #2156 from yichengq/309
pkg/metrics: self-manage global expvar map
2015-01-26 16:20:31 -08:00
08b34a3f5b pkg/metrics: self-manage global expvar map
This helps the embedded tests.
2015-01-26 16:20:09 -08:00
78f70137ea Merge pull request #2155 from yichengq/310
README: add doc about easy etcd cluster bootstrap
2015-01-26 15:47:21 -08:00
4c55e8a7c0 README: add doc about easy etcd cluster bootstrap 2015-01-26 15:41:56 -08:00
4427b889df Merge pull request #2151 from efrecon/tcl-binding-reference
Update libraries-and-tools.md
2015-01-26 14:33:02 -08:00
37f8e2d5e0 Merge pull request #2150 from sorah/master
Treat URLs have same IP address as same
2015-01-26 12:08:26 -08:00
f8ce5996b0 Treat URLs have same IP address as same
- To solve validation error problem using URLs in hostname #2123
2015-01-27 04:36:41 +09:00
9c7f66c5d9 Merge pull request #2119 from sorah/peer-ca-on-fetching-members
etcdserver: User peerTLSInfo to get cluster member
2015-01-26 10:50:44 -08:00
033e7d1db9 etcdserver: User peerTLSInfo to get cluster member 2015-01-27 03:43:21 +09:00
a6661201c5 Merge pull request #2148 from jonboulle/copyright
*: switch to line comments for copyright
2015-01-26 09:58:57 -08:00
f1ed69e883 *: switch to line comments for copyright
Build tags are not compatible with block comments.
Also adds copyright header to a few places it was missing.
2015-01-26 09:53:30 -08:00
200d4d6f41 Update libraries-and-tools.md
This documents a reference to the Tcl bindings for the etcd API.

Fixes #2127
2015-01-26 14:18:08 +01:00
f1dcefa834 docs: update etcd4j in libraries-and-tools 2015-01-26 11:34:02 +01:00
b2acb12c8e Update README.md
Example output of `$ etcdctl exec-watch` command was wrong and showing non-existing ETCD_VALUE, ETCD_KEY, etc keys. Submitting a PR, which updates those examples with correct keys (ETCD_WATCH_VALUE, ETCD_WATCH_KEY, etc).
2015-01-25 14:10:08 +01:00
93e4880ae6 Merge pull request #2135 from bcwaldon/test-int
test: do not run integration tests by default
2015-01-23 11:44:46 -08:00
d5f6b97b20 test: do not run integration tests by default
The ./test script will no longer run the integration tests. To run the
integration test, set the INTEGRATION env var to a nonzero value. For
example, `INTEGRATION=y ./test`.
2015-01-22 17:31:27 -08:00
6b304ce605 Merge pull request #2134 from bcwaldon/pkg-rename
pkg: ioutils -> ioutil
2015-01-22 17:30:36 -08:00
2120af8cfc pkg: ioutils -> ioutil 2015-01-22 17:14:01 -08:00
f16ff64949 Merge pull request #2131 from xiang90/version
etcdhttp: add internalVersion
2015-01-22 15:52:15 -08:00
c658e9a3e9 etcdctl: support upgrade 2015-01-22 15:51:45 -08:00
a77bf97c14 etcdhttp: add internalVersion 2015-01-22 15:42:16 -08:00
7d33a2686c Merge pull request #1990 from lemenkov/docs_proper_links
Proper links to the docs
2015-01-22 10:56:03 -08:00
e7d539e4ce Merge pull request #2128 from bdarnell/applied-restart
raft: Add applied index as an argument to newRaft and RestartNode.
2015-01-22 10:11:12 -08:00
8c3a6508e9 raft: Add applied to the newRaft log message. 2015-01-22 12:04:40 -05:00
59214978a2 raft: Add applied index as an argument to newRaft and RestartNode. 2015-01-22 11:38:05 -05:00
c2fa486920 Proper links to the docs
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
2015-01-22 14:02:11 +03:00
4409e88358 Merge pull request #2120 from bdarnell/formatter
raft: Add support for custom formatters in DescribeMessage/DescribeEntry
2015-01-21 16:32:59 -08:00
cd9d5573d4 raft: make EntryFormatter less clever. 2015-01-21 19:27:26 -05:00
891cb62b81 Merge pull request #2118 from yichengq/308
metrics: add /rafthttp/stream metrics
2015-01-21 15:30:30 -08:00
99821579bf metrics: add /rafthttp/stream metrics 2015-01-21 13:24:21 -08:00
e73d442e32 raft: Add support for custom formatters in DescribeMessage/DescribeEntry 2015-01-21 14:12:58 -05:00
88704c70e7 Merge pull request #2116 from yichengq/307
store: optimize ttlKeyHeap GC
2015-01-20 12:09:30 -08:00
c104ca89c2 store: optimize ttlKeyHeap GC
It helps to recycle nodes in heap array, whose value can be unlimited
long.
2015-01-20 12:01:57 -08:00
7c7d78a11f Merge pull request #2004 from xiang90/status
raft: add Status interface
2015-01-20 10:51:33 -08:00
003b97a60f raft: public progress struct in raft 2015-01-20 10:26:22 -08:00
b34936b097 raft: add progress into status 2015-01-18 15:23:50 -08:00
0eaaad0e48 raft: add Status interface
Status returns the current status of raft state machine.
2015-01-16 14:02:04 -08:00
3ec91ead88 Merge pull request #2112 from xiang90/health
etcdhttp: add health endpoint
2015-01-16 10:57:36 -08:00
a97f331a0e etcdhttp: add health endpoint 2015-01-16 10:52:02 -08:00
4735324403 Merge pull request #2113 from yichengq/306
*: remove consistent-get related stuffs
2015-01-16 10:46:56 -08:00
37dde76cd5 *: remove consistent-get related stuffs 2015-01-15 22:21:53 -08:00
c36aa3be6e Merge pull request #2110 from xiang90/raft
etcdserver: separate out raft related stuff
2015-01-15 15:17:48 -08:00
973f79e1c9 etcdserver: separate out raft related stuff 2015-01-15 15:15:13 -08:00
4b6fa2d24f Merge pull request #2108 from yichengq/305
rafthttp: write StatusOK before start streaming
2015-01-15 14:58:52 -08:00
84ceefbffc rafthttp: write StatusOK before start streaming 2015-01-15 14:44:24 -08:00
1a6161d08a Merge pull request #2104 from xiang90/timeout
etcdserver: make heartbeat/election configurable
2015-01-15 13:52:20 -08:00
6bd8c435f9 Merge pull request #2107 from yichengq/304
integration: fix TestForceNewCluster to wait leader
2015-01-15 13:35:11 -08:00
b28bad3b4a Merge pull request #2106 from yichengq/303
docs: update errorcode.md
2015-01-15 13:28:39 -08:00
d380be8fa1 integration: fix TestForceNewCluster to wait leader 2015-01-15 13:27:24 -08:00
e8698b0e42 docs: update errorcode.md 2015-01-15 13:23:24 -08:00
295fa1ca99 error: deprecate unused error code 2015-01-15 11:49:41 -08:00
276a4abac0 etcdserver: make heartbeat/election configurable 2015-01-15 11:11:33 -08:00
e9235002f7 Merge pull request #2068 from yichengq/285
add tests in pkg/types package
2015-01-15 10:55:55 -08:00
ae7153bf38 Merge pull request #2103 from yichengq/302
integration: fix TestForceNewCluster
2015-01-15 10:48:08 -08:00
68fdd70580 integration: fix TestForceNewCluster 2015-01-15 10:42:57 -08:00
190fd446f9 pkg/types: add URLs tests 2015-01-15 10:24:23 -08:00
886a6a6194 pkg/types: add unsafeSet.ContainsAll test 2015-01-15 10:21:53 -08:00
9b4e72dd3a pkg/types: add Uint64Slice test 2015-01-15 10:21:53 -08:00
c4e4a9711f Merge pull request #2075 from endocode/alban/build-aci
scripts: update build-aci
2015-01-15 09:57:06 -08:00
cb1903ddcb Merge pull request #2101 from jonboulle/relver
scripts: remove old release version scripts
2015-01-15 08:42:06 -08:00
5568d590ef Merge pull request #2100 from jonboulle/docs
README: update to reflect doc changes
2015-01-15 08:41:50 -08:00
b0a4637ebd build: etcd statically linked
So that it can easily be used in a container.

Symptoms:
$ sudo bin/rkt run ../etcd/etcd-${VERSION}-linux-amd64.aci
Error: Unable to open "/lib64/ld-linux-x86-64.so.2": No such file or directory
2015-01-15 12:30:12 +01:00
78a7e0e551 scripts/build-aci: improve the script
- fix path for bash
- check for common errors
2015-01-15 12:30:12 +01:00
e41d1e2064 scripts: remove old release version scripts 2015-01-14 22:34:59 -08:00
28feb073b5 README: update to reflect doc changes 2015-01-14 22:17:29 -08:00
e109836fef Merge pull request #2094 from yichengq/298
docs: remove discovery-protocol
2015-01-14 17:29:25 -08:00
5e4cc73991 Merge pull request #2099 from yichengq/301
docs: use 2.0 docs
2015-01-14 17:29:15 -08:00
245e23ca47 docs: use 2.0 docs 2015-01-14 17:27:35 -08:00
6bda827b67 Merge pull request #2096 from yichengq/299
docs: optimal-cluster-size -> 2.0/admin_guide
2015-01-14 17:24:45 -08:00
f1c6771726 docs: optimal-cluster-size -> 2.0/admin_guide 2015-01-14 17:23:37 -08:00
1146cb9461 Merge pull request #2097 from xiang90/fix_force_test
integration: fix force cluster test
2015-01-14 16:46:20 -08:00
467ce1e730 Merge pull request #2098 from yichengq/300
docs: refine security.md
2015-01-14 16:45:40 -08:00
507021d884 docs: refine security.md 2015-01-14 16:42:05 -08:00
8e8552b2ad integration: fix force cluster test 2015-01-14 16:40:09 -08:00
2b94119fb1 docs: remove discovery-protocol
It is out-of-data, and will be reintroduced when the protocol is settled
down.
2015-01-14 15:20:48 -08:00
41a30ff21b Merge pull request #2092 from yichengq/296
docs: remove cluster-discovery
2015-01-14 15:19:12 -08:00
dde0e6d05a Merge pull request #2093 from yichengq/297
docs: remove unused img/
2015-01-14 15:18:52 -08:00
4df434334f docs: remove unused img/ 2015-01-14 15:17:57 -08:00
1d02493a53 docs: remove cluster-discovery
It is covered by 2.0/clustering.md
2015-01-14 15:14:58 -08:00
d117a12d02 Merge pull request #2091 from yichengq/295
docs: remove clients-matrix
2015-01-14 15:09:04 -08:00
23406dc2ee docs: remove clients-matrix
The doc is out of maintainence, and may confuse users. We will bring it
back when we have efforts and better method to manage client bindings.
2015-01-14 15:05:35 -08:00
e5daa2c6ca Merge pull request #2086 from xiang90/cluster_doc
doc: remove old clustering doc
2015-01-14 15:03:43 -08:00
5de4a464f7 Merge pull request #2089 from bdarnell/heartbeat-response
raft: introduce MsgHeartbeatResp.
2015-01-14 14:56:24 -08:00
2e1c36cdd9 raft: introduce MsgHeartbeatResp.
Now that heartbeats are distinct from MsgApp{,Resp}, the retries
currently performed in stepLeader's MsgAppResp section are only
performed on an actual MsgAppResp (or a new MsgProp). This means
that it may take a long time to recover from a dropped MsgAppResp
in a quiet cluster.

This commit adds a dedicated heartbeat response message. This message
does not convey the follower's current log position because the
MsgHeartbeat does not include the leaders term and index. Upon receipt
of a heartbeat response, the leader may retry the latest MsgApp if it
believes the follower to be behind.
2015-01-14 17:34:10 -05:00
238b17fee0 Merge pull request #2090 from bdarnell/raft-ticks
raft: Use <= instead of < for heartbeat ticks.
2015-01-14 13:01:33 -08:00
9972e62d94 raft: Use <= instead of < for heartbeat ticks.
In code outside the raft package, we cannot call raft.bcastHeartbeat
directly. Instead, to control heartbeats we set heartbeatInterval to 1
and call Tick().
2015-01-14 15:27:32 -05:00
232927d9dc Merge pull request #2088 from bdarnell/listen-localhost
pkg/transport: tests always listen on 127.0.0.1
2015-01-14 10:54:46 -08:00
4510993b67 pkg/transport: tests always listen on 127.0.0.1
This avoids firewall prompts when running tests on OSX.
2015-01-14 13:14:57 -05:00
8e6297780b Merge pull request #2087 from xiang90/doc_rm
doc: remove out-of-dated docs
2015-01-13 20:58:15 -08:00
3e268467c8 doc: remove out-of-dated docs 2015-01-13 18:35:11 -08:00
733b655bfa doc: remove old clustering doc 2015-01-13 18:26:48 -08:00
1b9ccfc66f Merge pull request #2084 from yichengq/294
integration: add TestForceNewCluster
2015-01-13 15:47:21 -08:00
a318112c7a integration: add TestForceNewCluster 2015-01-13 13:55:38 -08:00
89d95539cf Merge pull request #2083 from yichengq/293
*: move etcdserver/idutil -> pkg/idutil
2015-01-13 13:04:50 -08:00
07a69430c1 *: move etcdserver/idutil -> pkg/idutil 2015-01-13 11:54:51 -08:00
a83aba12f0 Merge pull request #2082 from yichengq/292
error: remove unused Message func
2015-01-13 11:11:04 -08:00
c212a511fe Merge pull request #2078 from yichengq/290
pkg/crc: add test
2015-01-13 11:10:51 -08:00
c68f5c2059 pkg/crc: add test 2015-01-13 11:07:18 -08:00
51005d32c7 Merge pull request #2079 from yichengq/291
pkg/cors: add tests
2015-01-13 11:05:02 -08:00
b9544d32b6 error: remove unused Message func 2015-01-13 10:40:06 -08:00
586a5e463e Merge pull request #2059 from trainchou/master
docs: fix send rate usage in api.md
2015-01-13 08:33:36 -08:00
42ae6e5f5b docs: fix send rate usage in api.md 2015-01-13 23:18:12 +08:00
c8994cff37 pkg/cors: add tests 2015-01-12 18:42:40 -08:00
0015372939 pkg/cors: remove http flush
The code is introduced in 7dce4c8fbb, and
the comments cannot explain the usefulness of the code at all.
2015-01-12 18:03:30 -08:00
2e776117f8 Merge pull request #2071 from yichengq/287
etcdhttp: add NewPeerHandler test
2015-01-12 15:59:37 -08:00
dc6aef0d02 etcdhttp: add NewPeerHandler test 2015-01-12 15:56:29 -08:00
9010e8a2c4 Merge pull request #2069 from yichengq/286
pkg/pbutil: add marshal-related tests
2015-01-12 15:32:18 -08:00
7e67fd13f6 pkg/pbutil: add marshal-related tests 2015-01-12 15:26:55 -08:00
e01ae2c083 Merge pull request #2073 from yichengq/288
etcdmain: add config tests
2015-01-12 13:39:34 -08:00
50395a53fb etcdmain: add license 2015-01-12 13:34:21 -08:00
60d6c34c28 etcdmain: add config tests 2015-01-12 13:34:16 -08:00
2d8f5e1250 Merge pull request #2074 from yichengq/289
make `go test ./...` work
2015-01-12 12:25:20 -08:00
e3b2f08bd0 migrate/cmd/etcd-dump-logs: fix building 2015-01-12 12:17:41 -08:00
aec2eef498 Merge pull request #2067 from yichengq/284
add tests in pkg/transport package
2015-01-10 13:13:23 -08:00
dfb66ab8ce pkg/transport: add NewKeepAliveListener test 2015-01-10 13:09:57 -08:00
f1368a00fb pkg/transport: add NewListener test 2015-01-10 13:09:13 -08:00
3577ed69a2 pkg/transport: add NewTimeoutTransport test 2015-01-10 13:03:15 -08:00
e688471c28 pkg/transport: add NewTimeoutListener test 2015-01-09 15:57:04 -08:00
5d99024fea Merge pull request #2066 from yichengq/283
add tests and do clean in wal package
2015-01-09 15:54:35 -08:00
05e591f805 wal: remove unused encoder.buffered func 2015-01-09 14:59:46 -08:00
9bdc343b7c wal: add ReleaseLockTo test 2015-01-09 14:59:41 -08:00
270e67db84 wal: not export unnecessary public functions 2015-01-09 14:55:10 -08:00
50c179ec1c wal: add DetectVersion test 2015-01-09 14:55:05 -08:00
f08d1090d0 wal: refine parseWalName function
According to http://godoc.org/fmt#Scan, if scan number is less than the
number of arguments, err will report why. So we don't need to handle
this error case.
2015-01-08 14:56:21 -08:00
9532810f76 wal: remove unused max function 2015-01-08 14:49:14 -08:00
92f013393c test: remove no-test directory etcdserverpb 2015-01-08 14:46:13 -08:00
096cbbcbf6 Merge pull request #2061 from endocode/alban/fix-build-aci
build-aci: change 'val' abbreviation to 'value'
2015-01-08 09:48:35 -08:00
fcbe7fdc83 Merge pull request #2062 from splattael/patch-1
Fix link to Documentation/2.0 in README
2015-01-08 08:16:10 -08:00
d225690b08 doc: fix link to documentation/2.0 in readme
[ci skip]
2015-01-08 17:14:44 +01:00
80c174255a build-aci: change 'val' abbreviation to 'value'
The spec changed, so etcd must be updated to follow the new spec:
12a9617c2f
2015-01-08 09:52:21 +01:00
bca1e5aea6 Merge pull request #2057 from yichengq/282
fix context time-out failure on travis
2015-01-07 13:41:26 -08:00
9132098960 integration: wait longer for member to be removed 2015-01-07 13:36:59 -08:00
930156c18a integration: adjust election ticks using env var 2015-01-07 11:18:29 -08:00
f98d0ef817 Merge pull request #2051 from xiang90/fix_keepalive
pkg/transport: enable keep alive
2015-01-07 08:37:07 -08:00
6b237416e1 Merge pull request #2044 from yichengq/278
wal: record mark when snapshotting
2015-01-07 08:26:33 -08:00
1d1a4754a7 pkg/transport: enable keep alive 2015-01-06 22:02:30 -08:00
6460e49a33 wal: save empty snapshot when create
So caller can open at empty snapshot to read all entries.
2015-01-06 19:48:21 -08:00
78bb207bac wal: update doc about snapshot 2015-01-06 19:33:57 -08:00
84f62f21ee wal: record and check snapshot 2015-01-06 16:27:40 -08:00
945c5dd558 Merge pull request #2049 from xiang90/fix_timeout
etcdmain: do not set timeout for client api
2015-01-06 16:26:06 -08:00
a15f39e6a2 etcdmain: do not set timeout for client api 2015-01-06 16:17:56 -08:00
02085153c9 Merge pull request #2046 from xiang90/keepalive
*: use keepalive listener to detect dead clients
2015-01-06 13:38:46 -08:00
7f1c630a0b *: use keepalive listener to detect dead clients 2015-01-06 12:09:34 -08:00
47113d776e Merge pull request #2045 from xiang90/read_timeout
etcdmain: add readtimeout for http server
2015-01-06 11:31:24 -08:00
0afbca4090 etcdmain: add readtimeout for http server 2015-01-06 11:04:38 -08:00
cbdb0266e9 Merge pull request #2043 from xiang90/leader_member
etcdhttp: support member/leader endpoint
2015-01-06 09:01:58 -08:00
1ebad5e42c etcdhttp: support member/leader endpoint 2015-01-06 08:52:33 -08:00
7a2fa39e52 Merge pull request #2012 from andybons/master
raft: add link to the paper raft_paper_test.go refers to
2015-01-06 00:27:47 -08:00
6d288fa9e9 Merge pull request #2041 from yichengq/277
docs: add doc for server timeout
2015-01-05 15:27:02 -08:00
88a9eedf06 docs: add doc for server timeout 2015-01-05 15:23:22 -08:00
0c55cfb21e Merge pull request #2036 from xiang90/trtr
refactor rafthttp
2015-01-05 14:08:51 -08:00
1aa8f1eee6 rafthttp: clean up reader when failed 2015-01-05 12:04:25 -08:00
6b8667152b Merge pull request #2035 from xiang90/errorc
etcdserver: collect error from errorc
2015-01-05 11:29:01 -08:00
8ac184ad52 Merge pull request #2037 from xiang90/doc_watch
Doc watch
2015-01-05 11:26:12 -08:00
d4a145ab0d doc: add note for watch api 2015-01-05 11:04:01 -08:00
66d9f28926 Merge pull request #2027 from yichengq/273
integration: extend timeout to wait
2015-01-05 08:33:35 -08:00
cb5bff5b05 Merge pull request #2034 from yichengq/276
etcdhttp: reset serve and watch timeout
2015-01-05 08:33:25 -08:00
4938e6bff5 rafthttp: a stopped peer does not accept any methods 2015-01-03 20:02:43 -08:00
3319f716d9 rafthttp: a stopped stream does not accept any methods 2015-01-03 19:39:33 -08:00
15be030aaa etcdserver: collect error from errorc 2015-01-02 20:13:46 -08:00
4dd00be365 etcdhttp: reset serve and watch timeout 2015-01-02 16:39:13 -08:00
b44d7f84c4 integration: extend timeout to wait 2015-01-02 16:28:27 -08:00
d719bc0e29 Merge pull request #2032 from xiang90/note
doc: add note for reconfiguration
2015-01-02 15:03:19 -08:00
bc6f062008 doc: add note for reconfiguration 2015-01-02 15:02:35 -08:00
2a83e350b1 Merge pull request #1992 from xiang90/rm_leader
*: support removing the leader from a 2 members cluster
2015-01-02 14:15:12 -08:00
6e727625b9 etcdserver: continue to apply after self-removed 2015-01-02 14:10:07 -08:00
0632dc2023 Merge pull request #2031 from xiang90/rm_test
etcdsever: remove mult_server_test
2015-01-02 13:53:13 -08:00
51ffc88096 etcdsever: remove mult_server_test 2015-01-02 13:49:58 -08:00
5bb43b5276 Merge pull request #2030 from xiang90/server_test
Server test
2015-01-02 12:27:39 -08:00
41f6137261 etcdserver: use the actual store implementation when we need the actual implementation 2015-01-02 12:22:01 -08:00
27d47977d9 etcdserver: move recorder to testutil 2015-01-02 11:21:23 -08:00
ac6cd03365 etcdserver: refactor server_test.go 2015-01-02 10:56:09 -08:00
921ce4c25b Merge pull request #2021 from xiang90/raft_reject_hint
raft: add lastIndex as rejectHint
2015-01-02 09:16:33 -08:00
35b907ac58 raft: add lastIndex as rejectHint
Add the lastindex of the raft log as reject hint, so the leader can
bypass the greater index probing and decrease the next index directly
to last + 1.
2015-01-01 19:04:07 -08:00
95a661251d rafthttp: rename streamClient -> streamReader 2014-12-31 21:20:58 -08:00
fe53ffd74d rafthttp: streamserver -> streamwriter 2014-12-31 21:11:24 -08:00
5a867611ca Merge pull request #2025 from yichengq/270
tools: move etcd-migrate to tools
2014-12-31 11:47:21 -08:00
1f8eef3b3b Merge pull request #2026 from yichengq/272
rafthttp: fix stream.open call
2014-12-31 11:30:58 -08:00
2292da15d6 rafthttp: fix stream.open call 2014-12-31 10:02:45 -08:00
04003a01ba Merge pull request #2013 from xiang90/tr
rafthttp cleanup
2014-12-31 08:35:20 -08:00
4974bb0349 Merge pull request #2022 from yichengq/268
godeps: bump go-etcd to 6aa2da5
2014-12-31 07:39:00 -08:00
9de4e36b6a tools: move etcd-migrate to tools 2014-12-30 22:48:47 -08:00
dc863459f8 godeps: bump go-etcd to 6aa2da5 2014-12-30 20:12:48 -08:00
17401994c0 Merge pull request #2019 from yichengq/266
tools: add etcd-dump-logs
2014-12-30 16:16:11 -08:00
8b0c7bf652 tools: add etcd-dump-logs
The tool can dump the log from data directory.
It helps develop and debug.
2014-12-30 16:14:27 -08:00
7273a861a6 Merge pull request #2018 from xiang90/server_error
etcdserver: move error to errors.go
2014-12-30 15:05:05 -08:00
803c38f448 etcdserver: move error to errors.go
Both server.go and cluster.go are using defined ErrX. Move error
to errors.go
2014-12-30 15:02:07 -08:00
2c21ac656b Merge pull request #2017 from xiang90/pbutil
pbutil: move getbool to pbutil
2014-12-30 14:51:53 -08:00
c3d2f5eea0 pbutil: add getbool to pbutil 2014-12-30 14:51:26 -08:00
8088440e1d Merge pull request #2015 from yichengq/265
etcdserver: cleanup server tests
2014-12-30 13:52:58 -08:00
241a474935 etcdserver: refactor server tests
1. remove redundant fake struct
2. use fake node for better testing
3. code clean
2014-12-30 13:49:55 -08:00
d2c7a7e5cb rafthttp: remove raftPrefix 2014-12-30 13:48:07 -08:00
2193b70fb3 rafthttp: add stream 2014-12-30 13:45:11 -08:00
bbfed7e6ef Merge pull request #2016 from Mic92/patch-1
README.md: New etcdctl link
2014-12-30 11:49:23 -08:00
3f8a85ed7e README.md: New etcdctl link 2014-12-30 18:20:57 +01:00
a92bd1d165 etcdserver: add multi_server_test.go 2014-12-30 00:10:18 -08:00
f79b9042ab etcdserver: fix streaming handler 2014-12-29 22:12:58 -08:00
3748088b96 etcdserver: print out log of normal tests 2014-12-29 14:38:00 -08:00
6ccaadc95d Merge pull request #1952 from yichengq/262
etcdserver: add id generator
2014-12-29 13:59:06 -08:00
05c921229e etcdserver: add id generator 2014-12-29 13:03:04 -08:00
c712dd682a rafthttp: make Transport private 2014-12-29 12:20:52 -08:00
a14d13f724 rafthttp: make fields in Transport private 2014-12-29 12:08:13 -08:00
7c8b9c0203 Merge pull request #2011 from xiang90/timeutil
etcdserver: move getExpr to timeutil
2014-12-29 12:03:25 -08:00
152676f43a *: support removing the leader from a 2 members cluster 2014-12-29 11:34:33 -08:00
dc6ba914c8 Merge pull request #2010 from yichengq/264
rafthttp: cleanup transport
2014-12-29 11:22:59 -08:00
5bb8eeb5cf rafthttp: transport cleanup 2014-12-29 11:21:40 -08:00
4463f5c4b3 raft: add link to the paper raft_paper_tests.go refers to 2014-12-29 14:17:48 -05:00
cea29fe158 etcdserver: move getExpr to timeutil 2014-12-29 11:15:02 -08:00
5f11d5a0d0 Merge pull request #1999 from xiang90/discovery_srv
*: move srv into pkg discovery
2014-12-29 10:27:45 -08:00
e1ee335c3a Merge pull request #1802 from yichengq/235
rafthttp: set the API boundary of the package
2014-12-28 16:00:24 -08:00
08f839e32c rafthttp: set the API boundary of the package 2014-12-28 15:50:27 -08:00
0630f42e7a Merge pull request #2009 from xiang90/refactor
etcdserver: remove unused containsUint64()
2014-12-26 11:09:23 -08:00
1535596252 etcdserver: remove unnecessary indirection 2014-12-26 11:03:13 -08:00
3dcd66459d etcdserver: remove unused containsUint64() 2014-12-26 10:56:56 -08:00
e056e96ad5 Merge pull request #2008 from xiang90/server_clean
etcdserver: cleanup server.go
2014-12-25 21:40:35 -08:00
69444b6bba etcdserver: cleanup server.go 2014-12-25 21:37:20 -08:00
60d25635c4 Merge pull request #2007 from xiang90/cluster_clean
etcdserver: cleanup cluster.go
2014-12-25 21:03:40 -08:00
78b51d3f2f etcdserver: cleanup cluster.go 2014-12-25 20:56:30 -08:00
9c84443f42 Merge pull request #2006 from xiang90/cluster_clean
cluster clean up
2014-12-25 20:45:01 -08:00
6dc3af5da4 etcdserver: cluster clean up 2014-12-25 20:36:48 -08:00
7a5bf53222 etcdserver: move member sort interface to member.go 2014-12-25 20:18:55 -08:00
7ce0fc782e Merge pull request #2005 from xiang90/kill_todo
etcdserver: kill a todo in test
2014-12-25 18:14:27 -08:00
ef0a66bb0a etcdserver: kill a todo in test 2014-12-25 18:14:05 -08:00
52fc768c28 Merge pull request #2001 from xiang90/cleanup
etcdserver: cleanup
2014-12-25 17:57:08 -08:00
00b4e919d0 Merge pull request #2003 from xiang90/raft_clean
raft: remove unnecessary funcs in raft.go
2014-12-25 17:06:02 -08:00
fc96a9e4a7 raft: remove unnecessary funcs in raft.go 2014-12-25 17:04:33 -08:00
f43bc809b9 etcdserver: cleanup wal upgrade 2014-12-24 22:02:46 -08:00
7d866dbc44 Merge pull request #2000 from xiang90/rm
etcdserver: remove example.go
2014-12-24 21:41:43 -08:00
b9d228b0fa etcdserver: remove example.go 2014-12-24 21:41:31 -08:00
08e9c25ea5 *: move srv into pkg discovery 2014-12-24 21:37:20 -08:00
7ec2e382bd Merge pull request #1996 from kelseyhightower/fix-dns-discovery-hostnames
etcdmain: resolve DNS hostnames for client and peer URLs
2014-12-24 13:24:07 -05:00
705ec45083 etcdmain: resolve DNS hostnames for client and peer URLs
etcd resolves DNS hostnames to IP addresses for client and peer URLs
before creating any listening sockets.

The following messages are logged during startup:

    etcd: Resolving infra0.coreos.com:2380 to 10.0.1.10:2380

Fixes #1991
2014-12-24 13:12:32 -05:00
289b070aa5 Merge pull request #1985 from mgwilliams/config-docs
fix an error in the 2.0 config docs
2014-12-22 18:48:41 -08:00
08f74cf68f fix an error in the 2.0 config docs 2014-12-23 02:41:12 +00:00
2b9f388a91 Merge pull request #1983 from xiang90/raft_storage_doc
raft: add doc for storage
2014-12-22 12:34:36 -08:00
2dbdf87f86 raft: add doc for storage 2014-12-22 12:33:14 -08:00
d87ee9819b Merge pull request #1982 from xiang90/srv_doc
doc: doc addition/fix for discovery-srv flag
2014-12-22 12:22:14 -08:00
ee7f23d0d5 doc: doc addition/fix for discovery-srv flag 2014-12-22 12:10:04 -08:00
841368c8e3 Merge pull request #1981 from xiang90/flag_test
etcdmian: add tests for configuration parsing
2014-12-22 12:00:25 -08:00
3abe71dff5 etcdmian: add tests for configuration parsing 2014-12-22 11:56:56 -08:00
f143948fdd Merge pull request #1976 from xiang90/flag
etcdmain: add config.go
2014-12-19 18:39:19 -08:00
0fa754d90e etcdmain: add config.go 2014-12-19 18:33:19 -08:00
39786c4bea Merge pull request #1977 from kelseyhightower/update-clustering-docs
docs: document DNS bootstrapping
2014-12-19 17:53:40 -08:00
fb4781920c docs: document DNS bootstrapping 2014-12-19 17:51:03 -08:00
1a5afaec7a Merge pull request #1973 from kelseyhightower/dns-bootstrap-docs
docs: add dns bootstrap guide
2014-12-19 15:07:57 -08:00
4f2d35679e Merge pull request #1947 from barakmich/dns_bootstrap
add capability to bootstrap from DNS SRV
2014-12-19 13:45:03 -08:00
8fc17147ef change logging 2014-12-19 16:40:29 -05:00
1f98d15535 docs: add dns bootstrap guide 2014-12-19 13:24:28 -08:00
f78bf987c8 Merge pull request #1968 from xiang90/fix_raft_test
raft: flush the commit to fix a race in test
2014-12-18 17:11:13 -08:00
896bac1f76 raft: flush the commit to fix a race in test 2014-12-18 17:10:37 -08:00
f8752f9879 Merge pull request #1966 from jonboulle/5to2
*: change remaining 0.5 references -> 2.0
2014-12-18 16:51:15 -08:00
021fc140b8 Merge pull request #1965 from jonboulle/fileutil
pkg/fileutil: sort filenames during ReadDir
2014-12-18 16:44:07 -08:00
1ec98cb795 pkg/fileutil: sort filenames during ReadDir 2014-12-18 16:36:11 -08:00
2311463935 Merge pull request #1967 from jonboulle/master
README: update version disclaimer
2014-12-18 16:27:32 -08:00
f1890ea48b README: update version disclaimer 2014-12-18 16:22:14 -08:00
6295dfba5a resolve all hostnames in DNS discovery 2014-12-18 19:19:21 -05:00
4e6cbc937e *: change remaining 0.5 references -> 2.0 2014-12-18 16:14:42 -08:00
1d859790e5 Merge pull request #1961 from barakmich/flock
Fix building the lock on windows
2014-12-18 16:09:48 -08:00
a5923e5b00 apologize profusely about locking on windows 2014-12-18 19:04:58 -05:00
9f84be81a2 Add notification in docs re backup command 2014-12-18 18:58:01 -05:00
977c74069c move constants out for windows 2014-12-18 18:57:11 -05:00
a0d72fb00c Fix building the lock on windows 2014-12-18 18:57:11 -05:00
2dfcf053d4 rename flag to discovery-srv 2014-12-18 18:13:40 -05:00
5a99e969b7 Merge pull request #1964 from robszumski/master
readme: add logo
2014-12-18 15:10:40 -08:00
7f733ad68b Fully resolve DNS entries to IPs and ignore single errors (such as no etcd-server-ssl) 2014-12-18 18:08:56 -05:00
0a40e18f68 Merge pull request #1962 from xiang90/raft
raft: leader waits for the reply of previous message
2014-12-18 15:05:41 -08:00
8b8ebb96c4 readme: add logo 2014-12-18 15:05:13 -08:00
88767d913d raft: leader waits for the reply of previous message when follower is not in good path.
It is reasonable for the leader to wait for the reply before sending out the next
msgApp or msgSnap for the follower in bad path. Or the leader will send out useless
messages if the previous message is rejected or the previous message is a snapshot.
Especially for the snapshot case, the leader will be 100% to send out duplicate message
including the snapshot, which is a huge waste.

This commit implement a timeout based wait mechanism. The timeout for normal msgApp is a
heartbeatTimeout and the timeout for snapshot is electionTimeout(snapshot is larger). We
can implement a piggyback mechanism(application notifies the msg lost) in the future
if necessary.
2014-12-18 15:01:50 -08:00
7588e4ddfb Merge pull request #1963 from robszumski/add-logo
logos: add SVG and PNG logos
2014-12-18 15:01:00 -08:00
d375b67a50 logos: add SVG and PNG logos 2014-12-18 14:59:06 -08:00
221abdcb3b version: bump to v2.0.0-rc.1 2014-12-18 10:27:29 -08:00
fa35363f74 Documentation: update to 2.0
In anticipation for a 2.0.0-rc.0 release update and move the
documentation.
2014-12-18 10:18:26 -08:00
fc70aa27d2 add apurl checking and logging 2014-12-17 20:53:12 -05:00
04d9f848a7 fix from comments 2014-12-17 20:28:48 -05:00
fdad6630ea Add a simple test and mock for genDNS 2014-12-17 20:18:41 -05:00
35a772753c Merge pull request #1958 from xiang90/compatibility
doc: add backword_compatibility.md
2014-12-17 15:58:28 -08:00
aea87bc88d Merge pull request #1951 from jlsalvador/patch-1
etcdctl: add environment support to certs args
2014-12-17 15:53:59 -08:00
ce6f606766 doc: add backword_compatibility.md 2014-12-17 15:47:49 -08:00
a000e97eea Merge pull request #1956 from coreos/member-migration-example
doc: update node migration guide
2014-12-17 12:10:46 -08:00
2d76e5e273 doc: update node migration guide 2014-12-17 12:10:10 -08:00
f0b9ad3863 Merge pull request #1955 from coreos/doc-cleanup
docs: fix port in peer URLs
2014-12-17 11:01:27 -08:00
0a14927823 docs: fix port in peer URLs 2014-12-17 10:51:52 -08:00
910198d117 etcdctl: add environment support to certs args 2014-12-16 16:18:36 +01:00
722247a752 Merge pull request #1948 from xiang90/stats
etcdserver: fix leader stats
2014-12-15 17:10:48 -08:00
c27c288bef etcdserver: update stats when become leader 2014-12-15 17:02:48 -08:00
04522baeee etcdserver: fix leader stats 2014-12-15 16:50:03 -08:00
af4272848d add capability to bootstrap from DNS 2014-12-15 19:26:42 -05:00
43bb6cf038 Merge pull request #1946 from barakmich/less_logging
Remove verbose logging and extraneous debug. Fixes #1904
2014-12-15 11:49:48 -08:00
8ece28d4f7 Remove verbose logging and extraneous debug. Fixes #1904 2014-12-15 14:47:02 -05:00
5369fb1c4f Merge pull request #1945 from xiang90/raft_test
raft: use newRaft
2014-12-15 11:31:11 -08:00
044e35b814 raft: use newRaft 2014-12-15 11:25:35 -08:00
e9b06416de Merge pull request #1942 from xiang90/doc
doc: specify listening addrs in the clustering example
2014-12-15 10:41:34 -08:00
9dc5b5a7e8 Merge pull request #1943 from xiang90/fix_streamSrv
sender: set strmSrv to nil after stoping it
2014-12-14 20:13:23 -08:00
e3dbfefbe0 sender: set strmSrv to nil after stoping it 2014-12-14 20:00:32 -08:00
0ea8c0929e Merge pull request #1927 from xiang90/flock
*: lock the in using files; do not purge locked the wal files
2014-12-14 19:39:58 -08:00
502396edd5 wal: fix wal doc 2014-12-14 19:36:37 -08:00
6b73a72d42 test: add fileutil to test 2014-12-14 19:34:54 -08:00
53bf7e4b5e wal: rename openAtIndex -> open; OpenAtIndexUntilUsing -> openNotInUse 2014-12-14 19:33:06 -08:00
f538cba272 *: do not backup files still in use 2014-12-14 19:27:22 -08:00
ea94d19147 *: lock the in using files; do not purge locked the wal files 2014-12-14 19:27:22 -08:00
b90693ccae doc: specify listening addrs in the clustering example 2014-12-14 19:21:54 -08:00
dcf34c0ab4 Merge pull request #1938 from yichengq/262
etcdserver: protect the sender map in SendHub
2014-12-15 10:41:52 +08:00
ceb077424d etcdserver: protect the sender map in SendHub 2014-12-15 10:37:41 +08:00
d07434f99e Merge pull request #1939 from xiang90/sender_logging
rafthttp: better logging
2014-12-14 18:23:36 -08:00
cb6983cbb1 Merge pull request #1940 from xiang90/raft_log
rafT: log term as %d
2014-12-14 10:06:59 -08:00
c586d5012c raft: log term as %d 2014-12-14 10:06:45 -08:00
d86603840d rafthttp: better logging 2014-12-14 09:50:59 -08:00
e40a53b534 Merge pull request #1926 from jainvipin/master
minor fix for #1786
2014-12-13 16:26:59 -08:00
3f64c677e1 modify directory deletion sequence 2014-12-13 16:22:36 -08:00
b8ab2b0b5c Merge pull request #1936 from xiang90/fix_test
pkg/transport: change write size from 1MB -> 5MB
2014-12-13 11:38:51 -08:00
3cc4cdd363 pkg/transport: change write size from 1MB -> 5MB
As we move to container-based infrastructure testing env
on travis, the tcp write buffer is more than 1MB. Change
the test according to the change on the testing env.
2014-12-13 11:32:29 -08:00
c620238257 Merge pull request #1934 from xiang90/fix_test
discovery: fix watch index
2014-12-13 11:18:32 -08:00
f265afa8ac discovery: fix watch index 2014-12-13 11:15:24 -08:00
bee3103931 Merge pull request #1931 from barakmich/travis
Disable unused sudo-ability from Travis in hopes of faster startup
2014-12-12 19:47:42 -05:00
fa195dae39 Merge pull request #1929 from lisael/master
added aioetcd (python 3.4+) to client libs list
2014-12-12 16:43:29 -08:00
fe4abc40ce Disable unused sudo-ability from Travis in hopes of faster startup
times.
2014-12-12 19:39:09 -05:00
3794f6ab88 version: bump to alpha.5 2014-12-12 16:26:16 -08:00
22e56ae9c6 Merge pull request #1930 from xiang90/flag
doc: add max wal/snap flags
2014-12-12 16:14:33 -08:00
b7cd72b593 doc: add max wal/snap flags 2014-12-12 16:09:53 -08:00
1f0d43250f documentation: fix min python version for aioetcd 2014-12-12 23:46:34 +01:00
97025bf5f1 documentation: added aioetcd to client libs 2014-12-12 23:40:56 +01:00
ae1f3d5640 Merge pull request #1925 from xiang90/stats
Stats
2014-12-12 10:17:12 -08:00
4724cbbe2c etcdserver: one line 2014-12-11 22:17:36 -08:00
935f7128a9 etcdserver: move stats inferface to stats pkg 2014-12-11 22:14:05 -08:00
b555843e0f Merge pull request #1922 from crawford/docs
docs: Update the flags and environment variables
2014-12-11 17:15:50 -08:00
d5d034ecd2 Merge pull request #1921 from xiang90/fix_time
store: return utc time to user
2014-12-11 16:40:20 -08:00
f054dd9d6f docs: Update the flags and environment variables
The configuration docs were missing some flags environment variables.
Arranged both lists in alphabetical order as well.
2014-12-11 16:26:05 -08:00
773f112a5d store: return utc time to user 2014-12-11 16:24:33 -08:00
ec777ebd28 Merge pull request #1918 from xiang90/http_no_logging
etcdmain: discard the http server logging
2014-12-11 16:06:58 -08:00
3a83ab1b71 etcdmain: discard the http server logging 2014-12-11 16:06:28 -08:00
d381889a84 Merge pull request #1920 from xiang90/better_logging
etcdmain: better logging for discovery error
2014-12-11 16:04:39 -08:00
d9b21c79d4 etcdmain: better logging for discovery error 2014-12-11 16:03:27 -08:00
2e9f6f70d6 Merge pull request #1917 from philips/add-build-aci-script
scripts: build-aci initial commit
2014-12-11 14:00:12 -08:00
2c2e032155 Merge pull request #1908 from bdarnell/error-fixes
raft: remove panic when we see a proposal with no leader.
2014-12-11 13:58:51 -08:00
b1d7597a9e Merge pull request #1828 from cap10morgan/statically-compile-etcdctl
build: statically compile etcdctl binary
2014-12-11 13:27:38 -08:00
f21cc09d83 scripts: build-aci initial commit
This will build an ACI from an etcd release tarball. This can be slimmed
down once the `actool` gets better
2014-12-11 15:58:37 -05:00
b26856b603 raft: add detail to "no leader" log message 2014-12-11 15:07:32 -05:00
5f16fab541 Merge pull request #1915 from barakmich/1834
Return Unknown instead of NotExist
2014-12-11 13:49:26 -05:00
cf7690cb51 detect more cases of empty directories and actual errors 2014-12-11 13:37:32 -05:00
421fe128c3 Return Unknown instead of NotExist
Unless the data dir truly does not exist.
2014-12-11 13:09:50 -05:00
0416503124 Merge pull request #1803 from junxu/master
etcdmain: Fix misuse "-addr" flag
2014-12-11 09:45:17 -08:00
c26542b7f2 Merge pull request #1913 from xiang90/lazy_snap_dir
etcdserver: create snap dir until start the node
2014-12-11 09:39:51 -08:00
2d4ca7e448 Merge pull request #1905 from robszumski/minor-log
migrate: improve logging for name and ID
2014-12-11 09:39:37 -08:00
836ccabad2 etcdserver: create snap dir until start the node 2014-12-11 09:25:18 -08:00
5b2ec31a15 Merge pull request #1910 from xiang90/gateway
discovery: fix gateway timeout
2014-12-10 23:12:50 -08:00
7171410422 discovery: discovery will try forever when there is a timeout.
Perviously, etcd retries three times for timeout error. After this
commit, etcd retries forever. Also this commit make etcd client
aware of gateway timetout.
2014-12-10 23:08:24 -08:00
f2863e5279 Merge pull request #1911 from diffoperator/issue_1903
rafthttp: fixes issue 1903
2014-12-10 22:55:22 -08:00
123b3dd64c rafthttp: fixes issue 1903
Record the URL being fetched in the log when we 404
2014-12-10 21:34:29 -08:00
89cba625d6 Merge pull request #1897 from xiang90/raft
raft: get rid of the using of defer in critical path
2014-12-10 21:24:38 -08:00
e89cc25c50 Merge pull request #1901 from yichengq/260
rafthttp: batch MsgProp
2014-12-10 21:16:07 -08:00
8aba4caa72 rafthttp: batch MsgProp
If amounts of MsgProp goes to the follower, it could batch them and
forward to the leader. This can avoid dropping MsgProp in good path
due to exceed maximal serving in sender.

Moreover, batching MsgProp can increase the throughput of proposals that
come from follower.
2014-12-10 21:08:40 -08:00
3867c72c8a raft: support to do multiple proposals in one message 2014-12-10 20:00:59 -08:00
a729c829a5 Merge pull request #1907 from robszumski/dash-note
docs: make clear that dashboard is a module
2014-12-10 16:50:55 -08:00
fa247d09cc raft: remove panic when we see a proposal with no leader.
This panic can never be reached when using raft.Node, because we only
read from propc when there is a leader. However, it is possible to see
this error when using raft the raft object directly (as in MultiNode),
and in this case it is better to simply drop the proposal (as if we had
sent it to a leader that immediately vanished).

Add an error return to MemoryStorage.Append for consistency.
2014-12-10 17:34:40 -05:00
7e242acf04 docs: make clear that dashboard is a module 2014-12-10 14:21:29 -08:00
96de9776b7 raft: get rid of allocation 2014-12-10 13:41:04 -08:00
d4dcd39b83 Merge pull request #1906 from yichengq/261
rafthttp: log the type of message that is dropped when sending
2014-12-10 13:23:24 -08:00
07e876592b rafthttp: log the type of message that is dropped when sending 2014-12-10 12:50:31 -08:00
e7f5b14f1b migrate: improve logging for name and ID 2014-12-10 11:53:04 -08:00
4777cba995 Merge pull request #1898 from robszumski/improve-logging
Improve logging for etcdserver and rafthttp
2014-12-10 10:46:47 -08:00
2593914973 rafthttp: feedback 2014-12-10 10:18:01 -08:00
ce0b0ef418 Merge pull request #1900 from diffoperator/etcd_tests
etcdserver: removed an unhelpful test failure message
2014-12-09 23:10:07 -08:00
a852936a59 etcdserver: removed an unhelpful test failure message
this commit changes instances of "blah" in a test to more
descriptive messages
2014-12-09 21:45:50 -08:00
4094812b39 rafthttp: improve start/stop logging 2014-12-09 16:57:40 -08:00
13f3158728 etcdserver: improve discovery ignore warning 2014-12-09 15:57:25 -08:00
e4c0f5c1a8 Merge pull request #1895 from xiang90/snap_nodes
etcd: update conf when apply the confChange entry
2014-12-09 11:45:01 -08:00
a5efbf826d raft: drop nodes in softState 2014-12-09 11:43:52 -08:00
0472ddf05f Merge pull request #1890 from yichengq/259
raft: set raft.Commit too when setting raftLog.committed
2014-12-09 11:28:05 -08:00
29d7a2a558 etcd: update conf when apply the confChange entry 2014-12-08 23:37:07 -08:00
4804c45e14 raft: set raft.Commit too when setting raftLog.committed 2014-12-08 22:35:55 -08:00
22dd3b039c Merge pull request #1888 from yichengq/258
raft: increase term to 1 before append initial entries
2014-12-08 22:27:23 -08:00
7317834417 raft: increase term to 1 before append initial entries
Because the term of new raft is 0, it is weird to have term-1 committed
entries in the log.
2014-12-08 22:21:39 -08:00
20e2c8f431 Merge pull request #1894 from xiang90/fix_snap
snap: error on empty snapshot
2014-12-08 22:02:19 -08:00
e981dda287 snap: error on empty snapshot 2014-12-08 21:45:28 -08:00
9c8f5c9535 Merge pull request #1891 from yichengq/257
etcdserver: init state before run loop correctly
2014-12-08 16:38:33 -08:00
325e768c7b Merge pull request #1889 from xiang90/chord_raft
Chord raft
2014-12-08 16:35:42 -08:00
13814c9d7d etcdserver: init state before run loop correctly 2014-12-08 16:13:16 -08:00
7e06d85651 etcdserver: apply entries when it is not empty
Or it updates appliedi wrongly.
2014-12-08 15:56:38 -08:00
ba45637ba3 raft: group step funcs 2014-12-08 15:29:54 -08:00
099f4f10ea raft: one line 2014-12-08 15:28:48 -08:00
dfbe16445d Merge pull request #1882 from yichengq/256
etcdserver: correct the log about recovering from snapshot
2014-12-08 15:25:19 -08:00
8ead428e76 raft: group getter funcs 2014-12-08 15:24:34 -08:00
f73d059d80 raft: group configuration related funcs 2014-12-08 15:23:21 -08:00
25313b1210 raft: move poll close to campaign 2014-12-08 15:21:57 -08:00
d52c66ad42 raft: removed unused func 2014-12-08 15:20:43 -08:00
a5ec7040e0 Merge pull request #1887 from xiang90/raft_logging
raft: refactoring logging
2014-12-08 15:17:20 -08:00
62ed1de10d raft: refactoring logging 2014-12-08 15:16:02 -08:00
71f3b80fbe etcdserver: check recovery error when new server 2014-12-08 14:55:23 -08:00
8c338ffcc7 etcdserver: correct the log about recovering from snapshot 2014-12-08 14:51:42 -08:00
b4773a15b2 Merge pull request #1886 from xiang90/raft_log
raft: print out log when creating a newraft
2014-12-08 14:47:04 -08:00
6cb7f2d9e9 raft: print out log when creating a newraft 2014-12-08 14:37:39 -08:00
576aba700e Merge pull request #1885 from xiang90/doc
Doc
2014-12-08 14:16:16 -08:00
8065206839 doc: fix typo 2014-12-08 14:15:37 -08:00
cd878ea9a9 doc: add a link to the peer url section in other_apis.go 2014-12-08 14:14:33 -08:00
091cc237e3 Merge pull request #1883 from xiang90/member_migration
doc: add doc for member migration
2014-12-08 14:09:09 -08:00
069578c29c doc: add doc for member migration 2014-12-08 14:08:01 -08:00
31b9f712ba Merge pull request #1879 from xiang90/peer_url_doc
doc: add doc for changing peer urls
2014-12-08 13:40:47 -08:00
706b6f96b3 doc: http status for other_apis.md 2014-12-08 13:10:21 -08:00
e83e2bff92 doc: refactor other_apis.md 2014-12-08 11:46:24 -08:00
2b519c90b9 doc: add doc for changing peer urls 2014-12-08 11:43:14 -08:00
f10f7802be Merge pull request #1874 from bdarnell/bootstrap-apply
Pre-apply the bootstrapping ConfChange entries.
2014-12-08 10:52:33 -08:00
f63d51e40f Merge pull request #1878 from yichengq/253
rafthttp: increase sender buffer size
2014-12-07 22:38:50 -08:00
b24d546bd0 rafthttp: increase sender buffer size
The buffer size is set big enough to buffer all messages generated in
one second as a follower in good path.
2014-12-07 22:35:50 -08:00
ea4d645a83 raft: Ignore redundant addNode calls.
This avoids clobbering any state when bootstrapping entries are
applied twice.
2014-12-05 17:15:50 -05:00
3d91faf85a Pre-apply the bootstrapping ConfChange entries.
This eliminates the need to fake an ApplyConfChange call before Campaign
in tests.

Fixes #1856.
2014-12-05 15:35:39 -05:00
6bfa5d409e Merge pull request #1872 from xiang90/fix_watcher_race
store: fix race in watcher_hub
2014-12-05 12:12:07 -08:00
793cb095b0 store: fix race in watcher_hub
Get the lock before modifing the global objects in the hub.
2014-12-05 12:09:48 -08:00
c03da80330 Merge pull request #1871 from xiang90/fix_node
raft: filter out messages from unknown sender.
2014-12-05 11:50:34 -08:00
6409a8bf0d raft: filter out messages from unknow sender.
If we cannot find the `m.from` from current peers in the raft and it is a response
message, we should filter it out or raft panics. We are not targetting to avoid
malicious peers.

It has to be done in the raft node layer syncchronously. Although we can check
it at the application layer asynchronously, but after the checking and before
the message going into raft, the raft state machine might make progress and
unfortunately remove the `m.from` peer.
2014-12-05 11:34:56 -08:00
15aed05071 Merge pull request #1869 from yichengq/251
etcdserver: not add self into sendhub when new server
2014-12-05 10:09:01 -08:00
771ff4589d etcdserver: not add self into sendhub when new server 2014-12-05 00:18:40 -08:00
a16dd7ea67 Merge pull request #1861 from yichengq/250
wal: sync after writing data to disk in Cut function
2014-12-04 23:49:07 -08:00
b9bf957c6d wal: sync after writing data to disk in Cut function 2014-12-04 22:56:34 -08:00
abb72f60bc Merge pull request #1866 from xiang90/raftnode_log
raft: refactor logging at node level
2014-12-04 21:03:32 -08:00
182c30a41a raft: refactor logging at node level 2014-12-04 21:03:06 -08:00
1b43f60e0e Merge pull request #1857 from yichengq/248
integration: add TestProgressWithMajority
2014-12-04 18:39:39 -08:00
6d046d94d6 integration: improve member tests 2014-12-04 17:37:44 -08:00
933a9f3e3f Merge pull request #1863 from xiang90/usage
etcdmain: format usage
2014-12-04 17:37:20 -08:00
a1f648e5db etcdmain: format usage 2014-12-04 17:21:23 -08:00
1d1c2ff834 Merge pull request #1841 from yichengq/246
etcdserver: close storage when stop
2014-12-04 15:36:24 -08:00
29982dc935 Merge pull request #1839 from yichengq/245
wal: save latest state into new WAL
2014-12-04 15:21:27 -08:00
a7bc03b42b etcdserver: close storage when stop 2014-12-04 15:16:22 -08:00
88e2fab572 Merge pull request #1859 from xiang90/pause_test
*: add pauseMember test
2014-12-04 15:11:59 -08:00
197e6b1b20 Merge pull request #1858 from vlajos/typofixes-vlajos-20141204
typofixes - https://github.com/vlajos/misspell_fixer
2014-12-04 14:52:27 -08:00
3de2ab2c04 *: typofixes
https://github.com/vlajos/misspell_fixer
2014-12-04 22:51:19 +00:00
ca32a5fe9b Merge pull request #1860 from yichengq/249
integration: fix possible early fire in TestWatch
2014-12-04 14:48:39 -08:00
356146b5a0 integration: fix possible early fire in TestWatch 2014-12-04 14:34:20 -08:00
151f043414 *: add pauseMember test 2014-12-04 14:22:43 -08:00
af0f34c595 wal: save latest state into new WAL
So we could always read out state when open at valid index.
2014-12-04 12:19:21 -08:00
a47690dd30 Merge pull request #1845 from xiang90/testunstable
raft: add TestUnstableTruncateAndAppend
2014-12-04 11:03:37 -08:00
4ebd3a0b10 Merge pull request #1852 from xiang90/heartbeat
raft: add msgHeartbeat type
2014-12-04 10:25:46 -08:00
72d2597f3d Merge pull request #1854 from yichengq/247
integration: not check whether readloop goroutines exist
2014-12-04 10:16:04 -08:00
149389cbfa raft: add msgHeartbeat type 2014-12-04 08:29:31 -08:00
719a634fdc integration: not check whether readloop goroutines exist
Readloop goroutines may be left from time to time. Skip the check for now,
and will dig into it when we have time.
2014-12-04 00:51:31 -08:00
e344774c10 Merge pull request #1850 from yichengq/247
raft: return 0 for term of compacted index
2014-12-03 17:23:32 -08:00
34a468de36 raft: return 0 for term of compacted index
It is necessary to make this check because of the following case:

1. memory storage contains ents from index 0 to 50, and unstable has
ents from index 50 to 60.
2. raft receives an incoming snapshot with index 100.
3. raft restores its unstable to 100, but has not applied snapshot on memory storage.
4. raft receives an out-dated MsgApp from index 60.
5. raft finds the term of index 60 to check the match.
6. raft asks memory storage about the term of index 60 after it failed to get
it from unstable.
7. memory storage panics because it knows nothing about index 60.
2014-12-03 17:22:36 -08:00
ddd9cb7345 raft: add TestUnstableTruncateAndAppend 2014-12-03 16:37:19 -08:00
2c0d323318 Merge pull request #1848 from xiang90/raft_log
raft: fix log format in sendAppend
2014-12-03 16:15:12 -08:00
2caf4f5f22 raft: fix log format in sendAppend 2014-12-03 16:11:44 -08:00
a426b310fc Merge pull request #1846 from xiang90/raft
raft: more logging
2014-12-03 14:59:06 -08:00
06a5892a18 raft: more logging 2014-12-03 14:46:24 -08:00
a36d07047a Merge pull request #1844 from xiang90/testunstable
Testunstable
2014-12-03 13:47:28 -08:00
8074a5b5a4 raft: fix error message format in test 2014-12-03 13:36:47 -08:00
37ab463e86 raft: add TestUnstableStableTo 2014-12-03 13:26:35 -08:00
7703d4942c raft: add TestUnstableRestore 2014-12-03 13:03:56 -08:00
be60c88603 Merge pull request #1842 from xiang90/unstable_test
raft: add TestUnstableFirstIndex
2014-12-03 11:50:39 -08:00
256e51874e Merge pull request #1843 from yichengq/248
raft: print out term in decimal format
2014-12-03 11:34:55 -08:00
63ed202db6 raft: print out term in decimal format 2014-12-03 11:33:51 -08:00
48f75ca645 raft: add TestUnstableMaybeTerm 2014-12-03 11:30:59 -08:00
058356d9bd raft: add TestUnstableLastIndex 2014-12-03 11:11:31 -08:00
98ebfa3468 raft: add TestUnstableFirstIndex 2014-12-03 11:11:11 -08:00
70bd26a652 Merge pull request #1815 from ravigadde/patch-1
docs: add etcd-lock into libraries-and-tools.md
2014-12-02 22:45:52 -08:00
16f9fd63ab doc: add etcd-lock into libraries-and-tools.md
Lock implementation for etcd. It has three go routines:
    a) acquire - loop that watches for the lock to be free and tries to acquire it.
    b) watch - to watch for lock changes
    c) refresh - to refresh the ttl when the lock is acquired

All the changes in lock ownership are notified on the events channel. Any feedback welcome!
2014-12-02 22:39:06 -08:00
23b32a6cbe Merge pull request #1716 from yichengq/225
raft: panic if loaded commit is out of range
2014-12-02 22:14:12 -08:00
7305451d43 Merge pull request #1825 from yichengq/242
wal: not return ErrIndexNotFound in ReadAll
2014-12-02 22:11:49 -08:00
38768e5396 raft: panic if loaded commit is out of range 2014-12-02 22:09:34 -08:00
7e01c02abb Merge pull request #1837 from xiang90/fix_restore
raft: do not restore snapshot if local raft has longer matching history
2014-12-02 21:48:43 -08:00
b3841afcc3 raft: do not restore snapshot if local raft has longer matching history
Raft should not restore the snapshot if it has longer matching history.
Or restoring snapshot might remove the matched entries.
2014-12-02 21:34:14 -08:00
e07e2ac124 Merge pull request #1836 from xiang90/panic_slice
raft: panic on bad slice
2014-12-02 17:48:34 -08:00
3209fd544b raft: panic on bad slice 2014-12-02 17:48:03 -08:00
79014556e9 Merge pull request #1831 from xiang90/fix_unstable
raft: fix unstable
2014-12-02 14:43:11 -08:00
2f5b748a90 raft: clearify that the firstIndex might not be available. 2014-12-02 14:27:52 -08:00
1c7b9317a9 Merge pull request #1833 from yichengq/244
raft: not call stableTo for restored snapshot
2014-12-02 13:20:39 -08:00
551a56fb98 raft: not call stableTo for restored snapshot
Stable has been set when restoring the snapshot in raftlog, so we don't need
to set it after advance.
2014-12-02 13:10:35 -08:00
b7ca56e3c8 raft: move good case of truncateAndAppend to the first place 2014-12-02 13:05:55 -08:00
3cadaca1a3 Merge pull request #1830 from xiang90/raft_snap_log
raft: log snapshot events
2014-12-02 12:06:15 -08:00
411063e14f raft: log snapshot events 2014-12-02 11:57:10 -08:00
99c2e905e2 Merge pull request #1829 from xiang90/raft_index
raft: use index in entry
2014-12-02 10:42:55 -08:00
788d1e59a2 raft: use index in entry 2014-12-02 10:25:27 -08:00
70b501d17c Merge pull request #1824 from yichengq/241
etcdserver: close idle connections when stop sendhub
2014-12-02 10:12:45 -08:00
6692a8060e Merge pull request #1823 from xiang90/raft_log
raft: logging state change events and events on bad path
2014-12-02 10:10:08 -08:00
51de095d2c raft: logging state change events and events on bad path 2014-12-02 10:08:19 -08:00
f02eae934b Merge pull request #1827 from lamielle/doc-whitespaces
doc: uses spaces consistently in sample JSON
2014-12-02 07:44:03 -08:00
57b076f710 build: statically compile etcdctl binary 2014-12-02 10:24:05 -05:00
2b7af3d101 doc: uses spaces consistently in sample JSON
Replaces spurious uses of tabs with four spaces.  Removes strange
unicode space character with standard space character.
2014-12-02 06:43:07 -08:00
aa61009560 wal: not return ErrIndexNotFound in ReadAll
This IndexNotFound case is reasonable now because we don't write dummy
entries into wals any more.
2014-12-02 00:28:54 -08:00
fa292391d8 etcdserver: close idle connections when stop sendhub 2014-12-02 00:08:47 -08:00
f34fe6e4ae Merge pull request #1819 from yichengq/239
integration: use timeout transport when launching cluster
2014-12-01 23:00:28 -08:00
cb74b6812b Merge pull request #1820 from xiang90/fix_storage
raft: fix memory storage
2014-12-01 21:25:17 -08:00
312db7f0f3 raft: fix memory storage
Memory storage should append all entries that have greater index
than the snap.Matedata.Index. We first truncate the old parts of
incoming entries. Then truncate the existing entries in the storage.
At last, we append the incoming entries to the existing entries.
2014-12-01 16:37:16 -08:00
7a1d147795 integration: use timeout transport when launching cluster
This makes it do the same behavior as etcdmain does.
2014-12-01 16:26:27 -08:00
19ccdbee18 Merge pull request #1806 from xiang90/no_copy
No copy
2014-12-01 13:15:13 -08:00
7beac083ff Merge pull request #1810 from xiang90/purge
*: support purging old wal/snap files
2014-12-01 12:05:05 -08:00
d3db010190 *: support purging old wal/snap files 2014-12-01 11:50:17 -08:00
92d4112feb Merge pull request #1809 from xiang90/unstable
raft: stableTo checks term matching
2014-12-01 11:09:40 -08:00
649176934a raft: add tests for stableTo 2014-12-01 10:54:34 -08:00
7c47decd19 Merge pull request #1813 from xiang90/snap_event_log
etcdserver: log snapshot event
2014-11-30 12:11:23 -08:00
bc5acd3c42 etcdserver: log snapshot event 2014-11-30 12:10:20 -08:00
3c0fbe285c raft: stableTo checks term matching
stableTo should only mark the index stable if the term is matched. After raft sends out unstable
entries to application, raft makes progress without waiting for reply. When the appliaction
calls the stableTo to notify the entries up to "index" are stable, raft might have truncated
some entries before "index" due to leader lost. raft must verify the (index,term) of stableTo,
before marking the entries as stable.
2014-11-28 14:13:07 -08:00
d214e87aee raft: make unstable.entries immutable; copy the entries at bad path 2014-11-27 19:35:03 -08:00
d244e3bf6e raft: fix node bench 2014-11-26 23:07:35 -08:00
fe0bc4ff36 Merge pull request #1805 from xiang90/fix_raft_b
raft: fix start term
2014-11-26 21:41:38 -08:00
746c66b466 raft: fix start term 2014-11-26 21:21:13 -08:00
43d6f9f964 Update etcd.go
etcdmain: Fix misuse "-addr" flag

In code, it uses "-advertise-client-urls" or "-addr" flags to get the list of this member's peer URLs, 
It should be using "-peer-addr" flag instead of "-addr" flag.
2014-11-27 10:38:47 +08:00
35cf7b5a31 Merge pull request #1800 from xiang90/unstable
raft: move unstable related function to log_unstable.go
2014-11-26 16:12:43 -08:00
7929e46dd8 raft: clean up 2014-11-26 15:31:07 -08:00
8a626257c7 raft: move unstable related function to log_unstable.go 2014-11-26 15:25:24 -08:00
416b799ecf Merge pull request #1788 from yichengq/233
rafthttp: increase the size of streaming buffer
2014-11-26 15:22:28 -08:00
00ce0702b9 rafthttp: increase the size of streaming buffer
Streaming buffer is used for:
1. hand over data to io goroutine in non-blocking way
2. hold pressure for temprorary network delay
3. be able to wait on I/O instead of data coming under high throughput

The old 1024 value is too small and is very likely to be full and
break the streaming when suffering temprorary network delay.
2014-11-26 14:46:52 -08:00
7358ef21a2 Merge pull request #1799 from yichengq/237
integration: attempt more times to listen on specified port
2014-11-26 14:26:41 -08:00
e03cf6d488 Merge pull request #1797 from yichengq/236
raft: no need to save dummy entry into stable storage
2014-11-26 14:23:32 -08:00
670d98ec72 integration: attempt more times to listen on specified port
Travis is rather slow, and it may fail to listen on that port sometimes.
2014-11-26 14:21:15 -08:00
0f070f3d2d raft: no need to save dummy entry into stable storage 2014-11-26 14:04:56 -08:00
b2d686495c Merge pull request #1796 from xiang90/unstable
raft: move all unstable stuff into one struct for future cleanup
2014-11-26 13:59:07 -08:00
66252c7d62 raft: move all unstable stuff into one struct for future cleanup 2014-11-26 13:36:17 -08:00
488f508505 Merge pull request #1777 from xiang90/log_interface
Log interface
2014-11-26 12:51:37 -08:00
ab2a40ea37 Merge branch 'log_interface'
Conflicts:
	raft/log.go
2014-11-26 12:16:02 -08:00
732cfa1ad6 raft: remove the applysnap from Storage interface 2014-11-26 11:28:51 -08:00
e23f9e76d1 raft: do not applysnapshot in raft 2014-11-26 10:59:13 -08:00
d01d6119e5 Merge pull request #1792 from xiang90/fix_raft_l
raft: always write dummy entry to storage
2014-11-25 23:32:01 -08:00
39e6631447 raft: always write dummy entry to storage 2014-11-25 23:27:40 -08:00
7614aa53bf version: bump to alpha.4 2014-11-25 21:41:13 -08:00
006da2f8a0 Merge pull request #1789 from yichengq/234
rafthttp: only batch good MsgAppResp
2014-11-25 18:46:23 -08:00
d5ceb26408 rafthttp: only batch good MsgAppResp
A MsgAppResp with Reject set should be sent back to the leader as soon
as possible instead of batching.
2014-11-25 17:53:26 -08:00
8de98d4903 raft: clean up 2014-11-25 16:21:50 -08:00
9bd1786fe4 raft: memory storage does not append out of date entries 2014-11-25 15:18:40 -08:00
9df0e7715d raft: do not panic on out of date compaction 2014-11-25 15:14:39 -08:00
01cbcce8ba etcdserver: do not applySnapshot twice 2014-11-25 14:53:49 -08:00
74d8c7f457 etcdserver: cleanup main loop 2014-11-25 14:38:18 -08:00
7e6e305c4f Merge branch 'log_interface'
Conflicts:
	raft/raft.go
2014-11-25 14:22:11 -08:00
a13d5a70ff etcdserver: save snapshot before entries 2014-11-25 12:39:15 -08:00
dd57c1f189 Merge pull request #1784 from yichengq/234
raft: not compact log if the compact index < first index of the log
2014-11-25 11:52:01 -08:00
4b43824be9 raft: not compact log if the compact index < first index of the log
It should ignore the compact operation instead of panic because the case that
the log is restored from snapshot before executing compact is reasonable.
2014-11-25 11:51:20 -08:00
1a5333e51d Merge pull request #1778 from yichengq/232
docs: add configuration doc
2014-11-25 11:16:44 -08:00
07ca99f4d6 docs: add configuration doc 2014-11-25 11:09:29 -08:00
aa2721e31d Merge pull request #1781 from orls/fix-backup-snapshots
Fix backup snapshots
2014-11-25 08:59:16 -08:00
c46e30412e Merge pull request #1782 from orls/fix-forcenew-panic
etcdserver: Fix panic when restoring from backup (-force-new-cluster)
2014-11-25 08:58:32 -08:00
dbb6a75e3f backup: Ensure dest snapshot dir always exists
Otherwise the SaveSnap operation fails
2014-11-25 16:57:18 +00:00
c67b937d62 etcdserver: truncate WAL from correct index when forcing new cluster
When loading from a backup with a snapshot and WAL, the length of WAL entries
can be lower than the current index integer value, causing a panic when
slicing off uncommitted entries. This looks for WAL entries higher than
the current index before slicing.
2014-11-25 16:46:56 +00:00
9974bf0291 backup: Add fatal if dest snapshot failed
Errors are currently silently swallowed
2014-11-25 14:08:20 +00:00
8aa89dba3d raft: make if checking match the error in storage.Term 2014-11-25 00:52:13 -08:00
8ee1bf31d6 raft: use IsEmptySnap to check the empty snapshot 2014-11-25 00:37:21 -08:00
e466126510 raft: set snapshot to nil when it is saved 2014-11-25 00:30:22 -08:00
e17bcd8932 raft: remove wont-fix TODO in ApplyConfChange 2014-11-25 00:10:44 -08:00
85d0e2f130 raft: remove unused raftLog.isOutOfAppliedBounds 2014-11-25 00:07:55 -08:00
1e0f87df8c raft: stricter checking in raftLog.slice 2014-11-25 00:05:00 -08:00
1d01c8aa2d raft: remove unused raftLog.at function 2014-11-24 23:52:28 -08:00
2c06a1d815 raft: not set applied when restore log from snapshot
applied is only updated by application level through Advance.
2014-11-24 23:37:47 -08:00
0d200baf72 raft: refine raftLog.term 2014-11-24 23:27:57 -08:00
7fcaca6d18 raft: simplify raftLog.lastIndex 2014-11-24 23:08:51 -08:00
8670f4012b raft: remove useless line in raftLog.append 2014-11-24 22:42:55 -08:00
239c8dd479 raft: add comment to newLog 2014-11-24 21:47:12 -08:00
54e1237271 etcdserver: panic when snapshot on raft storage
Snapshot on raft storage should always succeed. If there is an error, it must
be internal fault and needs stack info to debug.
2014-11-24 21:22:49 -08:00
1b038da18a etcdserver: init snapi when init appliedi 2014-11-24 21:19:30 -08:00
bd9e93eeea etcdserver: remove finished TODO for raftStorage.Compact 2014-11-24 21:10:53 -08:00
185d37c333 etcdserver: not load dummy entry from the wal 2014-11-24 20:51:04 -08:00
e3cb3d640b Merge pull request #1780 from xiang90/fix_raft_lead
raft: always check leader changes in node run loop
2014-11-24 19:29:53 -08:00
9455119968 raft: always check leader changes in node run loop 2014-11-24 19:07:10 -08:00
d67eea4a7d Merge pull request #1779 from yichengq/233
rafthttp: limit the buffer for every read correctly
2014-11-24 17:44:25 -08:00
61ce494386 rafthttp: limit the buffer for every read correctly 2014-11-24 17:39:39 -08:00
65ad1f6ffd raft: attach Index to Entry in all tests 2014-11-24 17:13:47 -08:00
10ebf1a335 raft: fix memoryStorage append 2014-11-24 16:36:59 -08:00
2876c652ab raft: fix for go vet 2014-11-24 15:00:38 -08:00
d69e4dbe6d etcdserver: initial index to 1 2014-11-24 14:57:08 -08:00
453133977d etcdserver: save snapshot only if the index is greater than previous snap index 2014-11-24 14:47:59 -08:00
4b7af29c37 etcdserver: fix TriggerSnap test.
Sleep for millisecond to allow the server to apply the first nop and
first put separately.
2014-11-24 14:47:49 -08:00
cfb96de413 Merge pull request #1770 from yichengq/230
*: set read/write timeout for raft transport and listener
2014-11-24 14:01:57 -08:00
1e797c1e38 rafthttp: limit the data size read from connection each time 2014-11-24 13:54:45 -08:00
3e55834c38 *: set read/write timeout for raft transport and listener 2014-11-24 13:46:44 -08:00
ad58122e3c pkg/transport: fix dialer typo 2014-11-24 13:35:46 -08:00
400e573013 rafthttp: log start and stop of streaming 2014-11-24 13:35:46 -08:00
62a8df304a raft: fix error message in TestLogRestore 2014-11-24 11:10:02 -08:00
e8afdcfe0a raft: refactor testUnstableEnts 2014-11-24 10:40:38 -08:00
08f156a1de etcdserver: remove extra empty line in snapshot func 2014-11-24 10:27:18 -08:00
3dd4c458ca raft: refactor term in log.go 2014-11-24 10:13:56 -08:00
94190286ff raft: add comment for append in unstableEntries in log.go 2014-11-24 09:05:40 -08:00
0a46c70f5d raft: use empty slice in unstableEntries in log.go 2014-11-24 09:04:45 -08:00
bc0e72acb9 raft: clean up panic in log.go 2014-11-24 09:01:25 -08:00
f3cef87c69 raft: remove extra empty line in log.go 2014-11-24 08:43:34 -08:00
6c8e294d20 test: longer test timeout 2014-11-24 08:37:26 -08:00
bdbafe2cf3 raft: use max in log.slice 2014-11-24 08:36:15 -08:00
bb640e326d Merge pull request #1773 from xiang90/header
pkg/transport: add copyright header
2014-11-24 00:40:30 -08:00
c72221a691 pkg/transport: add copyright header 2014-11-24 00:39:55 -08:00
c6cbea451a Merge pull request #1771 from xiang90/listener
pkg/transport: add timeout dailer and timeout listener
2014-11-23 23:00:54 -08:00
35e6df6d0a integration: longer request timeout for slow travis 2014-11-23 22:53:05 -08:00
da1ff2d2bb pkg/transport: add timeout dailer and timeout listener 2014-11-23 21:18:34 -08:00
68e79868cc Merge pull request #1768 from xiang90/batcher
rafthttp: add batcher
2014-11-23 12:08:00 -08:00
91bfead9e9 rafthttp: add batcher
After we enable streaming, there will be a large amount of msgAppResp due to high
rate msgApp. We should batch msgAppResp in a meanful way.
2014-11-23 12:05:42 -08:00
9ddd8ee539 Rename Storage.HardState back to InitialState and include ConfState.
This fixes integration/migration_test.go (and highlights the fact that
we need some more raft-level testing of restoring from snapshots).
2014-11-21 17:22:20 -05:00
03c8881e35 Fix TestSlowNodeRestore 2014-11-21 16:40:41 -05:00
0d680d0e6b Merge remote-tracking branch 'coreos/master' into merge
* coreos/master:
  rafthttp: fix import
  raft: should not decrease match and next when handling out of order msgAppResp
  Fix migration to allow snapshots to have the right IDs
  add snapshotted integration test
  fix test import loop
  fix import loop, add set to types, and fix comments
  etcdserver: autodetect v0.4 WALs and upgrade them to v0.5 automatically
  wal: add a bench for write entry
  rafthttp: add streaming server and client
  dep: use vendored imports in codegangsta/cli
  dep: bump golang.org/x/net/context

Conflicts:
	etcdserver/server.go
	etcdserver/server_test.go
	migrate/snapshot.go
2014-11-21 15:40:11 -05:00
30690d15d9 Re-enable a few tests I had missed.
Fix integration test for the change to log entry zero.

Increase test timeouts since integration tests often take
longer than 10s for me.
2014-11-21 15:27:17 -05:00
66c30f28d6 Merge pull request #1761 from xiang90/fix_raft
raft: should not decrease match and next when handling out of order msgAppResp
2014-11-20 18:12:15 -08:00
edcdffe11e Merge pull request #1762 from xiang90/fix_import
rafthttp: fix import
2014-11-20 18:10:49 -08:00
264a63be80 rafthttp: fix import 2014-11-20 18:05:45 -08:00
063c5c77a0 raft: should not decrease match and next when handling out of order msgAppResp 2014-11-20 17:58:23 -08:00
c0fb1c8a00 Merge pull request #1755 from bcwaldon/golang.org-deps
Switch to golang.org/x/net/context
2014-11-20 16:26:14 -08:00
5139257b8d Merge pull request #1743 from barakmich/auto_upgrade
etcdserver: autodetect v0.4 WALs and upgrade them to v0.5 automatically
2014-11-20 17:20:34 -05:00
ce82a3e7ad Fix migration to allow snapshots to have the right IDs 2014-11-20 16:49:34 -05:00
53fbf0f333 Merge pull request #1760 from xiang90/wal
wal: add a bench for write entry
2014-11-20 13:16:37 -08:00
2d5ccf12ef add snapshotted integration test 2014-11-20 15:38:08 -05:00
d1e7fee3ca fix test import loop 2014-11-20 15:38:08 -05:00
59a0c64e9f fix import loop, add set to types, and fix comments 2014-11-20 15:38:08 -05:00
78ea3335bf etcdserver: autodetect v0.4 WALs and upgrade them to v0.5 automatically 2014-11-20 15:38:08 -05:00
d0dd205b0e wal: add a bench for write entry 2014-11-20 12:07:17 -08:00
aca195f3ad Merge pull request #1746 from yichengq/229
rafthttp: streaming server and client
2014-11-20 11:42:00 -08:00
9d53b94546 rafthttp: add streaming server and client 2014-11-20 11:34:50 -08:00
da5538b8c7 dep: use vendored imports in codegangsta/cli 2014-11-20 10:19:13 -08:00
9a728a127a dep: bump golang.org/x/net/context
Move from code.google.com/p/go.net/context to
golang.org/x/net/context before bumping to latest.
2014-11-20 10:19:12 -08:00
b29240baf0 Merge remote-tracking branch 'coreos/master' into merge
* coreos/master:
  scripts: build-docker tag and use ENTRYPOINT
  scripts: build-release add etcd-migrate
  create .godir
  raft: optimistically increase the next if the follower is already matched
  raft: add handleHeartbeat handleHeartbeat commits to the commit index in the message. It never decreases the commit index of the raft state machine.
  rafthttp: send takes raft message instead of bytes
  *: add rafthttp pkg into test list
  raft: include commitIndex in heartbeat
  rafthttp: move server stats in raftHandler to etcdserver
  *: etcdhttp.raftHandler -> rafthttp.RaftHandler
  etcdserver: rename sender.go -> sendhub.go
  *: etcdserver.sender -> rafthttp.Sender

Conflicts:
	raft/log.go
	raft/raft_paper_test.go
2014-11-19 17:05:16 -05:00
355ee4f393 raft: Integrate snapshots into the raft.Storage interface.
Compaction is now treated as an implementation detail of Storage
implementations; Node.Compact() and related functionality have been
removed. Ready.Snapshot is now used only for incoming snapshots.

A return value has been added to ApplyConfChange to allow applications
to track the node information that must be stored in the snapshot.

raftpb.Snapshot has been split into Snapshot and SnapshotMetadata, to
allow the full snapshot data to be read from disk only when needed.

raft.Storage has new methods Snapshot, ApplySnapshot, HardState, and
SetHardState. The Snapshot and HardState parameters have been removed
from RestartNode() and will now be loaded from Storage instead.
The only remaining difference between StartNode and RestartNode is that
the former bootstraps an initial list of Peers.
2014-11-19 16:40:26 -05:00
b50f331558 Merge pull request #1744 from xiang90/next
raft: optimistically increase the next if the follower is already matched
2014-11-19 13:21:11 -08:00
12aaf046d7 Merge pull request #1752 from philips/include-etcd-migrate-in-releases
scripts: build-release add etcd-migrate
2014-11-19 12:13:21 -08:00
f08df9e0f3 Merge pull request #1753 from philips/fixup-build-docker
scripts: build-docker tag and use ENTRYPOINT
2014-11-19 12:13:08 -08:00
00df13138e scripts: build-docker tag and use ENTRYPOINT
Use ENTRYPOINT so people can specify flags to etcd without providing the
binary.

Thanks to @hugod in IRC for pointing this out.
2014-11-19 12:11:27 -08:00
d2e36a9535 scripts: build-release add etcd-migrate
this tool is only temporary for the alphas but make sure it makes it in.
2014-11-19 12:10:06 -08:00
893fb3b890 Merge pull request #1747 from proppy/master
create .godir
2014-11-18 16:00:07 -08:00
03bacc1984 create .godir 2014-11-18 15:01:57 -08:00
4c1fd07311 raft: optimistically increase the next if the follower is already matched
This is useful since we want to pipeline the appendEntry requests. Without
enabling optimistic increasing, the second pipelining appendEntry request
will include the entries the first one has already sent out. We decrease
the next directly to match if the leader receives a rejection for a matched
follower. This happens if one pipelining request get lost and following ones
arrives at the follower.
2014-11-18 13:41:38 -08:00
e07ef6991c Merge pull request #1740 from xiang90/handleheartbeat
raft: add handleHeartbeat
2014-11-18 13:25:12 -08:00
46ee58c6f0 raft: Rename ErrSnapshotRequired To ErrCompacted. 2014-11-18 13:15:10 -05:00
f94ff96c69 Merge pull request #1739 from yichengq/230
rafthttp: send takes raft message instead of bytes
2014-11-18 10:11:05 -08:00
bd4cfa2a07 raft: add handleHeartbeat
handleHeartbeat commits to the commit index in the message. It never decreases the
commit index of the raft state machine.
2014-11-18 08:34:06 -08:00
1a72143ecb rafthttp: send takes raft message instead of bytes
This gives streaming mechanism the chance to assemble and disassemble
raft messages.
2014-11-17 22:39:53 -08:00
6cac631a0d Merge pull request #1738 from yichengq/231
*: add rafthttp pkg into test list
2014-11-17 17:14:40 -08:00
04d416291a *: add rafthttp pkg into test list 2014-11-17 16:45:54 -08:00
1635844ebd Merge pull request #1737 from xiang90/include_commit
raft: include commitIndex in heartbeat
2014-11-17 16:26:07 -08:00
b93d87f17f raft: include commitIndex in heartbeat 2014-11-17 16:19:28 -08:00
a2c568a144 Merge pull request #1669 from yichengq/215
*: add rafthttp as a separate package
2014-11-17 16:14:59 -08:00
f24e214ee5 rafthttp: move server stats in raftHandler to etcdserver 2014-11-17 16:02:20 -08:00
5dc5f8145c *: etcdhttp.raftHandler -> rafthttp.RaftHandler 2014-11-17 15:52:24 -08:00
3fcc011717 etcdserver: rename sender.go -> sendhub.go 2014-11-17 15:35:15 -08:00
84fbf7aab5 *: etcdserver.sender -> rafthttp.Sender 2014-11-17 15:35:10 -08:00
300c5a2001 Merge remote-tracking branch 'coreos/master' into log-storage-interface
* coreos/master: (21 commits)
  etcdserver: refactor ValidateClusterAndAssignIDs
  integration: add integration test for remove member
  integration: add test for member restart
  version: bump to alpha.3
  etcdserver: add buffer to the sender queue
  *: gracefully stop etcdserver
  Fix up migration tool, add snapshot migration
  etcd4: migration from v0.4 -> v0.5
  etcdserver: export Member.StoreKey
  etcdserver: recover cluster when receiving newer snapshot
  etcdserver: check and select committed entries to apply
  etcdserver: recover from snapshot before applying requests
  raft: not set applied when restored from snapshot
  sender: support elegant stop
  etcdserver: add StopNotify
  etcdserver: fix TestDoProposalStopped test
  etcdserver: minor cleanup
  etcdserver: validate new node is not registered before in best effort
  etcdserver: fix server.Stop()
  *: print out configuration when necessary
  ...

Conflicts:
	etcdserver/server.go
	etcdserver/server_test.go
	raft/log.go
2014-11-17 18:28:24 -05:00
e04e4632b3 Merge pull request #1736 from xiang90/verify
etcdserver: refactor ValidateClusterAndAssignIDs
2014-11-17 14:34:59 -08:00
0541f0afa0 etcdserver: refactor ValidateClusterAndAssignIDs 2014-11-17 14:23:37 -08:00
64d9bcabf1 Add Storage.Term() method and hide the first entry from other methods.
The first entry in the log is a dummy which is used for matchTerm
but may not have an actual payload. This change permits Storage
implementations to treat this term value specially instead of
storing it as a dummy Entry.

Storage.FirstIndex() no longer includes the term-only entry.

This reverses a recent decision to create entry zero as initially
unstable; Storage implementations are now required to make
Term(0) == 0 and the first unstable entry is now index 1.
stableTo(0) is no longer allowed.
2014-11-17 16:54:12 -05:00
144db790ae Merge pull request #1729 from xiang90/test_rm
integration: add integration test for remove member
2014-11-17 13:35:26 -08:00
c26de66262 integration: add integration test for remove member 2014-11-17 13:28:09 -08:00
ee8fbee7ab Merge pull request #1733 from xiang90/config
integration: add test for member restart
2014-11-17 13:19:59 -08:00
800747e1cf integration: add test for member restart 2014-11-17 11:28:18 -08:00
a817ca705b Merge pull request #1726 from xiang90/fix_sender
etcdserver: add buffer to the sender queue
2014-11-14 16:13:32 -08:00
fd512ffe6d version: bump to alpha.3 2014-11-14 15:51:01 -08:00
7c4b84a6cd etcdserver: add buffer to the sender queue 2014-11-14 15:18:16 -08:00
ac5a282003 Merge pull request #1720 from xiang90/sender_stop
*: gracefully stop etcdserver
2014-11-14 14:16:39 -08:00
8bf71d796e *: gracefully stop etcdserver 2014-11-14 14:12:24 -08:00
4e251f8624 Merge pull request #1578 from barakmich/bcm_migrate
migrate: Add a migration tool to go from etcd v0.4 -> v0.5 data directories
2014-11-14 16:58:22 -05:00
192f200d9e Fix up migration tool, add snapshot migration
Fixes all updates since bcwaldon sketched the original, with cleanup and
into an acutal working state. The commit log follows:

fix pb reference and remove unused file post rebase

unbreak the migrate folder

correctly detect node IDs

fix snapshotting

Fix previous broken snapshot

Add raft log entries to the translation; fix test for all timezones. (Still in progress, but passing)

Fix etcd:join and etcd:remove

print more data when dumping the log

Cleanup based on yichengq's comments

more comments

Fix the commited index based on the snapshot, if one exists

detect nodeIDs from snapshot

add initial tool documentation and match the semantics in the build script and main

formalize migration doc

rename function and clarify docs

fix nil pointer

fix the record conversion test

add migration to test suite and fix govet
2014-11-14 16:46:08 -05:00
5ea1f2d96f etcd4: migration from v0.4 -> v0.5 2014-11-14 15:57:26 -05:00
c36abeabd1 etcdserver: export Member.StoreKey 2014-11-14 15:57:26 -05:00
b6887e4a83 Merge pull request #1719 from yichengq/228
etcdserver: recover snapshot before applying committed entries
2014-11-14 12:18:41 -08:00
77433ff6da etcdserver: recover cluster when receiving newer snapshot 2014-11-14 12:11:21 -08:00
dfaa7290c4 etcdserver: check and select committed entries to apply 2014-11-14 12:11:16 -08:00
f6a7f96967 etcdserver: recover from snapshot before applying requests 2014-11-14 12:08:39 -08:00
7d0ffb3f12 raft: not set applied when restored from snapshot
applied is only updated by application level through Advance.
2014-11-14 12:08:39 -08:00
45e96be605 raft: PR feedback.
Removed Get prefix in method names, added assertions and fixed comments.
2014-11-14 13:53:42 -05:00
1f7198855b Merge pull request #1703 from jonboulle/proc
*: fix Procfile
2014-11-14 08:39:08 -08:00
6f7fd89ba2 Merge pull request #1718 from yichengq/226
sender: support elegant stop
2014-11-13 21:29:02 -08:00
12dba7d413 sender: support elegant stop 2014-11-13 17:44:36 -08:00
e66bda957b Merge pull request #1714 from xiang90/stop
StopNotify
2014-11-13 15:16:52 -08:00
6a1fe00615 Merge pull request #1704 from xiang90/print_config
*: print out configuration when necessary
2014-11-13 14:35:50 -08:00
11f392bdc8 Merge pull request #1708 from yichengq/223
etcdserver: validate new node is not registered before in best effort
2014-11-13 14:30:40 -08:00
b5d480f17a etcdserver: add StopNotify 2014-11-13 14:16:48 -08:00
978d0f1ca1 etcdserver: fix TestDoProposalStopped test
We start etcd server in this test without the cluster. Sometimes it panics when
accessing the cluster. Most of the time it does not panic, since we can stop the
server fast enough before applying the first configuration change entry.
2014-11-13 14:08:59 -08:00
fb344bc33f etcdserver: minor cleanup 2014-11-13 14:01:56 -08:00
813ff6ba48 Merge pull request #1713 from xiang90/stop
etcdserver: fix server.Stop()
2014-11-13 13:58:07 -08:00
ac907d746b etcdserver: validate new node is not registered before in best effort 2014-11-13 13:56:11 -08:00
30dfdb0ea9 etcdserver: fix server.Stop()
Stop should be idempotent. It should simply send a stop signal to the server.
It is the server's responsibility to stop the go-routines and related components.
2014-11-13 13:47:12 -08:00
0e8ffe9128 raft: remove a guard that is no longer necessary 2014-11-13 15:51:36 -05:00
39eddd8565 Merge remote-tracking branch 'coreos/master' into log-storage-interface
* coreos/master:
  etcdserver: add sender tests
  raft: Only call stableTo when we have ready entries or a snapshot.
  etcdserver: add ID() function to the Server interface.
  sender: use RoundTripper instead of Client in sender
2014-11-13 15:50:08 -05:00
8c4494a39d Merge pull request #1711 from bdarnell/stable-restart
raft: Only call stableTo when we have ready entries or a snapshot.
2014-11-13 12:49:19 -08:00
9716def94b Merge pull request #1700 from yichengq/222
etcdserver: add sender tests
2014-11-13 12:37:29 -08:00
d89bf9f215 etcdserver: add sender tests 2014-11-13 12:29:25 -08:00
32824e053c raft: Only call stableTo when we have ready entries or a snapshot.
The first Ready after RestartNode (with no snapshot) will have no
unstable entries, so we don't have the correct prevLastUnstablei
when Advance is called. This would cause raftLog.unstable to move
backwards and previously-stable entries would be returned to
the application again.

This should have been caught by the "unexpected Ready" portion of
TestNodeRestart, but it went unnoticed because the Node's goroutine
takes some time to read from advancec and prepare the write to read to
readyc. Added a small (1ms) delay to all such tests to ensure that the
goroutine has time to enter its select wait.
2014-11-13 14:57:01 -05:00
8319d4dcbe Merge pull request #1709 from xiang90/server_id
etcdserver: add ID() function to the Server interface.
2014-11-13 11:37:39 -08:00
d6f40acc86 etcdserver: add ID() function to the Server interface. 2014-11-13 11:37:06 -08:00
b29c512f50 Merge remote-tracking branch 'coreos/master' into log-storage-interface
* coreos/master: (27 commits)
  pkg/wait: move wait to pkg/wait
  etcdserver: do not add/remove/update local member to/from sender hub
  etcdserver: not record attributes when add member
  raft: add a test for proposeConfChange
  raft: block Stop() on n.done, support idempotency
  raft: add a test for node proposal
  integration: add increase cluster size test
  integration: remove unnecessary t.Testing argument
  raft: stop the node synchronously
  integration: fix test to propagate NewServer errors
  etcdserver: move peer URLs check to config
  etcdserver: ensure initial-advertise-peer-urls match initial-cluster
  raft: add a test for node.Tick
  raft: add comment string for TestNodeStart
  etcdserver: use member instead of node at etcd level
  raft: nodes return sorted ids
  raft: update unstable when calling stableTo with 0
  *: support updating advertise-peer-url Users might want to update the peerurl of the etcd member in several cases. For example, if the IP address of the physical machine etcd running on is changed, user need to update the adversite-pee-rurl accordingly. This commit makes etcd support updating the advertise-peer-url of its members.
  transport: create a tls listener only if the tlsInfo is not empty and the scheme is HTTPS
  etcdserver: use member pointer for all tests
  ...

Conflicts:
	etcdserver/server.go
	raft/log.go
	raft/log_test.go
	raft/node.go
2014-11-13 14:21:09 -05:00
92096dfdc3 *: print out configuration when necessary 2014-11-13 10:46:42 -08:00
a551b75d96 Merge pull request #1707 from xiang90/wait_pkg
pkg/wait: move wait to pkg/wait
2014-11-13 09:31:34 -08:00
0d18a0f381 pkg/wait: move wait to pkg/wait 2014-11-13 09:11:53 -08:00
23b5bc0dfe sender: use RoundTripper instead of Client in sender 2014-11-12 21:42:08 -08:00
1e1535e6f9 Merge pull request #1620 from yichengq/204
etcdserver: not record attributes when add member
2014-11-12 21:33:53 -08:00
4adbd821a3 Merge pull request #1706 from xiang90/fix_sender_hub_add
etcdserver: do not add/remove/update local member to/from sender hub
2014-11-12 21:29:33 -08:00
04994048bb Merge pull request #1702 from xiang90/node_config_propose
raft: add a test for proposeConfChange
2014-11-12 21:16:54 -08:00
ba915ad5a8 etcdserver: do not add/remove/update local member to/from sender hub 2014-11-12 20:45:21 -08:00
84ecb89774 *: fix Procfile 2014-11-12 17:54:09 -08:00
0c2b45ddc6 etcdserver: not record attributes when add member
There is no need to set attributes value when adding member because new
member will publish the information whenever it starts.
2014-11-12 17:48:15 -08:00
eb66d2b0eb Merge pull request #1699 from jonboulle/node_stop
raft: block Stop() on n.done, support idempotency
2014-11-12 16:26:54 -08:00
2a407dadc0 raft: add a test for proposeConfChange 2014-11-12 16:16:26 -08:00
634011eb8b Merge pull request #1698 from xiang90/node_propose
raft: add a test for node proposal
2014-11-12 16:02:57 -08:00
2cedf127d4 raft: block Stop() on n.done, support idempotency 2014-11-12 15:54:45 -08:00
68ab7e69e1 raft: add a test for node proposal 2014-11-12 15:44:24 -08:00
54b07d7974 Remove raft.loadEnts and the ents parameter to raft.RestartNode.
The initial entries are now provided via the Storage interface.
2014-11-12 18:31:19 -05:00
147fd614ce The initial term=0 log entry is now initially unstable.
This entry is now persisted through the normal flow instead of appearing
in the stored log at creation time.  This is how things worked before
the Storage interface was introduced. (see coreos/etcd#1689)
2014-11-12 18:24:16 -05:00
ec7793557a Merge pull request #1664 from yichengq/212
integration: add AddMember test
2014-11-12 15:04:30 -08:00
b271e88c20 Merge pull request #1696 from xiang90/testnodetick
raft: add a test for node.Tick
2014-11-12 14:38:07 -08:00
bc9de47a9a integration: add increase cluster size test 2014-11-12 14:33:18 -08:00
fc21f299b1 Merge pull request #1676 from jonboulle/doc_initial_cluster
etcdserver: validate and document initial-advertise-peer-urls
2014-11-12 14:13:03 -08:00
5cef3d888a integration: remove unnecessary t.Testing argument 2014-11-12 14:11:56 -08:00
d834324e97 raft: stop the node synchronously 2014-11-12 14:06:52 -08:00
76a3de9a33 Require a non-nil Storage parameter in newLog.
Callers must in general have a reference to their Storage objects to
transfer entries from Ready to Storage, so it doesn't make sense to
create a hidden Storage for them.

By explicitly creating Storage objects in tests we can remove a
few casts of raftLog's storage field.
2014-11-12 16:38:50 -05:00
d1ae276434 integration: fix test to propagate NewServer errors 2014-11-12 13:12:49 -08:00
1197c1f965 etcdserver: move peer URLs check to config 2014-11-12 13:12:49 -08:00
3f358b6d5d etcdserver: ensure initial-advertise-peer-urls match initial-cluster
This adds a check to setupCluster to ensure that the list of URLs
specified in `initial-advertise-peer-urls` matches those configured in
`initial-cluster` for this node. Also updates the documentation to
clarify this and address some changes in wording.
2014-11-12 12:54:35 -08:00
45c36a0808 raft: add a test for node.Tick 2014-11-12 11:51:51 -08:00
0772987128 Merge pull request #1695 from xiang90/nodestart
raft: add comment string for TestNodeStart
2014-11-12 11:41:03 -08:00
fe0325fce7 raft: add comment string for TestNodeStart 2014-11-12 11:40:40 -08:00
f1f796f2fc Merge pull request #1694 from xiang90/use_member
etcdserver: use member instead of node at etcd level
2014-11-12 10:48:45 -08:00
0aa8258d29 etcdserver: use member instead of node at etcd level 2014-11-12 10:45:35 -08:00
fb93e3fa00 Merge pull request #1689 from yichengq/219
raft: update unstable when calling stableTo with 0
2014-11-12 10:41:40 -08:00
d494014782 Merge pull request #1679 from xiang90/peerurl
update peer url
2014-11-12 10:21:13 -08:00
48644f465d Merge pull request #1692 from yichengq/221
raft: nodes return sorted ids
2014-11-12 10:08:19 -08:00
78cbb1512c raft: nodes return sorted ids
This makes raft.softState return the same result when its soft state is
not changed.
2014-11-11 22:58:15 -08:00
7dba92dd53 raft: update unstable when calling stableTo with 0
It should update unstable in this case because it may happen that raft
only writes entry 0 into stable storage.
2014-11-11 17:20:31 -08:00
3f3fc05c8f Merge pull request #1687 from xiang90/fix_listener
Fix listener
2014-11-11 13:10:51 -08:00
5967794009 *: support updating advertise-peer-url
Users might want to update the peerurl of the etcd member in several cases.
For example, if the IP address of the physical machine etcd running on is
changed, user need to update the adversite-pee-rurl accordingly.
This commit makes etcd support updating the advertise-peer-url of its members.
2014-11-11 12:07:03 -08:00
b6f0c789b8 transport: create a tls listener only if the tlsInfo is not empty and the scheme is HTTPS 2014-11-11 11:51:57 -08:00
b87243d827 Merge pull request #1688 from xiang90/cluster_test
Cluster test
2014-11-11 11:36:08 -08:00
67a0de4bbc etcdserver: use member pointer for all tests 2014-11-11 11:20:56 -08:00
e4931e0c47 etcdserver: remove unnecessary newTestMemberp 2014-11-11 11:09:33 -08:00
077e144e8a etcdserver: move newTestMember* to member_test.go 2014-11-11 11:02:50 -08:00
4b2d6fc70b Merge pull request #1686 from xiang90/proto
raftpb: fix proto
2014-11-10 17:08:24 -08:00
f64963de88 raftpb: fix proto 2014-11-10 17:05:30 -08:00
246ba4301d Merge pull request #1682 from yichengq/217
integration: rewrite the way to check cluster make progress
2014-11-10 16:58:17 -08:00
24edf57e12 integration: newMember -> mustNewMember 2014-11-10 16:53:15 -08:00
b1c3c4a202 integration: rewrite the way to check cluster make progress 2014-11-10 16:53:07 -08:00
50ffd87831 Merge pull request #1685 from xiang90/proxy
proxy: return JSON errors
2014-11-10 16:51:25 -08:00
424377f859 proxy: add a todo for logging 2014-11-10 16:37:15 -08:00
6fa8f77638 proxy: return JSON errors 2014-11-10 15:56:42 -08:00
25b6590547 raft: introduce log storage interface.
This change splits the raftLog.entries array into an in-memory
"unstable" list and a pluggable interface for retrieving entries that
have been persisted to disk. An in-memory implementation of this
interface is provided which behaves the same as the old version;
in a future commit etcdserver could replace the MemoryStorage with
one backed by the WAL.
2014-11-10 17:40:39 -05:00
ac77971f99 Merge pull request #1671 from xiang90/proxy_doc
doc: add doc for proxy
2014-11-10 13:39:03 -08:00
645cfb8355 Merge pull request #1681 from jonboulle/fix_exit
etcdmain: do not exit inappropriately
2014-11-10 12:34:36 -08:00
e1e454f138 etcdmain: do not exit inappropriately 2014-11-10 12:34:14 -08:00
a0002d0598 doc: add fallback to discovery section in clustering.md 2014-11-10 12:14:19 -08:00
99aa2caa3d Merge pull request #1680 from jonboulle/fix_errors
etcdmain: actually return errors
2014-11-10 12:04:05 -08:00
8799679083 etcdmain: actually return errors 2014-11-10 11:59:59 -08:00
2dcd8213e4 Merge pull request #1670 from yichengq/207
integration: add basic discovery tests
2014-11-10 10:30:20 -08:00
5396037450 integration: add basic discovery tests 2014-11-10 10:04:30 -08:00
1e299d8232 doc: add doc for proxy 2014-11-08 19:59:24 -08:00
8870b739b3 Merge pull request #1661 from jonboulle/wal_errors
wal: propagate errors
2014-11-08 17:16:48 -08:00
5a964f49a5 wal: propagate errors 2014-11-08 17:16:23 -08:00
aca58ec605 Merge pull request #1655 from jonboulle/wal_logic
etcdserver: collapse shared readWAL logic
2014-11-08 17:07:43 -08:00
41757e7f78 etcdserver: collapse shared readWAL logic 2014-11-08 17:07:05 -08:00
f333c7ff87 Merge pull request #1668 from yichengq/214
integration: wait cluster to be stable before return launch
2014-11-08 15:54:31 -08:00
071ebb9feb integration: wait cluster to be stable before return launch
The wait ensures that cluster goes into the stable stage, which means that
leader has been elected and starts to heartbeat to followers.

This makes future client requests always handled in time, and there is no
need to retry sending requests.
2014-11-08 15:39:10 -08:00
aa72cda7b2 Merge pull request #1667 from yichengq/213
etcdserver: not get cluster info from self peer urls
2014-11-08 14:05:20 -08:00
4b9c3a9102 etcdserver: not get cluster info from self peer urls
Self peer urls have not started to serve at the time that it tries to
get cluster info, so it is useless to get cluster info from self peer
urls.
2014-11-08 13:52:48 -08:00
0b493ac8d4 version: bump to alpha.2 2014-11-07 16:44:02 -08:00
c73d41d98b Merge pull request #1658 from jonboulle/doc_etcdctl_backup
Add doc for backup and force-new-cluster
2014-11-07 16:39:45 -08:00
3d2f65fc0d docs: clarify rewriting 2014-11-07 16:35:33 -08:00
6b283f6ea1 docs: reword failure descriptions 2014-11-07 16:34:19 -08:00
4367c9a1db docs: no need to stop etcd while doing backup 2014-11-07 16:25:38 -08:00
c9894687fc Merge pull request #1662 from yichengq/211
etcdserver: fix data race in cluster
2014-11-07 16:20:59 -08:00
a56fa60fb4 doc: add backup/restore guide 2014-11-07 16:14:45 -08:00
014ef0f52d etcdserver: fix data race in cluster
The data race happens when etcd updates member attributes and fetches
member info in http handler at the same time.
2014-11-07 16:13:07 -08:00
2fc47034ee Merge pull request #1660 from yichengq/209
etcdserver: not add sender when it has existed
2014-11-07 16:10:50 -08:00
46cbfbc630 etcdserver: not add sender when it has existed 2014-11-07 14:05:00 -08:00
d3fd10798b Merge pull request #1656 from jonboulle/1656_sender_garbage
sender logs garbage
2014-11-07 13:44:18 -08:00
a6ba4d357c Merge pull request #1474 from jonboulle/1474_print_peers
print out remote peers' information and config change in the cluster
2014-11-07 13:39:32 -08:00
e707af7c3a Merge pull request #1654 from yichengq/208
integration: use client to do requests
2014-11-07 13:37:14 -08:00
ca06fd0060 etcdserver: log cluster when adding/removing node 2014-11-07 13:36:41 -08:00
958ade86a5 etcdserver: log message after loading peers from snapshot 2014-11-07 13:34:43 -08:00
85a4477f71 integration: use client to do requests 2014-11-07 13:34:30 -08:00
38ec84693f etcdserver: clean up sender error message 2014-11-07 13:32:44 -08:00
78865aa7f7 Merge pull request #1657 from xiangli-cmu/backup
*: add ctl backup support
2014-11-07 13:30:54 -08:00
0d541e6338 *: add ctl backup support 2014-11-07 13:27:44 -08:00
5f6e536be8 Merge pull request #1639 from bcwaldon/etcdctl-tls
Wire up TLS flags for etcdctl
2014-11-07 13:19:36 -08:00
4f85a68c25 Merge pull request #1650 from jonboulle/build_release
scripts: clean build-release script a bit
2014-11-07 12:51:30 -08:00
c3aae88b0c Merge pull request #1653 from jonboulle/server_order
etcdserver: re-order ServerConfig fields
2014-11-07 12:28:29 -08:00
32a82bb423 Merge pull request #1651 from jonboulle/discard
etcdserver: discard log output in tests
2014-11-07 12:05:40 -08:00
285cd404e3 etcdserver: print peerURLs when adding member 2014-11-07 12:00:41 -08:00
a607e097c6 etcdserver: re-order ServerConfig fields 2014-11-07 11:45:59 -08:00
55b4ff0cdf etcdserver: discard log output in tests 2014-11-07 11:45:46 -08:00
82094f05e0 scripts: clean build-release script a bit 2014-11-07 11:45:40 -08:00
c4f273478d Merge pull request #1652 from jonboulle/fix_tests
etcdserver: sort IDs and s/getIDset/getIDs/
2014-11-07 11:43:51 -08:00
14e1442d2d etcdserver: sort IDs and s/getIDset/getIDs/ 2014-11-07 10:57:42 -08:00
810a5146dd Merge pull request #1635 from jonboulle/doc
etcdserver: add docstrings for confchanges
2014-11-07 10:20:05 -08:00
5055863e09 etcdserver: add docstrings for confchanges 2014-11-07 10:19:55 -08:00
bf47fe7cac Merge pull request #1647 from xiangli-cmu/force_cluster
etcdserver: force new cluster
2014-11-07 10:15:53 -08:00
9d19429993 Merge pull request #1609 from yichengq/202
etcdserver: refactor sender
2014-11-07 10:12:02 -08:00
142dfc7d88 etcdserver: add doc for getIDset 2014-11-07 09:00:58 -08:00
0a9c6164af etcdserver: add support for force cluster 2014-11-07 08:49:01 -08:00
376268391b Merge pull request #1646 from jonboulle/1536_disco_proxy
discovery: add command line flag for discovery-proxy
2014-11-07 08:32:23 -08:00
d6f37ec9ad Merge pull request #1648 from jonboulle/delete_member_404
etcdhttp: return 404 when removing nonexistent member
2014-11-06 17:24:17 -08:00
ca1b30db10 etcdhttp: return 404 when removing nonexistent member 2014-11-06 16:59:40 -08:00
9454d30854 etcdserver: add sendHub tests 2014-11-06 16:49:13 -08:00
f75e56932a Merge pull request #1643 from jonboulle/fix_flags
pkg: fix SetFlagsFromEnv behaviour
2014-11-06 16:43:21 -08:00
5604b4c57c flag: split out SetFlagsFromEnvBad test; declare return error 2014-11-06 16:40:13 -08:00
8f1885a398 discovery: add command line flag for discovery-proxy 2014-11-06 16:35:24 -08:00
ccded6644a Merge pull request #1505 from yichengq/193
etcdserver: refactor non-blocking check for sync tests
2014-11-06 15:48:18 -08:00
321d65c4ac pkg: fix SetFlagsFromEnv behaviour
This function was fundamentally buggy, as a panic could be trivially
triggered by setting the wrong environment variable (e.g.
ETCD_BIND_ADDR=foo). Instead, let's propagate the error and present it
to the user in a cleaner way.
2014-11-06 14:39:30 -08:00
c5e6053fcd Merge pull request #1638 from xiangli-cmu/better_logging
etcdserver: better logging for clusterFromPeerURLs
2014-11-06 14:33:53 -08:00
eb0d80767e etcdserver: better logging for clusterFromPeerURLs 2014-11-06 14:28:07 -08:00
6fa031fa69 Merge pull request #1641 from bdarnell/remove-raftlog-reset
raft: remove raftLog.resetUnstable and resetNextEnts
2014-11-06 14:26:08 -08:00
21987c8701 raft: remove raftLog.resetUnstable and resetNextEnts
These methods are no longer used outside of tests and are redundant with
the new stableTo and appliedTo methods.
2014-11-06 17:18:00 -05:00
457b30e585 etcdserver: add/remove sender in sendhub explicitly 2014-11-06 14:04:14 -08:00
2138163c61 etcdserver: code clean on sender struct 2014-11-06 14:04:14 -08:00
211c5e3e29 etcdserver: fix data race in Cluster struct 2014-11-06 14:04:14 -08:00
c3b0de943c etcdserver: discard messages if sender reaches max serving
It is the correct thing to do to ensure that the communication is full
of out-of-date messages.

It results in that integration testing is very easy to throw MsgProp away,
and makes client wait until 5 min timeout. Sync interval and heartbeat are
increased to alleviate the traffic.
2014-11-06 14:04:14 -08:00
1e05cd75c7 etcdserver: refactor sender
1. restrict the number of inflight connections to remote member
2. support stop
2014-11-06 14:04:14 -08:00
2d942e970b etcdctl: add --ca-file, --cert-file, --key-file flags 2014-11-06 12:50:38 -08:00
087e0e8b62 Merge pull request #1636 from xiangli-cmu/client
client: add error handling for addmember
2014-11-06 12:46:15 -08:00
b65dd84e1a Merge pull request #1632 from jonboulle/cs_flag
etcdmain: use StringsFlag for initialclusterstate
2014-11-06 12:36:22 -08:00
66572561bf client: add error handling for addmember 2014-11-06 12:31:24 -08:00
902f06c5c4 pkg/transport: generate TLS client config w/ only CAFile 2014-11-06 12:13:36 -08:00
b53a98eb38 Merge pull request #1631 from xiangli-cmu/validate_doc
Validate doc
2014-11-06 11:45:00 -08:00
a1f5df22ad doc: document conflict case when adding a member 2014-11-06 11:16:49 -08:00
04f6208ace etcdmain: use StringsFlag for initialclusterstate 2014-11-06 11:13:24 -08:00
3cb885c6b2 etcdhttp: return 409 instead of 412 when there is a conflict when adding a member 2014-11-06 11:07:25 -08:00
f4ea274555 etcdctl: centralize getEndpoints logic 2014-11-06 10:54:59 -08:00
4b555dba99 client: add SyncableHTTPClient.Endpoints 2014-11-06 10:54:56 -08:00
9c8f9b3560 Merge pull request #1585 from coreos/clean-up-other-apis-docs
docs: clean up other apis
2014-11-06 10:48:02 -08:00
4ed60471fe Merge pull request #1627 from xiangli-cmu/validate_peer_url
etcdserver: validate peerurl when adding members
2014-11-06 10:43:22 -08:00
7d28d80e5a Merge pull request #1626 from jonboulle/proxy_stuff
discovery: simplify interface
2014-11-06 10:09:16 -08:00
45d7ef99c4 Merge pull request #1629 from asmundg/x-fix-typo
Fix typo in docs
2014-11-06 09:58:54 -08:00
0d8345e0c1 Fix typo in docs
Suggesting that users add two nodes with the same name is probably not a
good idea.
2014-11-06 10:49:40 +01:00
2760739ceb Merge pull request #1625 from yichengq/205
docs: describe the lifetime of discovery url
2014-11-06 00:32:49 -08:00
5d755bd54a docs: describe the lifetime of discovery url 2014-11-06 00:31:19 -08:00
bd2b18b6de etcdserver: validate peerurl when adding members 2014-11-05 23:12:48 -08:00
68bca981de discovery: simplify interface
There's no real need to expose a Discoverer interface/struct when the
only use of the interface (and indeed the module) is to invoke a single
function. This isn't Java, after all. So instead, simplify to Discovery
exposing just two functions: JoinCluster (i.e. what was formerly called
"discovery"), and GetCluster (hitherto "ProxyDiscovery")
2014-11-05 22:45:01 -08:00
6fdbb086f4 Merge pull request #1623 from xiangli-cmu/valid_configuration
Valid configuration
2014-11-05 18:13:04 -08:00
99b1af40c6 etcdserver: move config validation to cluster 2014-11-05 17:55:07 -08:00
99bb479a60 Merge pull request #1618 from yichengq/203
etcdserver: improve panic message in Cluster
2014-11-05 17:14:26 -08:00
98406af448 cluster: separate out membersFromStore from newClusterFromStore 2014-11-05 15:56:43 -08:00
6c9169b4f4 etcdserver: improve panic message in Cluster 2014-11-05 15:39:28 -08:00
3fc6f9c24f Merge pull request #1586 from xiangli-cmu/fix_node
*: add Advance interface to raft.Node
2014-11-05 15:09:51 -08:00
0d7c43d885 *: add a Advance interface to raft.Node
Node set the applied to committed right after it sends out Ready to application. This is not
correct since the application has not actually applied the entries at that point. We add a
Advance interface to Node. Application needs to call Advance to tell raft Node its progress.
Also this change can avoid unnecessary copying when application is still applying entires but
there are more entries to be applied.
2014-11-05 15:04:14 -08:00
c5140d5c18 Merge pull request #1614 from yichengq/194
*: handle panic and fatal organizedly
2014-11-05 14:08:35 -08:00
fdb82718e0 Merge pull request #1612 from jonboulle/proxy
proxy: add docstrings
2014-11-05 13:56:24 -08:00
791b2fd503 *: handle panic and fatal more consistently
1. etcd fatals if there is critical error in the system and operator should
do something for it
2. etcd panics if there happens something unexpected, and it should be
reported to us to debug.
2014-11-05 13:53:24 -08:00
3c3cae57c6 Merge pull request #1616 from jonboulle/philips-add-error-to-test
test: add error package
2014-11-05 13:40:58 -08:00
bdd2a0a018 test: add error package 2014-11-05 13:31:42 -08:00
c6104c1e2a Merge pull request #1613 from jonboulle/proxy_clean
etcdmain: simplify proxy start logic
2014-11-05 11:41:15 -08:00
b85496922f etcdmain: simplify proxy start logic 2014-11-05 11:41:03 -08:00
89eac70d09 proxy: add docstrings 2014-11-05 10:30:05 -08:00
58b171b3e5 Merge pull request #1610 from jonboulle/discovery_docs
discovery: add clarifying docstrings
2014-11-04 19:38:59 -08:00
bb84aaebaf discovery: add clarifying docstrings 2014-11-04 17:02:33 -08:00
ab00d23cd3 Merge pull request #1608 from jonboulle/flags
pkg: move to more generic StringsFlag
2014-11-04 16:53:48 -08:00
5de9d38cc6 pkg: move to more generic StringsFlag 2014-11-04 16:52:56 -08:00
d36f09d643 Merge pull request #1602 from jonboulle/bump_timeout
integration: bump timeout for good path
2014-11-04 16:52:44 -08:00
f71c247d87 Merge pull request #1604 from xiangli-cmu/fallback_proxy
*: support discovery fallback
2014-11-04 16:41:28 -08:00
71acd0c3d0 discovery: consolidate proxyDiscover and Discover interface 2014-11-04 16:38:05 -08:00
288624550e Merge pull request #1581 from jonboulle/log_changes
No logs when members added/removed from cluster
2014-11-04 15:13:12 -08:00
e4d0c25365 etcdserver: log adding and removing nodes 2014-11-04 15:05:15 -08:00
c628d7f412 Merge pull request #1601 from jonboulle/client
client: return ErrNoEndpoint when none available
2014-11-04 14:58:22 -08:00
5cb13fd071 *: support discovery fallback 2014-11-04 14:30:22 -08:00
9e001dee29 Merge pull request #1603 from jonboulle/typo
etcdhttp: fix typo in test comment
2014-11-04 13:18:12 -08:00
4d40816a90 etcdserver: refactor non-blocking check for sync tests
to make it much more reliable and avoid false errors.
2014-11-04 13:07:44 -08:00
0f7add9722 etcdhttp: fix typo in test comment 2014-11-04 12:57:59 -08:00
9f29545f66 integration: bump timeout for good path
When waiting for a watch result, we expect the good path to complete
quickly here so we don't need to time out so aggressively. (Failure
noted in #1600)
2014-11-04 12:55:40 -08:00
45b7c9a4ac client: return ErrNoEndpoint when none available
In certain cases (for example, if a cluster peer is accessible but it
has no members listed), the httpClusterClient could have an empty set of
endpoints as a result of the Sync. This means that its Do function could
potentially return a nil response and nil error, with catastrophic
consequences for callers.

To be safe (particularly about this latter behaviour), this change
errors in both Sync and Do if no endpoints are available.
2014-11-04 12:51:43 -08:00
34dabe281b Merge pull request #1591 from philips/application-json-errors
error: use application/json as the content-type
2014-11-04 12:31:06 -08:00
5fbef59dbc error: use application/json as the content-type
Fixes #1584
2014-11-04 12:08:18 -08:00
915f8f4822 Merge pull request #1531 from jonboulle/410_gone
return 410 Gone for member that has been removed in /v2/members -XDELETE
2014-11-04 11:54:01 -08:00
cedcc0d8df etchttp: return 410 gone for permanently removed members 2014-11-04 11:21:24 -08:00
ac49e1d50f Merge pull request #1594 from unihorn/201
etcdhttp/etcdserver: support HEAD on /v2/keys/ namespace
2014-11-04 00:11:47 -08:00
866ec5948c etcdhttp/etcdserver: support HEAD on /v2/keys/ namespace 2014-11-04 00:06:49 -08:00
aa5711bd0f Merge pull request #1595 from jonboulle/header
*: add copyright header to remaining files
2014-11-03 23:42:14 -08:00
f7434b55e5 *: add copyright header to remaining files 2014-11-03 23:29:15 -08:00
2235b47030 Merge pull request #1545 from unihorn/197
etcdhttp: always respond json-format error to client
2014-11-03 23:25:14 -08:00
5ead800ff5 Merge pull request #1572 from xiangli-cmu/raft_test
raft: add paper tests for section 5.4.1
2014-11-03 22:37:26 -08:00
e4b12a8e28 Merge pull request #1593 from unihorn/200
etcdserver: print out initial cluster members
2014-11-03 22:23:40 -08:00
9aefb91531 etcdhttp: always respond json-format error to client 2014-11-03 22:19:17 -08:00
5ed5d44652 etcdserver: print out initial cluster members
It is moved from etcdmain pkg because the line should only be printed out
when etcd bootstraps at the first time.
2014-11-03 19:34:24 -08:00
cc0ef16346 docs: clean up other apis
The docs for the other APIs use curl for example usage, which matches
the docs for the etcd APIs.

Other cleanup include fixing usage of peer ports and using 10.0.0.x IPs
throughout.
2014-11-03 17:14:08 -08:00
a272f5d7e3 Merge pull request #1592 from jonboulle/integration_tests
integration: add keys API integration tests
2014-11-03 16:31:59 -08:00
63cf0b9d90 integration: add keys API integration tests 2014-11-03 16:30:29 -08:00
ab69c2adbd etcdhttp: use EcodePrevValueRequired when appropriate 2014-11-03 16:12:50 -08:00
075ab6415f Merge pull request #1587 from xiangli-cmu/fix_wal
wal: sync before returning from create
2014-11-03 15:58:47 -08:00
dd09042632 etcdserver: try to listen on ports before initializing etcd server 2014-11-03 15:55:58 -08:00
165ac654e8 raft: add paper tests for section 5.4.1 2014-11-03 15:50:56 -08:00
dbdeceda7b raft: do not load empty state and ents 2014-11-03 15:16:41 -08:00
ff1f5a9d57 wal: sync before returning from create 2014-11-03 14:28:59 -08:00
d1ec13210f Merge pull request #1571 from bcwaldon/client-redirects
client: follow redirects
2014-11-03 14:26:20 -08:00
2ba02c04be Merge pull request #1576 from coreos/print-initial-cluster-members
etcd: print initial cluster members during startup
2014-11-03 14:24:33 -08:00
6dd4944e62 client: follow redirects 2014-11-03 12:15:16 -08:00
5da481213e Merge pull request #1478 from unihorn/190
etcdserver: panic on storage error
2014-11-03 11:07:55 -08:00
433b4138c5 etcdserver: panic on storage error
It is a critical error to etcd, and etcd is not able to recover it now.
2014-11-03 10:46:04 -08:00
729770f32a Merge pull request #1570 from bcwaldon/client-endpoints
client: use all endpoints
2014-11-03 10:44:09 -08:00
3ec4da6ac6 etcd: print initial cluster members during startup
etcd now prints the initial clusters members during startup.

```
2014/11/03 10:32:46 etcd: initial cluster members: etcd0=http://127.0.0.1:2380,etcd1=http://127.0.0.1:2390,etcd2=http://127.0.0.1:2400
```
2014-11-03 10:38:18 -08:00
9df06bfa94 Merge pull request #1579 from coreos/cleanup-clustering-doc
docs: clean up clustering doc
2014-11-03 10:25:04 -08:00
20df86e3c3 docs: clean up clustering doc 2014-11-03 09:51:50 -08:00
6433be5738 Merge pull request #1575 from coreos/improve-admin-docs
docs: fix usage of peers urls
2014-11-02 22:56:23 -08:00
3068340a83 docs: fix usage of peers urls 2014-11-02 22:00:41 -08:00
da6827f09e client: use all endpoints 2014-10-31 20:51:47 -07:00
75104c10d4 Merge pull request #1553 from bcwaldon/client-sync
Support syncing and `--no-sync` flag in `etcdctl member` commands
2014-10-31 20:51:01 -07:00
58af26736c client: further clarify external interfaces 2014-10-31 20:45:55 -07:00
17c6f21d68 client: elevate context to caller of KeysAPI 2014-10-31 17:27:43 -07:00
f0760d6246 client: elevate context to caller of MembersAPI 2014-10-31 17:27:42 -07:00
913d102a81 client: remove unused field 2014-10-31 17:25:05 -07:00
824049897d client: export necessary interfaces/methods 2014-10-31 17:25:05 -07:00
b47631b38f etcdctl: respect --no-sync in member subcommands 2014-10-31 17:25:05 -07:00
22b86684f0 etcdctl: sync before running member subcommands 2014-10-31 17:25:05 -07:00
5ed5d018be client: add httpClusterClient.Sync 2014-10-31 17:25:05 -07:00
f6e8b677cf client: pass httpActionDo into NewMembersAPI 2014-10-31 17:25:05 -07:00
0ef270c25c client: pass httpActionDo into New[Discovery]KeysAPI 2014-10-31 17:25:05 -07:00
1130273178 client: s/newHTTPClusterClient/NewHTTPClient/ 2014-10-31 17:25:05 -07:00
3eb126af4d client: use httpActionDo in httpClusterClient 2014-10-31 17:25:05 -07:00
c282664c23 client: s/transport/CancelableTransport/
CancelableTransport is implemented by callers of the
client pkg, so we should export it so it is
documented publicly.
2014-10-31 17:25:04 -07:00
d52d836761 client: return full http.Response in httpActionDo 2014-10-31 17:25:04 -07:00
5bdf6a4110 Merge pull request #1528 from unihorn/191
raft: add tests based on section 5.3 in raft paper
2014-10-31 16:35:36 -07:00
421d5fbe72 raft: add tests based on section 5.3 in raft paper 2014-10-31 16:32:34 -07:00
f35130a0ed etcdctl: clean up formatting of member add 2014-10-31 15:37:08 -07:00
500e9e2212 version: bump to v0.5.0-alpha.1 2014-10-31 15:22:13 -07:00
7c52a86325 Merge pull request #1569 from philips/dynamic-configuration-docs
Documentation: add the runtime configuration document
2014-10-31 15:19:42 -07:00
124dd7096a Documentation: add the runtime configuration document 2014-10-31 15:16:45 -07:00
388b4aeb71 Merge pull request #1568 from philips/dynamic-configuration
etcdctl: two member fixes
2014-10-31 15:08:40 -07:00
6b4485d1ae etcdctl: take a name and print out the initial cluster
To help the user lets print out the configuration that they will need to give
to their new member:

$ etcdctl member add infra4 http://localhost:7004
added member 9bf1b35fc7761a23 to cluster
ETCD_NAME="infra4"
ETCD_INITIAL_CLUSTER="node2=http://localhost:7002,node3=http://localhost:7003,infra4=http://localhost:7004,node1=http://localhost:7001"

This is a little weird because the API doesn't take a name so the user gives us
a name and we just pass it on through.
2014-10-31 15:05:23 -07:00
74886713db Merge pull request #1567 from unihorn/199
*: name node{1,2,3} -> infra{1,2,3}
2014-10-31 14:53:34 -07:00
8f3be206ed etcdctl: add help on the members subcommands 2014-10-31 14:50:23 -07:00
1db23109ad *: name node{1,2,3} -> infra{1,2,3}
Be consistent with the naming in documentations.
2014-10-31 14:46:39 -07:00
749097429f Merge pull request #1565 from jonboulle/int
integration: clean up licenses and docs
2014-10-31 14:34:05 -07:00
34b2fecd28 integration: clean up licenses and docs 2014-10-31 14:33:56 -07:00
faede90293 Merge pull request #1556 from philips/fixup-the-admin-guide
Documentation: fixup the admin_guide
2014-10-31 14:11:39 -07:00
b6cc34b52e Documentation: fixup the admin_guide
- Provide more concrete examples and explanation
- Cleanup the formatting to one sentence per line, this makes reviewing
  easier
- Point to existing docs on wal and snap instead of trying to duplicate
  it here again.
2014-10-31 14:11:27 -07:00
308b8796e4 Merge pull request #1557 from bcwaldon/id-logging
etcdserver: fix logging of IDs
2014-10-31 12:27:37 -07:00
6e038e02a6 etcdserver: fix logging of IDs 2014-10-31 12:26:53 -07:00
38250d3fac Merge pull request #1541 from bcwaldon/client-peers
Use `-peers` in `etcdctl members` commands
2014-10-31 12:26:15 -07:00
eab4692744 client: use v2MembersURL helper 2014-10-31 12:21:15 -07:00
f0c3385cfc etcdctl: wire up --peers for member commands 2014-10-31 12:21:15 -07:00
8b8b3efdaa client: accept slice of endpoints 2014-10-31 12:21:15 -07:00
8d519ffdb8 client: introduce httpClusterClient 2014-10-31 12:21:15 -07:00
323fb1ec85 client: introduce httpActionDo interface 2014-10-31 12:21:15 -07:00
9d07db4432 client: move timeout into caller of httpClient 2014-10-31 12:21:15 -07:00
7c1f4a9baf client: explicitly carry API prefix around 2014-10-31 12:21:15 -07:00
dee912f2fd etcdctl: break out mustNewMembersAPI 2014-10-31 12:21:08 -07:00
bc62b05c7f etcdctl: break out getPeersFlagValue 2014-10-31 12:21:00 -07:00
48ec876af9 godep: bump github.com/codegangsta/cli 2014-10-31 12:21:00 -07:00
a576dbca43 Merge pull request #1554 from xiangli-cmu/removed_logging
etcdserver: better logging when member is removed
2014-10-31 12:07:57 -07:00
eb472b7745 etcdserver: better logging when member is removed 2014-10-31 12:00:50 -07:00
a535161a84 Merge pull request #1552 from philips/fixup-wal-doc
wal: update the docs to show the optional metadata field
2014-10-31 11:32:26 -07:00
513c72ec8b wal: update the docs to show the optional metadata field 2014-10-31 11:32:17 -07:00
e02ef6b141 Merge pull request #1546 from unihorn/198
etcdserver: better logging for assign ids from upstream
2014-10-31 11:13:43 -07:00
2c5f062b7f etcdserver: better logging for assign ids from upstream 2014-10-31 11:06:31 -07:00
1bb07115f2 Merge pull request #1550 from jonboulle/bump_timeout
etcdhttp: bump default Server timeout to 5 mins
2014-10-31 11:05:44 -07:00
9726d3909c etcdhttp: bump default Server timeout to 5 mins 2014-10-31 10:52:46 -07:00
c53e58e97c Merge pull request #1309 from jonboulle/1309_standard_id
standardize ID serialization
2014-10-31 10:50:32 -07:00
55c92ad456 *: create ID type
This creates a simple ID type (wrapped around uint64) to provide for
standard serialization/deserialization to a string (i.e. base 16
encoded). This replaces strutil so now that package is removed.
2014-10-31 10:34:07 -07:00
781abc1db0 Merge pull request #1539 from unihorn/195
*: clean log.Print
2014-10-30 18:18:35 -07:00
aa50af1c69 *: clean log.Print
1. only log things by default that the operator of etcd may need to react to
2. put package name at the head of log lines
2014-10-30 18:15:53 -07:00
7f29045c0f Merge pull request #1543 from xiangli-cmu/fix_logging
etcdserver: fix sender logging
2014-10-30 18:13:16 -07:00
0f8b035253 etcdserver: fix sender logging 2014-10-30 18:00:00 -07:00
42a7c928d4 Merge pull request #1542 from xiangli-cmu/fix_logging
etcdhttp: fix logging in raft handler
2014-10-30 17:41:47 -07:00
02ff59514f etcdhttp: fix logging in raft handler 2014-10-30 17:39:01 -07:00
9a56001d63 Merge pull request #1537 from xiangli-cmu/cluster-token
Cluster token
2014-10-30 17:09:25 -07:00
8e633db5cb doc: add doc for initial-cluster-token 2014-10-30 17:08:15 -07:00
64a12e9341 Merge pull request #1511 from coreos/set-watch-consistency-to-strong
etcdctl: Set watch consistency to STRONG
2014-10-30 16:52:50 -07:00
ac71ad92af Merge pull request #1452 from unihorn/187
etcdserver: exit program when node is removed
2014-10-30 15:32:26 -07:00
ed30b6deca etcdserver: exit program when node is removed
Originally added in 400dd2d7bc,
and removed by mistake when refactor cluster.
2014-10-30 15:31:58 -07:00
76298ebcd8 Merge pull request #1534 from bcwaldon/client-tests
client: test assertStatusCode
2014-10-30 13:50:21 -07:00
d36a3e18d2 etcdctl: remove SetConsistency call
This call to SetConsistency is explicitly setting the default
value, so it's really unnecessary.
2014-10-30 13:45:59 -07:00
3dfb6723b2 *: rename initial-cluster-name to initial-cluster-token 2014-10-30 13:43:38 -07:00
6087e2b2f6 Merge pull request #1509 from bcwaldon/etcdctl-102
etcdctl: add --sort flag to ls command
2014-10-30 13:33:37 -07:00
6e8de1f426 Merge pull request #1508 from bcwaldon/etcdctl-96
etcdctl: add -p to ls command
2014-10-30 13:33:30 -07:00
052521eaf1 client: test assertStatusCode 2014-10-30 11:46:44 -07:00
549c643bfe Merge pull request #1530 from xiangli-cmu/discovery_doc
doc: add a Custom etcd discovery service section
2014-10-30 11:40:23 -07:00
af7d73717c doc: add a Custom etcd discovery service section 2014-10-30 11:34:46 -07:00
816c173edf Merge pull request #1526 from xiangli-cmu/leader_log
raft: better logging for leader transition
2014-10-30 10:13:58 -07:00
9359a57211 Merge pull request #1523 from jonboulle/raft_stuff
raft: minor cleanup in comments
2014-10-30 10:01:59 -07:00
b99633207c raft: minor cleanup in comments 2014-10-30 10:01:44 -07:00
4f6206bf65 Merge pull request #1522 from jonboulle/raft_tests
raft: add tests for progress.maybeDecr
2014-10-30 10:00:01 -07:00
bf44219766 Merge pull request #1492 from jonboulle/1492_nonexistent_member
Attempting to remove nonexistent member mishandled
2014-10-30 09:58:02 -07:00
19881b2f15 etcdhttp: return 404 when removing nonexistent member 2014-10-30 09:57:54 -07:00
46ebf69c02 raft: better logging for leader transition 2014-10-30 09:33:38 -07:00
0cf0cb3d02 raft: add tests for progress.maybeDecr 2014-10-29 22:57:25 -07:00
83ca16188c Merge pull request #1417 from jonboulle/master
RFC: move main logic to etcd subpackage
2014-10-29 18:47:42 -07:00
cf9dd31daa etcd: move main logic to etcdmain subpackage 2014-10-29 18:43:22 -07:00
38617f5c9b Merge pull request #1510 from xiangli-cmu/fix_discovery
discovery: fix discovery for not working on customized discovery service
2014-10-29 18:33:06 -07:00
027e944985 discovery: fix discovery for not working on customized discovery service 2014-10-29 18:30:59 -07:00
2be3f870cc etcdctl: Set watch consistency to STRONG 2014-10-29 18:11:05 -07:00
ba38847bdd Merge pull request #1507 from bcwaldon/doc-fix
doc: link directly to members API
2014-10-29 18:01:27 -07:00
97597eca03 etcdctl: add --sort flag to ls command
This is a port of coreos/etcdctl#102
2014-10-29 17:45:11 -07:00
243886edc8 etcdctl: add -p to ls command
This is a port of coreos/etcdctl#96
2014-10-29 17:42:21 -07:00
f61824ce01 Merge pull request #1500 from bcwaldon/client-tests
Add tests for client pkg
2014-10-29 17:26:26 -07:00
ac810b86bc doc: link directly to members API 2014-10-29 17:21:10 -07:00
e85ba2f384 Merge pull request #1504 from xiangli-cmu/admin_guide
doc: add a doc for data directory
2014-10-29 17:16:27 -07:00
f5c1da6967 doc: add a doc for data directory 2014-10-29 17:07:21 -07:00
0f51cbde6c Merge pull request #1502 from unihorn/192
store: copy Nodes correctly in NodeExtern.Clone
2014-10-29 16:57:04 -07:00
a910d8ba9f store: copy Nodes correctly in NodeExtern.Clone 2014-10-29 16:54:09 -07:00
d756dd2079 client: test membersAPIActionRemove 2014-10-29 16:42:16 -07:00
5264c05ddb client: clean up style of TestMembersAPIActionList 2014-10-29 16:42:16 -07:00
4e759b46ce client: use httptypes.MemberCreateRequest in member add 2014-10-29 16:42:14 -07:00
011a67c878 httptypes: add MemberCreateRequest.MarshalJSON 2014-10-29 16:37:07 -07:00
e457d52f5c client: log incorrect HTTP resp body as string 2014-10-29 16:37:07 -07:00
ccca32b138 Merge pull request #1497 from unihorn/189
raft: add tests based on section 5.1 in raft paper
2014-10-29 16:35:25 -07:00
dabb5c150d raft: add tests based on section 5.1 in raft paper 2014-10-29 16:22:17 -07:00
b7b3bf40e0 Merge pull request #1501 from bcwaldon/rename-members-tests
etcdhttp: s/TestServeAdminMembers*/TestServeMembers*/
2014-10-29 16:21:16 -07:00
2c0f6e4bf9 etcdhttp: s/TestServeAdminMembers*/TestServeMembers*/ 2014-10-29 16:18:03 -07:00
3f6e584702 Merge pull request #1499 from bcwaldon/client_clean
client: pass around statuscode instead of Response
2014-10-29 15:51:58 -07:00
97c23c4333 client: pass around statuscode instead of Response
There's no real need for do and doWithTimeout to return Responses when
the only field of interest is the status code.

This also removes the superfluous httpMembersAPIResponse struct.
2014-10-29 15:47:55 -07:00
95231c1278 Merge pull request #1493 from bcwaldon/etcdctl-members
etcdctl members [list|add|remove]
2014-10-29 15:44:30 -07:00
f810dda9b2 Merge pull request #1481 from bcwaldon/no-more-admin-api
Remove "admin" from /v2/admin/members
2014-10-29 15:43:37 -07:00
f6e242aa01 etcdctl: impl members commands 2014-10-29 15:09:23 -07:00
8b12e1aa37 client: fill in MembersAPI 2014-10-29 15:03:22 -07:00
b59961228b Merge pull request #1495 from xiangli-cmu/fix_raft_test
raft: fix a incorrect in testMaybeAppend
2014-10-29 15:03:13 -07:00
738da2b3fa raft: fix a incorrect in testMaybeAppend 2014-10-29 14:57:39 -07:00
de0cf2fb8e Merge pull request #1459 from bcwaldon/member-list
etcdhttp: encode MembersCollection properly
2014-10-29 14:49:22 -07:00
4b1431109e Merge pull request #1490 from jonboulle/1490
Logging member ID as int
2014-10-29 14:42:02 -07:00
6375bd7960 Merge pull request #1469 from xiangli-cmu/raft_log_test
raft: add tests for maybeappend
2014-10-29 14:36:07 -07:00
e99da41539 etcdserver: log member ID as hex string 2014-10-29 14:36:05 -07:00
14f4163e41 raft: add several test cases for testMaybeAppend 2014-10-29 14:35:13 -07:00
5bba81f5fc Merge pull request #1472 from jonboulle/clone_event
waitIndex is not working
2014-10-29 14:23:32 -07:00
a59e8cf1a6 Merge pull request #1487 from jonboulle/peerurls
etcdserver: make peer URLs log message more readable
2014-10-29 14:23:25 -07:00
9546df9a6c etcdserver: make peer URLs log message more readable 2014-10-29 14:18:51 -07:00
f7631be453 Merge pull request #1485 from jonboulle/raft_clean
raft: move test helper function into tests
2014-10-29 14:06:39 -07:00
81304b2b7e raft: move test helper function into tests 2014-10-29 14:04:45 -07:00
8298e06627 doc: remove trailing slashes 2014-10-29 12:16:02 -07:00
ab67fa4cc6 api: remove admin prefix from members API 2014-10-29 12:12:51 -07:00
bab19e3b0b doc: move admin_api.md to other_apis.md 2014-10-29 12:12:51 -07:00
d3bafd6aa4 etcdhttp: encode MembersCollection properly 2014-10-29 12:06:22 -07:00
84be7c1e9e etcdserver/store: clone Events before modifying 2014-10-29 11:54:35 -07:00
ad1718a3e5 raft: add a test case for testLogMaybeAppend 2014-10-29 11:44:18 -07:00
35bba87d2a Merge pull request #1471 from unihorn/189
raft: add tests based on section 5.2 in raft paper
2014-10-29 10:49:23 -07:00
bffe611fe6 raft: add tests based on section 5.2 in raft paper 2014-10-29 10:17:09 -07:00
6bcfa2b05d Merge pull request #1475 from bketelsen/patch-1
Add Skydns, crypt, viper
2014-10-29 08:55:09 -07:00
3857e92cad Add Skydns, crypt, viper
Added a plethora of tools we've written or contributed to that use etcd.
2014-10-29 09:09:31 -04:00
04e56a454e Merge pull request #1465 from bcwaldon/member-post
Clean up POST /v2/admin/members
2014-10-28 17:08:30 -07:00
658a84312b Merge pull request #1464 from bcwaldon/error-ctype
Set Content-Type before calling WriteHeader
2014-10-28 15:48:23 -07:00
ae7280dcf3 Merge pull request #1466 from jonboulle/errors
main: catch a few unhandled errors
2014-10-28 15:43:57 -07:00
c6873c1eab raft: add tests for maybeappend 2014-10-28 15:07:49 -07:00
a96f5ab146 main: catch a few unhandled errors
If any of this initialization fails, something very bad has happened,
and we should not continue as-is (this has previously manifested in
strange bugs)
2014-10-28 11:18:22 -07:00
6f851ac885 httptypes: set headers before call to WriteHeader 2014-10-28 11:08:10 -07:00
2b4201c53d httptypes: test HTTPError 2014-10-28 10:59:53 -07:00
57d447fef6 Merge pull request #1463 from bcwaldon/writeError-logging
etcdhttp: only log when error deserves it
2014-10-28 10:45:55 -07:00
c07b9ae32e etcdhttp: 415 when content-type not JSON 2014-10-28 10:38:09 -07:00
8fbf887e52 etcdhttp: only log when error deserves it 2014-10-28 10:30:05 -07:00
d1fb732e63 etcdhttp: properly serialize Member on POST 2014-10-28 10:21:11 -07:00
8b0eaa9e15 etcdhttp: separate member create deserialization 2014-10-28 10:09:05 -07:00
ad0664da9c doc: fix documentation of POST /v2/admin/members 2014-10-28 09:44:59 -07:00
b6b5081254 Merge pull request #1450 from bcwaldon/raft-logging
raft: stop logging IDs with 0x prefix
2014-10-28 08:17:11 -07:00
6796669484 raft: stop logging IDs with 0x prefix 2014-10-27 18:56:13 -07:00
87327a245d Merge pull request #1448 from bcwaldon/member-URLs
fix usage of copy in newMemberCollection
2014-10-27 18:43:33 -07:00
e08c2bbe3e Merge pull request #1449 from bcwaldon/id-to-hex
Move ID*Hex functions to pkg/strutil
2014-10-27 18:43:00 -07:00
8d052dd374 etcdhttp: copy Member URLs properly 2014-10-27 18:39:33 -07:00
480e92d340 strutil: move IDAsHex/IDFromHex to new pkg 2014-10-27 18:39:09 -07:00
dad7500d13 Merge pull request #1443 from bcwaldon/member-ID
Serialize member ID in API
2014-10-27 18:38:53 -07:00
d55546d62e Merge pull request #1446 from philips/add-quay-badge
README: add the quay badge to the official git builds
2014-10-27 17:40:50 -07:00
acd8eecd4e README: add the quay badge to the official git builds 2014-10-27 17:39:16 -07:00
2d31e5ab56 Merge pull request #1441 from philips/add-root-dockerfile
Dockerfile: initial commit
2014-10-27 17:27:57 -07:00
2472953939 etcdhttp: hex-encode member ID 2014-10-27 17:25:22 -07:00
80172c3d4a etcdserver: s/parseMemberID/mustParseMemberIDFromKey/ 2014-10-27 17:25:00 -07:00
b316c6b002 Merge pull request #1435 from xiangli-cmu/json
etcdhttp: make admin HTTP endpoint return json format error
2014-10-27 17:07:58 -07:00
6cb45236ac etcdhttp: make admin HTTP endpoint return json format error 2014-10-27 17:03:58 -07:00
04b5853261 Merge pull request #1439 from kelseyhightower/check-data-dir-permissions
etcd: ensure data dir is writable
2014-10-27 16:57:19 -07:00
b1731f0843 etcd: ensure data dir is writable
etcd checks that the data dir is writable by writing and removing an
empty file to the data dir during startup and exits non-zero if that
fails.

fixes #876
2014-10-27 16:52:05 -07:00
36cacb8bd8 Merge pull request #1429 from coreos/1392
Fix #1392
2014-10-27 16:50:46 -07:00
e849d8e157 etcdhttp: DELETE on members = MethodNotAllowed 2014-10-27 16:49:04 -07:00
387639e802 etcdserver/etcdhttp: treat /v2/admin/members and /v2/admin/members/ equally 2014-10-27 16:49:03 -07:00
3e234918ee Dockerfile: initial commit 2014-10-27 16:43:27 -07:00
0ce78d7a9c Merge pull request #1431 from philips/build-release-script
scripts: import script from 0.5 release
2014-10-27 16:42:30 -07:00
52350d1d2f Merge pull request #1433 from philips/add-build-docker-script
scripts: build-docker
2014-10-27 16:42:11 -07:00
7384ee39a6 Merge pull request #1436 from xiangli-cmu/writeTo
error: write->writeTo
2014-10-27 15:34:17 -07:00
d0604c7d5c error: write->writeTo 2014-10-27 15:32:36 -07:00
74c257f63d Merge pull request #1419 from xiangli-cmu/raft_log_test
raft: add test for findConflict
2014-10-27 14:30:36 -07:00
460d6490ba raft: address issues in comments 2014-10-27 14:20:42 -07:00
60cb18b6c2 Merge pull request #1432 from unihorn/187
raft: use raft-specific rand.Rand instead of global one
2014-10-27 14:15:58 -07:00
e8302c8413 scripts: build-docker
Build docker images from the release tarballs. The default CMD is
etcd.
2014-10-27 12:34:51 -07:00
b986a52579 raft: use raft-specific rand.Rand instead of global one 2014-10-27 12:32:11 -07:00
538ce935f0 scripts: import script from 0.5 release
It isn't pretty but this was the tool used to build the zip and tar
files for 0.5
2014-10-27 12:18:24 -07:00
94e4595af5 Merge pull request #1427 from bcwaldon/members-serialization
Centralize Members serialization
2014-10-27 11:33:39 -07:00
753bc5e166 httptypes: add doc.go 2014-10-27 11:22:47 -07:00
80ca168cbe client: simplify MembersAPI response parsing 2014-10-27 11:22:47 -07:00
14795d8ed9 httptypes: use MemberCollection for JSON (de)serialization 2014-10-27 11:22:47 -07:00
7545152318 httptypes: use []string for Member URLs 2014-10-27 11:22:47 -07:00
54a2d8ffc9 client: move Member models to new types pkg 2014-10-27 11:22:46 -07:00
ee27846d5b Merge pull request #1422 from unihorn/187
etcdserver: parse context error for better message
2014-10-27 11:00:01 -07:00
e77f8e311c etcdserver: parse context error for better message 2014-10-27 10:59:15 -07:00
585881a870 Merge pull request #1428 from jonboulle/subpackages
pkg: move everything into subpackages
2014-10-27 10:32:11 -07:00
9964bfa6b9 Merge pull request #1426 from xiangli-cmu/clusterid
etcdhttp: attach clusterID to key and adminMember endpoint
2014-10-27 10:16:16 -07:00
6e6d1897d8 pkg: move everything into subpackages 2014-10-27 09:57:28 -07:00
328d8f2d26 Merge pull request #1424 from bcwaldon/pkg-readme
pkg: add README.md
2014-10-27 09:13:26 -07:00
6f792354ca etcdhttp: attach clusterID to key and adminMember endpoint 2014-10-27 07:52:39 -07:00
40048d7300 Merge pull request #1420 from xiangli-cmu/clean_log
raft: remove unused code
2014-10-26 20:14:05 -07:00
000962d689 Merge pull request #1421 from xiangli-cmu/logging
*: better logging
2014-10-26 20:13:55 -07:00
444e6e952b pkg: add README.md 2014-10-26 16:28:48 -07:00
f9af07eb5b Merge pull request #1423 from bcwaldon/http-refactor-hdlrs
eradicate serverHandler
2014-10-26 14:44:30 -07:00
b06499d0c2 etcdserver/etcdhttp: break apart HTTP handlers 2014-10-26 13:20:53 -07:00
4b77082b6e Merge pull request #1415 from bcwaldon/http-refactor
etcdserver/etcdhttp: break apart http.go
2014-10-26 12:39:22 -07:00
009b737cef *: better logging 2014-10-26 08:13:03 -07:00
94f701cf95 raft: refactor isUpToDate and add a test 2014-10-25 20:34:14 -07:00
8cd95e916d raft: comments for isUpToDate 2014-10-25 20:12:54 -07:00
86c66cd802 raft: remove unused code 2014-10-25 19:56:13 -07:00
90f26e4a56 raft: add test for findConflict 2014-10-25 18:58:11 -07:00
73215447c1 Merge pull request #1414 from bcwaldon/client-members-API
Add MembersAPI w/ List method
2014-10-25 11:33:42 -07:00
cba19e348f client: MembersAPI.List 2014-10-25 11:30:15 -07:00
435611cf0d etcdserver/etcdhttp: break apart http.go 2014-10-25 11:28:52 -07:00
00dcbf8bf7 client: unexport HTTPKeysAPI 2014-10-25 08:58:25 -07:00
73e48068c2 client: add prefix to KeysAPI 2014-10-25 08:58:25 -07:00
2b9cabcbcd version: bump to v0.5.0-alpha.0 2014-10-24 17:25:49 -07:00
2baf3e0d79 Merge pull request #1407 from bcwaldon/old-data-dir
etcd: use old default data-dir format
2014-10-24 16:44:30 -07:00
677d9d1bea etcd: use old default data-dir format 2014-10-24 16:41:42 -07:00
91a4aa151a Merge pull request #1406 from bcwaldon/doc-clustering
doc: PUT instead of POST discovery config
2014-10-24 16:36:54 -07:00
b62fdac193 doc: PUT instead of POST discovery config 2014-10-24 16:30:48 -07:00
e630910e31 Merge pull request #1398 from jonboulle/proxy
proxy not working on master
2014-10-24 15:55:31 -07:00
338f59db74 Merge pull request #1401 from unihorn/186
etcdhttp: parse quorum field from http request
2014-10-24 15:54:40 -07:00
719c57a29d proxy: retrieve ClientURLs from cluster
This is a simple solution to having the proxy keep up to date with the
state of the cluster. Basically, it uses the cluster configuration
provided at start up (i.e. with `-initial-cluster-state`) to determine
where to reach peer(s) in the cluster, and then it will periodically hit
the `/members` endpoint of those peer(s) (using the same mechanism that
`-cluster-state=existing` does to initialise) to update the set of valid
client URLs to proxy to.

This does not address discovery (#1376), and it would probably be better
to update the set of proxyURLs dynamically whenever we fetch the new
state of the cluster; but it needs a bit more thinking to have this done
in a clean way with the proxy interface.

Example in Procfile works again.
2014-10-24 15:54:12 -07:00
0e1d1646fd etcdhttp: parse quorum field from http request 2014-10-24 15:44:39 -07:00
0fcb59e7d9 Merge pull request #1393 from philips/0.5-docs2
Documentation/0.5: add api.md
2014-10-24 15:18:59 -07:00
5456ef7049 Documentation/0.5: add api.md
- Update all of the ports to use the new IANA port numbers
- Update the stats section to talk about the id fields
- Remove mention of the modules
- Remove -L from all of the curl commands since it is no longer needed
- Point people at the clustering.md guide for the cluster APIs
2014-10-24 15:18:47 -07:00
cb59a46576 Merge pull request #1396 from unihorn/185
etcdhttp: trim StoreKeysPrefix from error in serveKeys
2014-10-24 14:48:31 -07:00
46528ee17b Merge pull request #1391 from jonboulle/version
/version is 404 now
2014-10-24 14:48:02 -07:00
9a465b9cf5 etcdhttp: add /version endpoint 2014-10-24 14:47:37 -07:00
dc46d40b8e Merge pull request #1397 from jonboulle/log_raft_msg
etcdserver/etcdhttp: remove log message for every received raft
2014-10-24 14:29:38 -07:00
bac13b5cb2 etcdserver/etcdhttp: remove log message for every received raft 2014-10-24 14:25:20 -07:00
34dcbb4679 etcdhttp: trim StoreKeysPrefix from error in serveKeys
It returns error messaage like this now:
'{"errorCode":100,"message":"Key not found","cause":"/1/pants","index":10}'

The commit trims '/1' prefix from cause field if exists.

This is a hack to make it display well. It is correct because all error causes
that contain Path puts Path at the head of the string.
2014-10-24 14:12:53 -07:00
030aed8205 Merge pull request #1394 from xiangli-cmu/initial-advertise-peer-urls
*: change advertise-peer-urls -> initial-advertise-peer-urls
2014-10-24 14:08:25 -07:00
2e84eb3c36 *: change advertise-peer-urls -> initial-advertise-peer-urls 2014-10-24 13:51:59 -07:00
9a38be297c Merge pull request #1380 from bcwaldon/client-keys-API
Break apart KeysAPI
2014-10-24 13:48:12 -07:00
f21d93ba60 client: define DefaultRequestTimeout 2014-10-24 13:28:04 -07:00
45d8fbdcda client: move discovery path logic into client pkg 2014-10-24 13:28:04 -07:00
ce4df96e69 client: break apart KeysAPI from httpClient 2014-10-24 13:27:59 -07:00
d7f9228133 Merge pull request #1381 from jonboulle/members
/v2/admin/members API should use JSON containers in response
2014-10-24 13:20:10 -07:00
49a68adcf1 Merge pull request #1386 from unihorn/184
etcdserver: update member attribute when apply request
2014-10-24 12:46:11 -07:00
ea0bff80c0 etcdserver: update member attribute when apply request 2014-10-24 12:43:53 -07:00
d1b57b448d Merge pull request #1383 from unihorn/183
etcdserver: support newly-join member bootstrap
2014-10-24 12:43:25 -07:00
08593bcdf6 etcdserver: support newly-join member bootstrap 2014-10-24 12:38:44 -07:00
9fb02eb6fa Merge pull request #1387 from xiangli-cmu/fix_raft
Fix raft
2014-10-24 12:10:54 -07:00
543e12074a etcdserver/member: change JSON fields to lowerCamelCase 2014-10-24 12:03:17 -07:00
14852662ef etcdhttp: rename Members -> members in JSON, update doc 2014-10-24 12:03:17 -07:00
7ef468b315 etcdhttp: remove /v2/admin/members/x serving 2014-10-24 12:03:17 -07:00
9b679de9dd etcdserver/etcdhttp: use container for admin/members endpoint 2014-10-24 12:03:17 -07:00
c8634428fa Merge pull request #1364 from bcwaldon/import-etcdctl
Import etcdctl
2014-10-24 12:02:41 -07:00
507300130b raft: add tests for ignoring heartbeat reply 2014-10-24 11:50:21 -07:00
e081ad7298 Merge pull request #1368 from xiangli-cmu/doc
doc: add admin api doc
2014-10-24 10:42:14 -07:00
85800fd8f6 Merge pull request #1385 from jonboulle/config
etcdserver: fix + expand config tests
2014-10-24 10:10:07 -07:00
0276089ed9 etcdserver: fix + expand config tests 2014-10-24 10:09:42 -07:00
3a41161e76 Merge pull request #1384 from jonboulle/test
etcdserver: add test for cluster.String
2014-10-24 10:03:37 -07:00
b9514ea265 etcdserver: add test for cluster.String 2014-10-24 10:03:28 -07:00
4c9d67aaa2 Merge pull request #1379 from xiangli-cmu/fix_member
etcdserver: fix member endpoint on peerurl
2014-10-23 17:25:40 -07:00
ed29259801 etcdserver: fix member endpoint on peerurl 2014-10-23 17:18:01 -07:00
500d21591f Merge pull request #1377 from bcwaldon/client-cleanup
Make httpClient.SetPrefix safer
2014-10-23 16:35:45 -07:00
992e7c76e0 client: copy v2KeysPrefix to httpClient
It's poor form to muck with a global variable. Make a copy when the
httpClient object is instantiated to make httpClient.SetPrefix safe.
2014-10-23 16:31:45 -07:00
a85a47c8f9 client: s/v2URL/v2KeysURL/ 2014-10-23 16:31:42 -07:00
ebe32689d4 client: s/v2Prefix/DefaultV2KeysPrefix/ 2014-10-23 16:30:56 -07:00
d1d12abfd7 Merge pull request #1372 from jonboulle/proxy
main: fix proxy initialization and setupCluster
2014-10-23 16:12:19 -07:00
d7301a5cf4 main: fix proxy initialization and setupCluster 2014-10-23 16:09:29 -07:00
d8258c38be Merge pull request #1374 from xiangli-cmu/cluster_on_peerurl
etcdserver: add member endpoint to peerurl
2014-10-23 16:08:45 -07:00
0eddf3db1f Merge pull request #1375 from jonboulle/sort
etcdserver: sort Members() in Cluster
2014-10-23 16:01:29 -07:00
af42f4a56b etcdserver: sort Members() in Cluster 2014-10-23 15:57:27 -07:00
02551c277d etcdserver: add member endpoint to peerurl 2014-10-23 15:55:00 -07:00
17bd5c3d21 Merge pull request #1373 from jonboulle/header
main: add header
2014-10-23 15:37:35 -07:00
0d36385bb4 main: add header 2014-10-23 14:46:05 -07:00
4089475c90 Merge pull request #1361 from unihorn/182
etcdserver: refactor cluster and clusterStore
2014-10-23 14:40:37 -07:00
4d80f01201 etcdserver: Cluster.IsIDremoved -> Cluster.IsIDRemoved 2014-10-23 14:29:58 -07:00
c25c50582e doc: add admin api doc 2014-10-23 14:26:33 -07:00
d47de988e4 etcdserver: panic when >1 members have the given name in MemberByName 2014-10-23 14:24:07 -07:00
5fbe6c7134 main: add genClusterString func and its test 2014-10-23 14:19:40 -07:00
8eee8c260e etcdserver: rebase on master and code clean 2014-10-23 13:58:55 -07:00
e21de51768 etcdserver: remove NewClusterFromMemberInfos 2014-10-23 13:27:55 -07:00
f8b8bdeb17 etcdserver: use path.Join for member key in cluster 2014-10-23 13:27:54 -07:00
3d243baacd etcdserver: generate id when new cluster 2014-10-23 13:27:54 -07:00
d2c4e981ed etcdserver: Member.Pick -> Member.PickPeerURL 2014-10-23 13:27:54 -07:00
67412e07f8 etcdserver: MemberFromName -> MemberByName 2014-10-23 13:27:54 -07:00
89572b5fd7 etcdserver: refactor cluster and clusterStore
Integrate clusterStore into cluster, and let cluster become the source of
cluster info.
2014-10-23 13:27:54 -07:00
09e9618b02 raft: change raftLog.maybeAppend to return the last new index
As per @unihorn's comment on #1366, we change raftLog.maybeAppend to
return the last new index of entries in maybeAppend.
2014-10-23 15:42:47 -04:00
233617bea2 raft: Make MsgAppRes ack only the last index in MsgApp
As explained in #1366, the leader will fail to transmit the missed
logs if the leader receives a hearbeat response from a follower
that is not yet matched in the leader. In other words, there are
append responses that do not explicitly reject an append but
implied a gap.

This commit is based on @xiangli-cmu's idea. We should only acknowledge
upto the index of logs in the append message. This way responses to
heartbeats would never interfer with the log synchronization because
their log index is always 0.

Fixes #1366
2014-10-23 14:56:17 -04:00
16c9970a03 Merge pull request #1365 from xiangli-cmu/admin_get
etcdserver: support GET on admin endpoint
2014-10-23 11:30:51 -07:00
86facb3f91 etcdhttp: sort member 2014-10-23 11:21:20 -07:00
8d6bb4a471 etcdserver: support GET on admin endpoint 2014-10-23 10:53:55 -07:00
051ad7585f Merge pull request #1363 from coreos/return_json
etcdserver: admin PUT returns the json representation of the newly creat...
2014-10-22 20:11:08 -07:00
2cb8efb9b5 Merge pull request #1362 from philips/consistent-hex-use
etcdserver: use hex for cluster and machine id
2014-10-22 18:43:21 -07:00
1539d5c49c etcdctl: update to meet go vet 2014-10-22 17:52:40 -07:00
69842b344d etcdctl: reflect build script location in README.md 2014-10-22 17:52:40 -07:00
52e08720b7 etcdctl: remove build indicator from README.md 2014-10-22 17:52:40 -07:00
29ef918808 etcdctl: import from external repo 2014-10-22 17:52:40 -07:00
9f2a42bf7d godep: add deps for etcdctl 2014-10-22 17:52:40 -07:00
9af5b74a8d gitignore: be more specific when ignoring /etcd 2014-10-22 17:52:40 -07:00
46be5d7d5f version: move version string into new package 2014-10-22 17:52:40 -07:00
63fa2a626a etcdserver: admin PUT returns the json representation of the newly created member 2014-10-22 17:19:28 -07:00
712a05be83 Merge pull request #1357 from coreos/accept_json
etcdserver: admin endpoint accepts json body
2014-10-22 16:30:22 -07:00
ab90369f9e etcdserver: use hex for cluster and machine id
Continue using hex everywhere. Including here.

TODO: cleanup the printing of the structs which currently have decimal
to/from:

`{Type:MsgAppResp To:9973738105406047488 From:17050684879817348455 T...`
2014-10-22 16:24:50 -07:00
7be0f4b618 etcdserver: admin endpoint accepts json body 2014-10-22 16:19:48 -07:00
ec7af4f519 Merge pull request #1359 from philips/fix-mismatch-error
etcdserver: fixup mismatch error line
2014-10-22 15:55:41 -07:00
0d0bc3a57e etcdserver: fixup mismatch error line
Both wcid and gcid are strings, don't try to print it out in hex.
2014-10-22 15:48:22 -07:00
2c21ae0f16 Merge pull request #1358 from philips/etcdserver-cleanup-cluster-id-msg
etcdserver: cleanup the cluster ID error message
2014-10-22 15:42:30 -07:00
1f84991b3a Merge pull request #1355 from barakmich/cluster_after_wal
etcdserver: Check the initial cluster settings after checking if the WAL...
2014-10-22 18:31:28 -04:00
400dd2d7bc etcdserver: cleanup the cluster ID error message
1) Don't panic since we know exactly where this is coming from and don't
need the user to see a full back trace

2) Add docs explaining this situation a bit further

3) Cleanup the error to look like other similiar errors
2014-10-22 15:26:35 -07:00
e42d65da12 etcdserver: Check the initial cluster settings after checking if the WAL exists 2014-10-22 18:16:43 -04:00
d27d308935 Merge pull request #1356 from coreos/fix_dis
main: use our own flagset in setupCluster
2014-10-22 14:55:40 -07:00
5444a366da main: use our own flagset in setupCluster 2014-10-22 14:51:51 -07:00
5780dfe690 Merge pull request #1347 from coreos/gen_nodeID
etcdserver: etcdserver generates the ID when adding new member.
2014-10-22 14:30:49 -07:00
6d9eb57555 etcdhttp: test bad url for POST on admin endopint 2014-10-22 14:27:08 -07:00
d6a5dc9e61 Merge pull request #1352 from coreos/fix_main
main: fix default case
2014-10-22 14:05:11 -07:00
ca4f12182a main: fix default case 2014-10-22 13:49:52 -07:00
d00152765a etcdserver: etcdserver generates the ID when adding new member.
When adding new member, the etcdserver generates the ID based on the current time
and the given peerurls. We include time to add the uniqueness, since the node with
same peerurls should be able to (add, then remove) several times.
2014-10-22 13:15:56 -07:00
13656eb4e7 Merge pull request #1340 from barakmich/better_ids2
etcdserver: Calculate IDs based on PeerURLs and --initial-cluster-name
2014-10-22 14:49:49 -04:00
829cec8ccf Merge stylistic comments 2014-10-22 14:26:05 -04:00
6b32395637 Merge pull request #1343 from unihorn/175
etcdserver: record removed member to check incoming message
2014-10-22 11:16:55 -07:00
5014558b00 etcdserver: clean code 2014-10-22 11:09:36 -07:00
3162ead7b1 etcdhttp: do message statistics only on valid ones 2014-10-22 11:09:36 -07:00
9ad4a8e33a etcdserver: add isKeyNotFound helper func 2014-10-22 11:09:36 -07:00
89b032cd69 etcdserver: Member.storeKey -> memberStoreKey 2014-10-22 11:09:36 -07:00
7498234e40 etcdserver: record removed member to check incoming message 2014-10-22 11:09:35 -07:00
b40d30a8d2 Merge pull request #1346 from unihorn/178
integration: fix master
2014-10-22 11:09:06 -07:00
c5d1fcd70a fix wrong name 2014-10-22 13:58:43 -04:00
cb5a638c44 style comments 2014-10-22 13:52:42 -04:00
52dedab7b4 Move setupCluster inside startEtcd 2014-10-22 13:52:42 -04:00
502a3c2460 Refactor Cluster to hold and add members. 2014-10-22 13:52:42 -04:00
1347e3952f docs and cluster ID change based on name 2014-10-22 13:52:42 -04:00
ad0b7b7dbb Add cluster name to etcd flags 2014-10-22 13:52:42 -04:00
1ca7c031ff first round of comments
Conflicts:
	etcdserver/config.go
	etcdserver/config_test.go
	etcdserver/server.go
	main.go
2014-10-22 13:49:54 -04:00
456d1ebcae etcdserver: Calculate IDs for nodes solely on PeerURLs
Removes the notion of name being anything more than advisory or
command-line grouping, and adds checks for bootstrapping the command
line. IDs are consistent if the URLs are consistent.
2014-10-22 13:49:54 -04:00
4f52d371c1 integration: skip TestGoroutinesRunning 2014-10-22 10:10:43 -07:00
e475388bc0 Merge pull request #1294 from kelseyhightower/issue_619_fix_listing_docs
doc: fix listing a directory
2014-10-22 09:53:48 -07:00
48992cced3 Merge pull request #1344 from unihorn/176
integration: add remaining goroutine check
2014-10-21 18:05:28 -07:00
f356648252 integration: add remaining goroutine check 2014-10-21 16:59:14 -07:00
f26bb6ad44 Merge pull request #1335 from unihorn/174
etcdserver/etcdhttp: store location adjustment
2014-10-21 16:24:30 -07:00
06b196e345 etcdhttp: writeEvent -> writeKeyEvent 2014-10-21 16:10:49 -07:00
ca73f25615 etcdhttp: parseRequest -> parseKeyRequest 2014-10-21 16:10:49 -07:00
e2b6a4fc4c etcdserver: const XXXDir -> StoreXXXPrefix
and code clean
2014-10-21 16:10:49 -07:00
2ff3cac653 etcdserver/etcdhttp: store location adjustment
Detailed adjustment:
/_etcd/machines/* -> /0/members/*
/* -> /1/*

And it keeps key path returned to user the same as before.
2014-10-21 16:10:19 -07:00
0398a31b16 Merge pull request #1339 from coreos/checkcid
etcdserver: checking clusterID
2014-10-21 16:00:49 -07:00
e69c37adf0 etcdserver: panic on clusterid mismatch 2014-10-21 15:22:16 -07:00
00dc61d169 Merge pull request #1341 from coreos/fix_bench
raft: fix node bench
2014-10-21 13:01:37 -07:00
48c4145f1b raft: fix node bench 2014-10-21 12:46:39 -07:00
a9984fda4f Merge pull request #1102 from coreos/node_bench
raft: add a one node bench
2014-10-21 11:44:46 -07:00
50d4abc676 raft: add a one node bench 2014-10-21 11:43:55 -07:00
c3f83f9275 Merge pull request #1337 from jonboulle/govet
tests: add `go vet` coverage
2014-10-21 11:40:26 -07:00
341c7190d3 test: add govet to tests 2014-10-21 11:32:38 -07:00
894e678ad6 etcdserver: checking clusterID 2014-10-21 11:05:24 -07:00
ae4403c945 test: add discovery to tests 2014-10-21 00:17:14 -07:00
a44849deec Merge pull request #1286 from coreos/clusterid
*: generate clusterid
2014-10-20 19:07:03 -07:00
99dd42026b Merge pull request #1336 from jonboulle/govet
*: fix various formatting issues
2014-10-20 18:23:26 -07:00
b3d5333cb3 *: fix various formatting issues 2014-10-20 17:55:18 -07:00
0fd28169c8 etcdserver: use id,cid 2014-10-20 16:35:41 -07:00
dc68dc9ebd etcdserver: add a todo for clusterid generation 2014-10-20 16:26:31 -07:00
d67a2855c1 Merge pull request #1334 from jonboulle/exit_help
main: exit 0 on -h/--help
2014-10-20 16:19:39 -07:00
92230cee63 Merge pull request #1333 from unihorn/172
etcdserver/raft: remove msgDenied, removedNodes, shouldStop
2014-10-20 16:04:09 -07:00
63b328ed11 main: exit 0 on -h/--help 2014-10-20 15:32:58 -07:00
e200d2a8e2 etcdserver/raft: remove msgDenied, removedNodes, shouldStop
The future plan is to do all these in etcdserver level.
2014-10-20 15:13:18 -07:00
ea6bcacfe4 *: generate clusterid 2014-10-20 15:00:54 -07:00
68da8084d0 Merge pull request #1318 from unihorn/164
main: add basic integration test
2014-10-20 14:45:22 -07:00
ef44ba10cf integration: add doc 2014-10-20 14:43:21 -07:00
80212aaf4d integration: retry on setKey to avoid timeout due to bootstrap 2014-10-20 14:43:21 -07:00
500a72962e integration: clean code
remove extra space, rename variables, remove unused function.
2014-10-20 14:43:21 -07:00
7af679333a integration: log microsecond time for integration tests 2014-10-20 14:43:21 -07:00
1b7947357f *: pkg functional -> integration 2014-10-20 14:43:21 -07:00
40279d324a functional: add TODO 2014-10-20 14:43:21 -07:00
f7a0d5387b etcdserver: stop server gracefully 2014-10-20 14:43:21 -07:00
058537f34a main: add basic functional test 2014-10-20 14:43:21 -07:00
8fa3834d69 Merge pull request #1327 from unihorn/168
docs: add naming.md
2014-10-20 14:23:36 -07:00
3184e1c66f docs: add glossary.md 2014-10-20 14:16:53 -07:00
dcaa7f0a37 Merge pull request #1328 from unihorn/169
skip initial-cluster check when reboot
2014-10-20 13:06:24 -07:00
17382ec905 etcdserver: skip initial-cluster check when reboot
If etcd is provided with data-dir that has data, it will not use
initial-cluster, and initial-cluster could be set to be empty.
2014-10-20 12:41:07 -07:00
da23327265 Merge pull request #1302 from jonboulle/license
add copyright info at the head of each file
2014-10-20 10:49:52 -07:00
7a4d42166b *: add license header to all source files 2014-10-17 15:41:22 -07:00
aa176610f3 main: remove duplicated self name check 2014-10-17 15:37:30 -07:00
f12583c163 Merge pull request #1021 from jonboulle/clock
Implement fake clock for testing
2014-10-17 13:56:30 -07:00
1456ae4453 store: restore minExpireTime check and advance FakeClock appropriately 2014-10-17 10:05:29 -07:00
e0801360d3 godep: update clockwork dependency 2014-10-17 10:05:29 -07:00
ec18e46641 etcdserver/etcdhttp: switch to using fake clock 2014-10-17 10:05:29 -07:00
3134658ded store: switch to fake clock 2014-10-17 10:05:29 -07:00
47c2421f7b godeps: add clockwork 2014-10-17 10:05:29 -07:00
de3bf58876 discovery: switch to fake clock 2014-10-17 10:05:29 -07:00
c5ba66e6aa Merge pull request #1319 from jonboulle/stats_race
etcdserver: fix data race in retrieving self stats
2014-10-17 09:04:17 -07:00
aed525edee Merge pull request #1325 from jonboulle/store_cleaner_still
store: remove unused code
2014-10-17 09:02:36 -07:00
766aa85320 Merge pull request #1326 from jurmous/patch-1
Update clients-matrix.md
2014-10-17 16:05:37 +02:00
6aa46d20d4 Update clients-matrix.md
Fix new boon etcd client entry so it complies to the rest of the entries with Y instead of F for HTTPS and Reconnect. Also fix the sorting.
2014-10-17 15:30:35 +02:00
da64e7509c etcdserver/stats: lock on leaderstats too 2014-10-17 00:11:25 -07:00
5c4edf65f9 store: remove another unused function 2014-10-17 00:07:45 -07:00
1fa763b47b store: remove unused function 2014-10-17 00:07:23 -07:00
70bbf8b470 store: remove more unused code 2014-10-17 00:05:56 -07:00
82023c591d etcdserver/stats: log any marshaling error 2014-10-16 23:05:48 -07:00
233e940410 etcdserver: copy stats instead of marshaling with lock 2014-10-16 23:05:48 -07:00
c28907ba95 etcdserver: fix race and improve stats interfaces 2014-10-16 23:05:48 -07:00
c30b82b596 etcdserver: fix data race in retrieving self stats 2014-10-16 23:05:48 -07:00
7311a2a67d Merge pull request #1321 from jonboulle/peers
main: correct peer-addr reference
2014-10-16 20:17:22 -07:00
bc7d372d5c main: correct peer-addr reference 2014-10-16 20:06:26 -07:00
67368ac7fa Merge pull request #1320 from jonboulle/proxy_doc
doc: add note about discovery proxy
2014-10-16 17:23:29 -07:00
2af0b2031f doc: add note about discovery proxy 2014-10-16 17:14:38 -07:00
b7c42b0d76 Merge pull request #1314 from jonboulle/raft_tests
raft: remove unused compactThreshold
2014-10-16 17:11:55 -07:00
fc42bdb904 raft: remove unused compactThreshold 2014-10-16 17:11:10 -07:00
f7988e6069 Merge pull request #909 from jonboulle/proxy
Support corporate proxy via env var
2014-10-16 16:50:31 -07:00
3a29db1e9d Merge pull request #1311 from jonboulle/remove_ttl
store: remove unused code
2014-10-16 16:35:01 -07:00
7ef375efbd Merge pull request #1317 from unihorn/169
etcdserver: fix data race in leaderStats.Followers
2014-10-16 16:24:26 -07:00
782d91f2d9 etcdserver: fix data race in leaderStats.Followers 2014-10-16 16:18:53 -07:00
074ddb5876 Merge pull request #1316 from unihorn/168
stats: fix data race when recording send result
2014-10-16 16:11:22 -07:00
eb72bdc3d2 stats: fix data race when recording send result 2014-10-16 15:39:31 -07:00
da2ee9a90c Merge pull request #1312 from unihorn/165
etcdhttp: set stats field in peer handler
2014-10-16 14:47:57 -07:00
8609acf573 etcdhttp: set stats field in peer handler 2014-10-16 14:23:09 -07:00
2cd6594485 store: remove unused code 2014-10-16 12:28:05 -07:00
7f8f371b0e discovery: add ability to proxy discovery requests 2014-10-16 11:15:04 -07:00
6a30d3ba04 Merge pull request #1285 from jonboulle/stats_leader_followers
etcdserver: add StoreStats, ServerStats and LeaderStats
2014-10-16 10:44:48 -07:00
9b9e72e2a3 etcdhttp: add tests for ServeStats/ServeLeader 2014-10-16 10:43:49 -07:00
97ae531eda etcdserver: split out storestats and serverstats 2014-10-16 10:43:49 -07:00
fedb67a71a etcdserver: fix TODO and change to base 16 2014-10-16 10:43:49 -07:00
8168fed825 etcdserver: add ServerStats and LeaderStats
This adds the remaining two stats endpoints: `/v2/stats/self`, for
various statistics on the EtcdServer, and `/v2/stats/leader`, for
statistics on a leader's followers.

By and large most of the stats code is copied across from 0.4.x, updated
where necessary to integrate with the new decoupling of raft from
transport.

This does not satisfactorily resolve the question of name vs ID. In the
old world, names were unique in the cluster and transmitted over the
wire, so they could be used safely in all statistics. In the new world,
a given EtcdServer only knows its own name, and it is instead IDs that
are communicated among the cluster members. Hence in most places here we
simply substitute a string-encoded ID in place of name, and only where
possible do we retain the actual given name of the EtcdServer.
2014-10-16 10:43:44 -07:00
0a8721a708 etcdserver: expose store statistics 2014-10-16 10:43:23 -07:00
79e9f2ab81 Merge pull request #1296 from unihorn/161
etcdserver: add checking when apply conf change
2014-10-16 09:58:51 -07:00
8cd6030a1d etcdserver: add checking when apply conf change 2014-10-16 09:49:26 -07:00
82476e04f0 Merge pull request #1303 from coreos/datadir
main: use node name as default dir
2014-10-16 21:31:18 +08:00
efba919a93 main: use node name as default dir
We use nodeID as the default dir previously. It works fine before we do dynamic nodeID
generation (introducing time). After the change the dynamic nodeID will change every
time we restart the etcd process. If the user does not provide the data dir, the default
dir will change every time. It is not the desired behavior.

In this commit, we change the default data dir to node name. If the user changes the node
name and does provide the data dir, etcd still cannot recover from previous state. But it
is much better than using nodeID. And it is actually a doucmentation issue.

Conflicts:
	main.go
2014-10-16 21:22:12 +08:00
c18acd7d6f Merge pull request #1306 from jonboulle/tls
pkg: set minimum TLS version to 1.0 (disable SSL3)
2014-10-15 14:02:05 -07:00
e334148a91 pkg: set minimum TLS version to 1.0 (disable SSL3)
SSLv3 is no longer considered secure, and is not supported by golang
clients. Set the minimum version of all TLSConfigs that etcd uses to
ensure that only TLS >=1.0 can be used.
2014-10-15 14:00:16 -07:00
eb2dd1892f raft: add RemovedNodes to SoftState 2014-10-15 10:53:07 -07:00
a8a1d4fd93 Merge pull request #1299 from unihorn/162
etcdhttp: add PUT and DELETE on /v2/admin/members/
2014-10-15 10:52:11 -07:00
f62d4908b0 Merge pull request #1304 from coreos/logging
etcdserver: better logging
2014-10-15 13:36:32 +08:00
828accf07b etcdserver: better logging 2014-10-15 13:07:34 +08:00
6d0658c8ca etcdhttp: check error returned by ParseForm 2014-10-14 14:50:11 -07:00
48c195fac7 Merge pull request #1298 from jonboulle/members
etcdhttp: remove members handling for now
2014-10-14 13:57:52 -07:00
7656069675 etcdhttp: remove members handling for now 2014-10-14 12:07:28 -07:00
99e35554c0 etcdhttp: add doc for member management http endpoint 2014-10-14 11:09:14 -07:00
b0fcd680f8 Merge pull request #1287 from coreos/refactor
*: proto refactoring
2014-10-15 01:51:44 +08:00
f98fbbfc14 *: proto refactoring 2014-10-14 21:07:23 +08:00
2b03d35ab9 Merge pull request #1300 from jonboulle/godep
*: move from third_party to Godep
2014-10-14 01:03:58 -07:00
4183b69e12 *: move from third_party to Godep 2014-10-14 00:37:52 -07:00
31264e7eb5 etcdhttp: add PUT and DELETE on /v2/admin/members/ 2014-10-13 22:36:06 -07:00
09f9884c6a Merge pull request #1288 from coreos/cleanup
etcdserver: clean NewServer
2014-10-14 11:32:13 +08:00
fbb874172c etcdserver: fix typo 2014-10-14 11:30:49 +08:00
6fc0b1977b etcdserver: Id -> ID 2014-10-14 11:30:49 +08:00
b53b74733a etcdserver: add s.apply 2014-10-14 11:30:49 +08:00
30c7a7f2dd etcdserver: add shouldDiscover 2014-10-14 11:29:00 +08:00
a85ec90d68 etcdserver: clean NewServer 2014-10-14 11:29:00 +08:00
57ae19b500 Merge pull request #1290 from coreos/member_endpoint
etcdserver: change machines endpoint to members
2014-10-14 11:04:08 +08:00
1177b07535 etcdserver: change machines endpoint to members 2014-10-14 11:02:17 +08:00
d7dfe07e5d Merge pull request #1293 from unihorn/160
raft: protobuf messageType
2014-10-14 09:16:38 +08:00
9722aac10d Merge pull request #1295 from jonboulle/typos
main: fix typos and initial-cluster references
2014-10-13 15:16:21 -07:00
a6dfde85e4 main: fix typos and initial-cluster references 2014-10-13 14:52:49 -07:00
85c2d852f3 Merge pull request #1259 from unihorn/156
etcdserver/raft: apply bootstrap addnode entries
2014-10-13 12:18:43 -07:00
f693c6ddf2 etcdserver: apply bootstrap conf change 2014-10-13 11:22:23 -07:00
0319b033ea etcdserver/raft: set context for bootstrap addnode entries 2014-10-13 11:22:23 -07:00
32c38820c1 raft: protobuf messageType 2014-10-13 11:13:43 -07:00
d06d55193b doc: fix listing a directory 2014-10-13 10:59:24 -07:00
b8b4852ec9 Merge pull request #972 from tazjin/etcd-security-docs
Documentation: Clarify etcd security documentation
2014-10-13 08:55:12 -07:00
6ffaa4db5d Merge pull request #1289 from coreos/uint
*: change all ID to uint64
2014-10-12 13:58:43 +08:00
3516cc3ee5 *: change all ID to uint64 2014-10-12 08:38:48 +08:00
f16a272898 Merge pull request #1234 from unihorn/152
etcdserver: save PeerURLs and Others into two different keys
2014-10-10 12:21:32 -07:00
f8b338d423 Merge pull request #1236 from unihorn/153
wal: record node id at the head of WAL file
2014-10-10 12:09:17 -07:00
447caf1afc etcdserver/wal: record info at the head of WAL file 2014-10-10 11:57:09 -07:00
181cbbdfe0 Merge pull request #1280 from RichardHightower/patch-2
Update clients-matrix.md
2014-10-10 10:05:26 -07:00
d241275518 Merge pull request #1275 from RichardHightower/patch-1
Update libraries-and-tools.md
2014-10-10 09:58:32 -07:00
2ec999ab3b Update clients-matrix.md 2014-10-10 02:03:35 -07:00
77271b0663 etcdserver: split Member into RaftAttributes and Attributes
The split helps to save them in different key paths, because they have
distinct life cycle on update.
2014-10-09 20:28:00 -07:00
74ab003e1f Merge pull request #1256 from barakmich/retry
Add logging and backoff and simple retry logic
2014-10-09 13:24:14 -04:00
5e7267a751 last comment 2014-10-09 13:16:45 -04:00
3e5073e9be Merge pull request #1261 from coreos/uint
raft: int64 -> uint64
2014-10-09 14:47:03 +08:00
1eb1020717 raft: fix raft test 2014-10-09 14:42:29 +08:00
8bbbaa88b2 *: raft related int64 -> uint64 2014-10-09 14:29:21 +08:00
af5b8c6c44 raft: int64 -> uint64 2014-10-09 14:26:43 +08:00
8c5aa16d03 Update libraries-and-tools.md 2014-10-08 21:50:22 -07:00
5fde52a403 add too many retries test case 2014-10-08 21:58:19 -04:00
9b35ca3a52 simplify and multiple retry 2014-10-08 21:53:15 -04:00
38af14b0f4 Merge pull request #1260 from coreos/snap_rm
raft: save removed nodes in snapshot
2014-10-09 08:00:33 +08:00
dbac2e8f15 test retry logic 2014-10-08 19:41:59 -04:00
ea99d3c002 Merge pull request #1269 from jonboulle/disco_warn
etcdserver: add discovery warning message
2014-10-08 16:24:51 -07:00
682008724d etcdserver: add discovery warning message 2014-10-08 16:09:12 -07:00
abe97e49d5 raft: more comment 2014-10-09 07:02:05 +08:00
73f2aaf98f raft: removedSlice -> removedNodes 2014-10-09 06:55:25 +08:00
c67fd14fe8 Merge pull request #1257 from bdarnell/cleanups
Raft: assorted cleanups (golint and go vet)
2014-10-09 05:55:21 +08:00
b4a7680bc4 Merge pull request #1268 from jonboulle/store_typo
store: fix typo "recurisive"
2014-10-08 14:22:07 -07:00
a07c51a9c9 store: fix typo "recurisive" 2014-10-08 14:13:38 -07:00
d2e858587f Raft: a few more improvements to test messages. 2014-10-08 15:07:11 -04:00
7b61565c0a raft: save removed nodes in snapshot 2014-10-08 15:33:55 +08:00
f3870598b9 fix retry to not retry on createSelf() 2014-10-07 21:20:45 -04:00
5f3fe7c61f Merge pull request #1254 from coreos/rand_etimeout
Rand etimeout
2014-10-08 08:10:26 +08:00
1cd3345e00 raft: address issues with election timeout 2014-10-08 07:41:17 +08:00
75f6643982 Merge pull request #1212 from unihorn/144
etcdserver: apply config change on cluster store
2014-10-07 16:32:59 -07:00
8e8719f6ac etcdserver: Create, Delete -> Add, Remove 2014-10-07 16:21:58 -07:00
1083ce8f73 raft: remove misleading labels in array definition
Since these are arrays instead of maps, the "keys" here are actually
(useless) goto labels. What really matters is that the ordering is
the same between the constant declarations and the array.
2014-10-07 18:44:06 -04:00
36558b1924 Raft: fix printf strings found by go vet. 2014-10-07 18:44:06 -04:00
3ad0df3722 Raft: fix problems reported by golint. 2014-10-07 18:44:06 -04:00
fe0e168b3b Add *.test to gitignore.
These files are left by some go commands.
2014-10-07 18:22:09 -04:00
ca1bbee737 add logging and backoff and simple retry logic 2014-10-07 16:58:58 -04:00
5b8c4f4e0d Merge pull request #1251 from philips/hack-insta-discovery
hack: introduce a insta-discovery script
2014-10-07 13:47:03 -07:00
cdea98d434 etcdserver: skip bootstrap addNode entry
This is a hack to make etcd work normally.
2014-10-07 11:11:31 -07:00
6a62621695 etcdserver: update panic info 2014-10-07 11:04:50 -07:00
3859297225 etcdserver: check id match 2014-10-07 11:04:50 -07:00
d051af4d3d etcdserver: apply config change on cluster store 2014-10-07 11:04:50 -07:00
ef0ed31210 hack: introduce a insta-discovery script
This sets up a localhost cluster via a new discovery token. Very useful
for testing.
2014-10-07 10:52:40 -07:00
f65d117462 raft: add a test for randElectionTimeout 2014-10-07 20:34:15 +08:00
d7d6f84f64 raft: rand election timeout 2014-10-07 20:12:49 +08:00
2e0fec7a84 Merge pull request #1253 from jonboulle/streaming_events
store: use a larger buffer for eventChan
2014-10-07 02:14:20 -07:00
26160b2154 store: use a larger buffer for eventChan
The event channel for watches can drop events too easily in the case of
streaming watches. This increases the buffer to a more useful level.
2014-10-07 01:57:05 -07:00
3f3b9866c6 Merge pull request #1241 from coreos/compact
raft: compact takes index and nodes parameters
2014-10-07 16:07:25 +08:00
45e4a8643a raft: add tests for raft.compact 2014-10-07 16:03:11 +08:00
7fe4385ef9 raft: add comment for Compact interface of Node 2014-10-07 16:03:11 +08:00
5587e0d73f raft: compact takes index and nodes parameters
Before this commit, compact always compact log at current appliedindex of raft.
This prevents us from doing non-blocking snapshot since we have to make snapshot
and compact atomically. To prepare for non-blocking snapshot, this commit make
compact supports index and nodes parameters. After completing snapshot, the applier
should call compact with the snapshot index and the nodes at snapshot index to do
a compaction at snapsohot index.
2014-10-07 16:03:11 +08:00
de024ec844 Merge pull request #1250 from philips/fix-single-node
main: use a new cluster by default
2014-10-06 19:10:58 -07:00
6cbc282be1 main: use a new cluster by default
This is a safe default for now. Use it to make `./etcd` work again.
2014-10-06 17:34:14 -07:00
39e0a0cd0a Merge pull request #1249 from barakmich/sanity_check
Split config into a separate file and add sanity check and test
2014-10-06 20:19:23 -04:00
d6aea2a795 add golint on the new box and fix appropriate lint 2014-10-06 20:16:25 -04:00
8a311e5b76 remove new cluster check 2014-10-06 20:07:51 -04:00
1a0195e07e tableize the test 2014-10-06 20:05:53 -04:00
3ca3c9ad4c Merge pull request #1245 from unihorn/155
main/raft: write addNode ConfChange entries in log when start raft
2014-10-06 17:00:28 -07:00
b9c8ac73be Merge pull request #1248 from jonboulle/disco
main: fix temporary discovery cluster
2014-10-06 16:54:06 -07:00
120b088723 Split config into a separate file and add sanity check and test 2014-10-06 19:42:13 -04:00
5098cb0d32 main: fix temporary discovery cluster 2014-10-06 16:10:29 -07:00
45ebfb4217 raft: refine initial entries logic in StartNode 2014-10-06 16:06:01 -07:00
d98fe2ce1a Merge pull request #1247 from jonboulle/doc
documentation: clustering guide fixes
2014-10-06 15:16:25 -07:00
c15c3eab4c etcdserver: move int64Slice into pkg/types/ 2014-10-06 15:12:02 -07:00
a10c62ae25 documentation: clustering guide fixes 2014-10-06 15:07:44 -07:00
3500b56e54 Merge pull request #1237 from philips/0.5-docs
use initial-cluster and initial-cluster-state flags
2014-10-06 15:04:04 -07:00
e2d8037ded main: use initial-cluster and initial-cluster-state flags
In preperation for adding the ability to join a machine to an existing
cluster force the user to specify whether they expect this to me a new
cluster or an active one.

The error for not specifying the initial-cluster-state is:
```
etcd: initial cluster state unset and no wal found
```
2014-10-06 14:59:25 -07:00
314d425718 main/raft: write addNode ConfChange entries in log when start raft 2014-10-06 14:33:12 -07:00
7081dabd12 Merge pull request #1244 from jonboulle/peers
main: fail on peers/peers-file flags
2014-10-06 14:25:39 -07:00
ec7bcbb50d main: fail on peers/peers-file flags 2014-10-06 14:25:11 -07:00
6bc160b4e3 Documentation: introduce the initial 0.5 clustering guide
Introduce the concepts of static initial cluster configuration and
document the flag migrations.
2014-10-06 12:25:12 -07:00
9e3d045b2b *:discovery hook up 2014-10-06 10:12:42 -07:00
824b7231b8 Merge pull request #1240 from coreos/fix_proposal
raft: fix send
2014-10-06 05:53:54 +08:00
dc9cb4b4ba raft: fix send
send should not attach current term to msgProp. Send should simply do proxy for msgProp without
changing its term. msgProp has a special term 0, which indicates that it is a local message.
2014-10-06 04:48:35 +08:00
7ce3bb180c Merge pull request #1238 from jonboulle/etcdserver_cluster
etcdserver: restore test coverage of cluster
2014-10-03 17:06:36 -07:00
d2df23183d etcdserver: restore test coverage of cluster 2014-10-03 17:06:23 -07:00
2606508d1c Merge pull request #1215 from jonboulle/1215
Flag `-timeout` not descriptive
2014-10-03 14:06:18 -07:00
f432b9d29b etcdhttp: remove configurable timeout
It's slightly unclear why we expose this timeout as being configurable,
and the `-timeout` flag does not exist in 0.4.x, so for now, remove the
flag until we have evidence that it is needed.
2014-10-03 13:47:34 -07:00
1ca5991c8c Merge pull request #1096 from jonboulle/1096_embedded
simplify initialization of EtcdServer to support embedded etcd
2014-10-03 13:39:25 -07:00
1308c3e809 etcdserver: unexport EtcdServer fields where possible 2014-10-03 13:34:56 -07:00
e5f5fcff48 etcdserver: collapse dir configuration to DataDir 2014-10-03 13:34:49 -07:00
af6b29f291 main: move server configuration to etcdserver package 2014-10-03 13:34:49 -07:00
1c4163faf8 Merge pull request #1187 from jonboulle/1187_watches_header
Watches do not return X-Etcd-Index header
2014-10-03 10:13:25 -07:00
01ecc60a88 Merge pull request #1203 from coreos/fix_raft
raft: commitIndex=min(leaderCommit, index of last new entry)
2014-10-03 22:24:07 +08:00
172bd7d096 raft: add test for maybeappend change 2014-10-03 22:21:35 +08:00
5b291b521b Merge pull request #1207 from coreos/check_stale_resp
raft: do not decrease nextIndex and send entries for stale reply
2014-10-03 13:45:58 +08:00
70bf464cd6 raft: add comment to decrTo 2014-10-03 13:42:34 +08:00
16ba77767e raft: do not decrease nextIndex and send entries for stale reply 2014-10-03 13:41:27 +08:00
1c11f6a144 *: expose etcd-index in watch requests
This adds a StartIndex field to the Watcher interface, which represents
the Etcd-Index at which the Watcher is created.

Also refactors the HTTP tests to use a table for most handleWatch tests
2014-10-02 18:10:11 -07:00
8490904f20 Merge pull request #1224 from unihorn/149
raft: msg.Denied -> msg.Reject
2014-10-02 12:24:09 -07:00
fff918c672 raft: msg.Denied -> msg.Reject
Change the field name because it has msgDenied already.
2014-10-02 12:22:12 -07:00
4a5bf2e1b7 Merge pull request #1151 from unihorn/138
raft: add removed
2014-10-01 15:01:30 -07:00
b64246720b etcdserver: fix test due to rebase 2014-10-01 14:57:39 -07:00
182c8316e1 raft: refine comment for doc and removed list tests 2014-10-01 14:57:39 -07:00
e4a6c9651a raft: add removed
The usage of removed:
1. tell removed node about its removal explicitly using msgDenied
2. prevent removed node disrupt cluster progress by launching leader election

It is set when apply node removal, or receive msgDenied.
2014-10-01 14:57:38 -07:00
b1fc0feb72 Merge pull request #1221 from philips/fixing-stuff
pkg/types: introduce a URLs type
2014-10-01 14:55:41 -07:00
83137f9eba pkg/types: introduce a URLs type
Cleanup the usage of URLs into its own type so we don't have to use a
FlagValue everywhere we have a list of URLs.
2014-10-01 14:41:01 -07:00
619c7f9fdb Merge pull request #1220 from bcwaldon/bkcompat
Backwards-compatibility with v0.4.6 addr-related flags
2014-10-01 12:53:50 -07:00
f84b5b1071 Merge pull request #1201 from unihorn/143
etcdserver: publish self info when start
2014-10-01 11:56:20 -07:00
b3c7711da8 Merge pull request #1219 from unihorn/148
flags/urls: reject url without port
2014-10-01 11:51:32 -07:00
073eb7677d etcdserver: move grep member logic into publish func 2014-10-01 11:50:47 -07:00
dd88a08f8e etcd: support v0.4.6 addr flags
The -addr, -bind-addr, -peer-addr, and peer-bind-addr flags are
superseded by -advertise-client-urls, -listen-client-urls,
-advertise-peer-urls, and -listen-peer-urls, respectively.
If any of the former flags are provided, however, they will still
work. If the new counterparts to the old flags are provided, etcd
will log an error and fail.
2014-10-01 11:49:01 -07:00
11582b0f5f pkg: add URLsFromFlags 2014-10-01 11:49:01 -07:00
add3906f6c pkg/flags: add NewURLs helper 2014-10-01 11:49:01 -07:00
c9cac5fee5 flags: replace Addrs with IPAddressPort 2014-10-01 11:49:00 -07:00
cbc84bc70e etcdserver: minimize input info 2014-10-01 11:47:17 -07:00
a40a270e19 etcdserver: publish self info when start 2014-10-01 11:47:17 -07:00
1356037fc6 flags/urls: reject url without port
For now, if etcd receives a url without port, it will listen on a random
port, which is useless.
2014-10-01 11:44:17 -07:00
c0c0b08ff2 Merge pull request #1218 from unihorn/147
flags/urls: assign urls instead of append
2014-10-01 11:34:24 -07:00
fd758c71b8 Merge pull request #1217 from unihorn/146
main: not use loop variable in goroutine in loop body
2014-10-01 11:25:53 -07:00
8944364884 flags/urls: assign urls instead of append 2014-10-01 11:23:20 -07:00
7a698be6a3 main: not use loop variable in goroutine in loop body
Because loop variable are reused in following loops.
2014-10-01 11:07:32 -07:00
6760345453 Merge pull request #1216 from philips/improve-cluster-procfile
etcdserver: stop worrying about scheme
2014-09-30 17:13:41 -07:00
04bd48fef3 etcdserver: stop worrying about scheme
Stop worrying about the scheme. This puts a TODO on adding validation to
the schemes if TLS is specified. But we can worry about that later.
2014-09-30 17:05:20 -07:00
7639752c82 Merge pull request #1213 from philips/improve-cluster
etcdserver: stop using addScheme
2014-09-30 16:43:26 -07:00
c2f96631d3 etcdserver: stop using addScheme
This standardizes the flags to use a list of URLs everywhere. The next
step is to enforce the scheme based on TLS settings and support compat
flags.
2014-09-30 16:40:32 -07:00
aa5b6cdc9e etcdserver: have newMember take an optional time field
This will be used by members joining an existing cluster or joining
using discovery.
2014-09-30 14:57:04 -07:00
ce70e63cc6 Merge pull request #1200 from coreos/raft_heartbeat
raft: heartbeat is only response for maintaining leader dominance
2014-09-29 17:00:26 -07:00
d7b4e44a66 raft: heartbeat is only response for maintaining leader dominance 2014-09-29 16:57:43 -07:00
b3c1bd5616 raft: commitIndex=min(leaderCommit, index of last new entry) 2014-09-29 14:38:17 -07:00
b6a73c9358 Merge pull request #1202 from unihorn/144
etcdserver: fix left Id -> ID
2014-09-29 14:21:42 -07:00
34547229a6 etcdserver: fix left Id -> ID 2014-09-29 14:14:45 -07:00
0e8345aa73 Merge pull request #1143 from unihorn/136
*: Id -> ID for protobuf types
2014-09-29 13:58:02 -07:00
768090754c Merge pull request #1199 from AdoHe/master
update the Documentation/libraries-and-tools.md to add a new Java client
2014-09-29 13:21:40 -07:00
08e5f39d8a Merge pull request #1192 from unihorn/140
etcdserver: add publish func
2014-09-29 10:20:39 -07:00
89077167c3 etcdserver: add publish func 2014-09-29 10:13:06 -07:00
1eb09acd8b Merge pull request #1197 from coreos/raft_t
Add raft msg denied
2014-09-28 23:53:13 -07:00
1c27fad2cf update the Documentation/libraries-and-tools.md 2014-09-29 13:42:12 +08:00
e26ff32fd8 raft: fix error msg 2014-09-28 21:17:51 -07:00
51529cc3f2 raft: remove index field in msg AppResp 2014-09-28 21:13:53 -07:00
adefd83855 raft: remove index field in msg voteResp 2014-09-28 21:13:43 -07:00
86473d8a27 raft: add msg denied field 2014-09-28 21:13:33 -07:00
e38fbfe9de Merge pull request #1196 from philips/add-flagtypes-package
flagtypes: introduce flagtypes package
2014-09-28 19:48:12 -07:00
d8bf9728d2 Merge pull request #1194 from unihorn/141
etcdserver: return client urls for /v2/machines
2014-09-28 17:29:52 -07:00
78a9bba276 pkg/types/flags: introduce flags package
I want to use the Addrs type in another experimental proxy that I am
implementing. Pull it out into a separate package.
2014-09-28 14:56:30 -07:00
5784693a39 etcdserver: Cluster.Endpoints() -> Cluster.PeerURLs() 2014-09-28 14:39:47 -07:00
e83f851995 etcdserver: move cluster test from etcdhttp to etcdserver 2014-09-28 14:35:48 -07:00
15798a73d9 etcdserver: return client urls for /v2/machines 2014-09-26 16:50:15 -07:00
2a0f3d85c8 Merge pull request #1190 from jonboulle/undeprecate_peers_file
main: undeprecate peers-file for now
2014-09-26 13:57:36 -07:00
1d5d2e3726 *: Id -> ID for protobuf types
We use ID instead of Id in this project based on golang conventions.
2014-09-26 11:49:30 -07:00
04f6993108 main: undeprecate peers-file for now 2014-09-26 09:54:47 -07:00
61dc89e7f3 Merge pull request #1147 from philips/add-name
introduce cluster store
2014-09-25 18:46:18 -07:00
5e3fd6ee3f etcdserver: introduce the cluster and member
This introduces two new concepts: the cluster and the member.

Members are logical etcd instances that have a name, raft ID, and a list
of peer and client addresses.

A cluster is made up of a list of members.
2014-09-25 18:04:10 -07:00
56c64ab2e8 Merge pull request #1153 from jonboulle/1153_etcd_index
X-Etcd-Index off by one
2014-09-25 17:00:22 -07:00
9c9437a9e7 Merge pull request #1152 from jonboulle/1152_raft_headers
Missing X-Raft-Term & X-Raft-Index headers
2014-09-25 17:00:02 -07:00
9b3478218e etcdserver: add RaftIndex and RaftTerm 2014-09-25 16:46:24 -07:00
5874387871 Merge pull request #1183 from coreos/corspeer
main: remove cors wrapper for raft handler
2014-09-25 16:10:11 -07:00
8a60257bff main: remove cors wrapper for raft handler 2014-09-25 11:58:11 -07:00
9e46d54483 Merge pull request #1182 from coreos/cors
pkg: move cors.go to /pkg/cors.go
2014-09-25 11:49:04 -07:00
720aa6aeae pkg: move cors.go to /pkg/cors.go 2014-09-25 11:46:08 -07:00
0662afc95f Merge pull request #1181 from coreos/functional
functional: remove functional
2014-09-25 11:39:35 -07:00
5feef73a17 Merge pull request #1180 from coreos/elog
elog: remove elog
2014-09-25 11:35:58 -07:00
f393b1459a functional: remove functional 2014-09-25 11:34:39 -07:00
aab41f06d0 elog: remove elog 2014-09-25 11:33:10 -07:00
f96f1041fd Merge pull request #1179 from coreos/scripts
scripts: remove broken script
2014-09-25 11:31:56 -07:00
05d8f7270f scripts: remove broken scripts 2014-09-25 11:29:30 -07:00
e20e286064 Merge pull request #1178 from coreos/crc
pkg: move /crc to /pkg/crc
2014-09-25 10:55:24 -07:00
20ac0ee80d Merge pull request #1177 from coreos/tran
pkg: move /transport to pkg/transport
2014-09-25 10:55:11 -07:00
9158d293fd Merge pull request #1176 from coreos/testutil
pkg: move testutil to pkg
2014-09-25 10:51:56 -07:00
2f6086de22 pkg: move /crc to /pkg/crc 2014-09-25 10:50:33 -07:00
a0f5625728 pkg: move /transport to pkg/transport 2014-09-25 10:47:14 -07:00
45f71af33e pkg: move testutil to pkg 2014-09-25 10:40:40 -07:00
2e4f725c2b Merge pull request #1172 from jonboulle/1172_ttl_now
TTL=0 should expire keys "now"
2014-09-24 17:41:56 -07:00
2da1010cf7 etcdhttp: make TTL= equivalent to unset, and TTL=0 expire 2014-09-24 17:41:44 -07:00
db3afb18df Merge pull request #1164 from jonboulle/1164_dirs
Unable to create directories
2014-09-24 17:16:04 -07:00
f196276ca6 Merge pull request #1170 from jonboulle/version
main: add version flag
2014-09-24 17:14:13 -07:00
fa762e6b25 etcdhttp: process dir parameter in request 2014-09-24 17:11:28 -07:00
c82309d2b4 main: add version flag 2014-09-24 17:08:42 -07:00
98561f6b5d Merge pull request #1158 from jonboulle/1158_unset_ttl
"unsetting" a TTL fails
2014-09-24 17:01:50 -07:00
9ba35bc95e Merge pull request #1163 from jonboulle/1163_doc
Messages in documentation need updating
2014-09-24 17:01:18 -07:00
20ac7d6732 Merge pull request #1157 from jonboulle/1019_etcdserver
etcdserver: extend storeRecorder to test parameters
2014-09-24 16:58:57 -07:00
f603d90775 Merge pull request #1167 from bcwaldon/move-flag-code
Move flag-related code into new pkg package
2014-09-24 16:57:48 -07:00
42957815d3 Merge pull request #1168 from bcwaldon/moar-flags
etcd: deprecate remaining v0.4.6 flags
2014-09-24 16:51:33 -07:00
48e8ea1569 etcd: sort list of deprecated flags 2014-09-24 16:49:11 -07:00
2b52384e7e etcdhttp: allow empty values for TTL parameter 2014-09-24 16:44:55 -07:00
a6b7f4e5ea etcd: deprecate remaining v0.4.6 flags 2014-09-24 16:44:32 -07:00
4a65813a66 test: alphabetize list of testable packages 2014-09-24 16:37:46 -07:00
e30c1eeefd pkg: move SetFlagsFromEnv to pkg package 2014-09-24 16:29:47 -07:00
b0617be7e3 etcd: rewrite SetFlagsFromEnv test to use custom flagset 2014-09-24 16:27:00 -07:00
f7c353a703 etcd: export SetFlagsFromEnv 2014-09-24 16:12:06 -07:00
18c300f80c etcd: pass flagset into setFlagsFromEnv 2014-09-24 16:11:47 -07:00
314c13a8f0 pkg: move DeprecatedFlag to new package 2014-09-24 16:09:37 -07:00
002ace2403 etcd: remove unnecessary flag desc 2014-09-24 16:03:53 -07:00
13c20b1b64 docs: update error codes in api document 2014-09-24 15:59:40 -07:00
c2ced7dc70 etcdserver: add tests for Set and Dir=true/false 2014-09-24 15:57:06 -07:00
ef0ba361df etcdhttp: add test for expiration time 2014-09-24 15:46:40 -07:00
5059062275 Merge pull request #1166 from bcwaldon/override-usage
etcd: correctly override flag.Usage
2014-09-24 15:42:28 -07:00
69fba03fc1 etcd: correctly override flag.Usage 2014-09-24 15:39:06 -07:00
510213b1c2 Merge pull request #1159 from jonboulle/1159_prevvalue_required
`prevValue` ignored when no value provided
2014-09-24 15:30:25 -07:00
2e2cd12407 etcdhttp: disallow empty prevValue fields 2014-09-24 15:21:18 -07:00
f27b4cbbce store: add etcd-index tests 2014-09-24 15:04:32 -07:00
a45d490598 Merge pull request #1146 from jonboulle/1146_protobuf
script protobuf generation
2014-09-24 14:34:49 -07:00
c28fd92d10 etcdserver: extend storeRecorder to test parameters 2014-09-24 14:33:51 -07:00
b15fefa8ea store: use nextIndex where necessary 2014-09-24 14:07:52 -07:00
bbbd5fd5ec Merge pull request #1150 from bcwaldon/deprecated-flags
Slurp up deprecated flags, logging a warning
2014-09-24 14:04:30 -07:00
bcedef83d3 etcd: override flag usage func
No need to communicate deprecated flags, so prevent them from getting
printed in the usage info.
2014-09-24 13:52:58 -07:00
c8c55aa378 scripts: consolidate and standardize protobuf generation 2014-09-24 13:45:00 -07:00
1f736263b2 Merge pull request #1149 from unihorn/137
raft: stop tickElection when the node is not in peer list
2014-09-24 13:20:20 -07:00
ec1df42d04 Merge pull request #1138 from jonboulle/1138_timeout
etcdserver: handle watch timeouts and streaming
2014-09-24 12:39:34 -07:00
784d7ac680 etcd: warn on deprecated flags 2014-09-24 12:14:11 -07:00
a9caa24f8a etcdhttp: add test for streaming watches 2014-09-24 11:27:36 -07:00
ddc30c0a33 etcdserver: use Context to communicate timeout, and add tests 2014-09-24 11:27:36 -07:00
172a32e5e3 etcdserver: correct timeout and streaming handling
This reintroduces the 'stream' parameter to support long-lived watch
sessions. These sessions respect a server timeout (set to 5 minutes by
default).
2014-09-24 11:27:36 -07:00
7aaaf49fee Merge pull request #1148 from ThomasAlxDmy/master
Add link for etcd-backup
2014-09-24 11:17:06 -07:00
1ca03d8e9d raft: move logic to separate func 2014-09-24 10:23:44 -07:00
b07be74a82 raft: stop tickElection when the node is not in peer list
This prevents the bug like this:
1. a node sends join to a cluster and succeeds
2. it starts with empty peers and waits for sync, but it have not
received anything
3. election timeout passes, and it promotes itself to leader
4. it commits some log entry
5. its log conflicts with the cluster's
2014-09-23 23:15:02 -07:00
af01e11a5b Added link for etcd-backup 2014-09-23 17:07:17 -07:00
f34e37f68f Merge pull request #1134 from jonboulle/1134_flaky_test
flaky test TestSyncTriggerDeleteExpriedKeys
2014-09-23 16:13:19 -07:00
e97134e767 etcdserver: eliminate race in sync test 2014-09-23 15:49:20 -07:00
b85ad9bbc2 Merge pull request #1082 from jonboulle/1082_x_etcd_index
X-Etcd-Index returns the node's modifiedIndex
2014-09-23 15:14:21 -07:00
290b3915c2 Merge pull request #1144 from bcwaldon/TLS
Simplify TLS testing in transport pkg
2014-09-23 14:55:42 -07:00
03152004d7 Merge pull request #1145 from coreos/fix_panic
raft: node ignores unexpected local messages receiving from network
2014-09-23 14:11:56 -07:00
25c2768b8f raft: node ignores unexpected local messages receiving from network 2014-09-23 13:50:43 -07:00
dcdc7913c0 Merge pull request #1100 from unihorn/129
raft: add Configure
2014-09-23 13:50:10 -07:00
a299e92dfa transport: fake out certificate parser
The work being done in the tests is completely wasted, as we do not
need to test the udnerlying x509 library. Faking out the parser function
allows the tests to run much faster without having to carry massive
fixtures, either.
2014-09-23 13:49:32 -07:00
4d68c933d1 Merge pull request #1142 from bcwaldon/TLS
TLS: peer server/transport and proxy transport
2014-09-23 13:19:13 -07:00
c6cb635e01 etcdserver: refine comments of config change tests 2014-09-23 13:03:30 -07:00
4649a28097 transport: exercise TLSInfo.ClientConfig & ServerConfig 2014-09-23 12:52:59 -07:00
6ac4aea2bf transport: test TLSInfo.Empty() 2014-09-23 12:19:32 -07:00
3c4b155395 transport: spot-check NewTransport 2014-09-23 12:14:50 -07:00
bc7b0108dc raft: ConfigChange -> ConfChange 2014-09-23 12:02:44 -07:00
73504dca41 proxy: determine scheme based on TLSClientConfig 2014-09-23 11:01:58 -07:00
1ea3197feb proxy: pass addrs and scheme into newDirector 2014-09-23 11:01:55 -07:00
99e9f561ee etcdserver: add Peers.Addrs 2014-09-23 10:56:41 -07:00
b94d0281d4 etcd: use TLS in proxy transport 2014-09-23 10:19:01 -07:00
10220335f7 etcdserver: determine scheme based on TLSClientConfig 2014-09-23 10:14:12 -07:00
e19b0442f8 etcdserver: pass scheme into send 2014-09-23 10:14:11 -07:00
fb7968d704 etcdserver: Peers.Pick returns just an addr 2014-09-23 10:09:34 -07:00
27813599a1 etcd: wire up peer TLS flags 2014-09-23 10:03:17 -07:00
342ea18239 transport: build TLS config in NewTransport 2014-09-23 10:03:17 -07:00
e880dd41f2 transport: add TLSInfo.ClientConfig 2014-09-23 10:03:16 -07:00
0c7351c309 etcd: manually construct HTTP client for peer communication 2014-09-23 10:03:14 -07:00
5470a6d3d6 etcdserver: pass http client into Sender 2014-09-23 10:02:23 -07:00
db12e5704b transport: no need to set RootCAs in TLSInfo.ServerConfig 2014-09-23 09:04:26 -07:00
b754406f10 Merge pull request #1140 from bcwaldon/TLS
client server TLS
2014-09-23 08:04:50 -07:00
e89f6efd20 Merge pull request #1122 from coreos/discovery
discovery
2014-09-22 23:48:05 -07:00
d92931853e raft: Config -> ConfigChange
Configure -> ProposeConfigChange
AddNode, RemoveNode -> ApplyConfigChange
2014-09-22 23:39:53 -07:00
87df94dbd4 Merge pull request #1130 from jonboulle/1130_wal_log
wal logs saveState too frequently
2014-09-22 23:20:26 -07:00
08ebb05335 discovery: add a overfull case for waitNodes 2014-09-22 19:51:31 -07:00
fdfaf07c46 discovery: address comments 2014-09-22 19:51:31 -07:00
a35df0ad7c discovery: remove redundant comment for createSelf 2014-09-22 19:51:31 -07:00
17068c5110 discovery: key config -> key _config 2014-09-22 19:51:31 -07:00
6081311db5 discovery: store size inside /[cluster]/config 2014-09-22 19:51:31 -07:00
00d1daaf1e discovery: add tests for sortableNodes 2014-09-22 19:51:31 -07:00
2fd5a9863b discovery: add d.selfKey() 2014-09-22 19:51:31 -07:00
b8eb21c027 discovery: add fast path 2014-09-22 19:51:31 -07:00
2b623cf0fa discovery: init commit 2014-09-22 19:51:31 -07:00
cf4af47f7e wal: remove logging messages
These are noisy and unhelpful by default. We can re-add if at some point
we reintroduce debugging/multiple log levels.
2014-09-22 19:08:47 -07:00
5441c6aa54 etcdserver: correct X-Etcd-Index header
This adds an EtcdIndex field to store.Event and uses that as the header
instead of the node's modifiedIndex. To facilitate this in a non-racy
way, we set the EtcdIndex while holding the lock.
2014-09-22 18:56:12 -07:00
f2d3d90b60 etcd: wire up client TLS flags 2014-09-22 17:58:31 -07:00
17459c7bfc transport: wrap net.Listener with TLSInfo 2014-09-22 17:58:30 -07:00
a782a1a7d1 etcd: manually construct listeners 2014-09-22 17:57:44 -07:00
a4cca35e9d Merge pull request #1137 from philips/gofmt-hack
test: stop running gofmt ./
2014-09-22 17:28:48 -07:00
fd48f3f2a4 test: stop running gofmt ./
gofmt ./ will recursively check the .git directory. So use *.go for
gofmt instead
2014-09-22 17:28:31 -07:00
ec8f493fde raft: refine comments for Configure 2014-09-22 15:44:47 -07:00
dc36ae7058 raft: use pb.Config instead of []byte for Configure 2014-09-22 15:44:47 -07:00
4203569da2 etcdserver: use ConfigType in protobuf 2014-09-22 15:44:46 -07:00
b82d70871f raft: use EntryType in protobuf 2014-09-22 15:44:46 -07:00
b801f1affe raft: refine comment for raft.pendingConf 2014-09-22 15:44:46 -07:00
abdb2cad15 etcdserver: Config.Id -> Config.ID 2014-09-22 15:44:46 -07:00
aaffb9eb78 etcdserver: add AddNode, RemoveNode
AddNode and RemoveNode is used to propose config change to the cluster.
If succeeds, it will add/remove node from the cluster.
2014-09-22 15:44:46 -07:00
ff6705b94b raft: add Configure, AddNode, RemoveNode
Configure is used to propose config change. AddNode and RemoveNode is
used to apply cluster change to raft state machine. They are the
basics for dynamic configuration.
2014-09-22 15:43:13 -07:00
ceab948831 Merge pull request #1131 from bcwaldon/1129
etcdserver: init time.Time only if Expiration > 0
2014-09-22 15:39:32 -07:00
7d1126fb35 etcdserver: init time.Time only if Expiration > 0
golang's concept of "zero" time does not align with the zero value of
a unix timestamp. Initializing time.Time with a unix timestamp of 0
makes time.Time.IsZero fail. Solve this by initializing time.Time only
if we care about the time.
2014-09-22 15:31:31 -07:00
9711e70980 Merge pull request #1132 from jonboulle/fix_store
store: fix recursive/dir arguments
2014-09-22 14:54:37 -07:00
e08df4c8d2 store: fix recursive/dir arguments 2014-09-22 14:44:01 -07:00
34380ab096 Merge pull request #1013 from jonboulle/1013_cors
Add CORS support
2014-09-22 11:50:03 -07:00
e27b80643d Merge pull request #1109 from coreos/client
min client for discovery
2014-09-21 10:31:52 -07:00
49cc76d33b client: min client for discovery 2014-09-21 10:29:52 -07:00
0335422e81 Merge pull request #1098 from unihorn/131
fix sync tests
2014-09-20 17:47:31 -07:00
8ba801ec06 etcdserver: fix sync tests
This is to fix possible testing failures caused by sync tests.

Changes:
1. Get rid of time sleep operations, which introduces uncertainty.
2. Use fake Store.
2014-09-20 17:41:30 -07:00
ddfcb67ce3 Merge pull request #1118 from unihorn/133
etcdserver: add TestRecvSnapshot
2014-09-20 17:10:01 -07:00
fac38aad33 etcdserver: add TestRecvSlowSnapshot 2014-09-19 15:09:04 -07:00
1a36b53f14 main: add CORS support 2014-09-19 14:58:35 -07:00
b8e59a3c6a etcdserver: not push ready to readyNode automatically 2014-09-19 14:40:11 -07:00
f2ebd64a1b *: add testutil pkg 2014-09-19 14:32:38 -07:00
4eb156a324 Merge pull request #1104 from unihorn/132
etcdserver: add TestDoBadLocalAction
2014-09-19 09:30:34 -07:00
d5988c3ec2 etcdserver: add TestDoBadLocalAction 2014-09-19 09:22:26 -07:00
44ab66d858 etcdserver: add TestRecvSnapshot 2014-09-18 23:19:00 -07:00
da9956df11 Merge pull request #1107 from bcwaldon/Procfile
Isolate ./build from environment
2014-09-18 22:12:28 -07:00
24aa4d9bd9 Merge pull request #1117 from bcwaldon/prevExist
*: s/prevExists/prevExist/
2014-09-18 21:45:37 -07:00
91003cb994 *: s/prevExists/prevExist/ 2014-09-18 21:25:08 -07:00
517e4271e1 Merge pull request #1113 from jonboulle/unix
main: add address validation
2014-09-18 16:38:42 -07:00
f0789e7349 main: add address validation for bind-addr flag 2014-09-18 16:38:14 -07:00
6449387ccb Merge pull request #1110 from bcwaldon/proxy-readonly
Readonly proxy mode
2014-09-18 15:08:46 -07:00
98221cf6c0 Merge pull request #1112 from bcwaldon/update-link
CONTRIBUTING: update link to style guide
2014-09-18 15:06:59 -07:00
6e782b0e63 etcd: add -proxy=readonly 2014-09-18 15:05:33 -07:00
fd1f46313a proxy: add readonly handler 2014-09-18 15:05:30 -07:00
5b4fe8a558 CONTRIBUTING: update link to style guide 2014-09-18 15:03:55 -07:00
ec0e9c6e6a Procfile: run etcd from bin/etcd 2014-09-18 14:36:29 -07:00
81585716dc build: ignore calling environment 2014-09-18 14:36:26 -07:00
9cc114df36 Merge pull request #1106 from bcwaldon/proxy-flag
Replace -proxy-mode=<bool> with -proxy=<enum>
2014-09-18 14:31:00 -07:00
afce2948d2 etcd: replace -proxy-mode with -proxy 2014-09-18 14:30:22 -07:00
fcf50e756d test: actually test main pkg 2014-09-18 11:01:00 -07:00
df70f653a4 Merge pull request #1099 from unihorn/128
wal: OpenFromIndex fails if it cannot find previous index
2014-09-17 16:00:51 -07:00
655efca308 Merge pull request #1092 from jonboulle/dumb_gen_id
GenID: use a fast prnd
2014-09-17 16:00:25 -07:00
29f6d8a9e6 wal: add ErrFileNotFound and ErrIndexNotFound 2014-09-17 15:58:06 -07:00
a42d52482c etcdserver: use simple PRNG for GenID 2014-09-17 15:29:14 -07:00
1c544667ff Merge pull request #1040 from jonboulle/1040_config_env_vars
etcd needs to be configurable through env vars
2014-09-17 15:28:02 -07:00
7160b5ae26 wal: OpenFromIndex fails if it cannot find previous index
Example:
We save entry 1, 2, 3 to WAL.
If we try to open 100, it should fail.
2014-09-17 15:07:07 -07:00
f2e92d9140 Merge pull request #1097 from unihorn/130
etcdserver: use Action to fix possible data race
2014-09-17 14:28:37 -07:00
6b03135527 Merge pull request #1093 from jonboulle/node_interface
Create Node Interface
2014-09-17 14:20:42 -07:00
b66a40495d raft: introduce Node interface 2014-09-17 14:18:56 -07:00
844897360c main: add test for setting flags 2014-09-17 14:12:04 -07:00
ba851b2eca Merge pull request #1095 from coreos/nsnap
WIP *: init for on disk snap support
2014-09-17 14:02:48 -07:00
ab61a8aa9a *: init for on disk snap support 2014-09-17 13:56:12 -07:00
0ad0e24a86 etcdserver: use Action to fix possible data race 2014-09-17 13:48:03 -07:00
40c19e525c main: retrieve config from env vars 2014-09-17 12:15:39 -07:00
f17391a72b Merge pull request #1090 from jonboulle/1090_multiple_sockets
listen on multiple sockets
2014-09-16 15:29:05 -07:00
f786de13d0 Merge pull request #1081 from unihorn/125
make TTL work
2014-09-16 15:14:44 -07:00
a91d745c46 etcdserver: refine printout 2014-09-16 14:54:22 -07:00
936ecd097a main: listen for client requests on multiple sockets 2014-09-16 14:46:51 -07:00
757f400f5d Merge pull request #1091 from jonboulle/993_default_port
main: switch back to default ports for now
2014-09-16 14:37:57 -07:00
6d4c79b157 main: switch back to default ports 2014-09-16 14:36:59 -07:00
47b9b5520f Merge pull request #1010 from jonboulle/1010_separate_ports
separate ports used for client/server communication
2014-09-16 14:36:24 -07:00
de21c39ca5 raft: isStateEqual -> isHardStateEqual, IsEmptyState -> IsEmptyHardState 2014-09-16 13:55:00 -07:00
023dc7cba2 etcdserver: add SYNC request 2014-09-16 13:42:03 -07:00
38c690b155 Procfile: update to new address flags 2014-09-16 13:19:16 -07:00
67e57ffca4 etcdserver: split out client and server listeners 2014-09-16 11:36:37 -07:00
7a63e52901 Merge pull request #1088 from jonboulle/peers_tests
etcdserver/etcdhttp: add simple test for peers send
2014-09-15 22:13:46 -07:00
30b70e18c5 etcdserver/etcdhttp: add simple test for peers send 2014-09-15 21:10:00 -07:00
6f17fa6c90 Merge pull request #1087 from jonboulle/tests
etcdserver/etcdhttp: add tests for serveKeys
2014-09-15 20:52:03 -07:00
a7ec09c877 etcdserver/etcdhttp: use empty node for test 2014-09-15 20:34:14 -07:00
f846c5286a etcdserver/etcdhttp: fix comment, simplify resServer 2014-09-15 19:01:40 -07:00
27cf7747ea etcdserver/etcdhttp: add tests for serveKeys 2014-09-15 18:33:10 -07:00
43acdef660 Merge pull request #1086 from jonboulle/serve_raft_test
etcdserver/etcdhttp: add test for serveRaft
2014-09-15 16:13:08 -07:00
7ac3b32de6 etcdserver: change raft endpoint to send StatusNoContent 2014-09-15 16:10:31 -07:00
3e2c160eed etcdserver/etcdhttp: add test coverage for serveRaft 2014-09-15 16:07:06 -07:00
699bc50365 Merge pull request #1071 from jonboulle/serve_mux
etcdserver/etcdhttp: switch to using http.ServeMux
2014-09-15 16:05:58 -07:00
e04c028d64 etcdserver/etcdhttp: switch to using http.ServeMux 2014-09-15 16:05:20 -07:00
763c276d27 Merge pull request #1061 from jonboulle/server_interface
etcdserver: introduce Server interface
2014-09-15 15:36:11 -07:00
8a5ab2ec06 etcdserver: introduce Server interface
This changes etcdserver.Server to an interface, with the former Server
(now "EtcdServer") becoming the canonical/production implementation.
This will facilitate better testing of the http server et al with mock
implementations of the interface.
It also more clearly defines the boundary for users of the Server.
2014-09-15 15:11:01 -07:00
96624b1129 Merge pull request #1085 from unihorn/127
raft: remove unused raftpb.LastIndex
2014-09-15 15:09:09 -07:00
35ae488120 Merge pull request #1069 from jonboulle/methods
etcdhttp: check method for every endpoint, add tests
2014-09-15 14:56:47 -07:00
d9cfc35bed etcdhttp: check method for every endpoint, add tests 2014-09-15 14:56:43 -07:00
cc8d8f2102 raft: remove unused raftpb.LastIndex 2014-09-15 14:34:23 -07:00
07648f1f25 Merge pull request #1084 from unihorn/126
raft: remove unused return
2014-09-15 13:49:49 -07:00
9607665323 raft: remove unused return 2014-09-15 13:22:21 -07:00
9bf2c2ed9d Merge pull request #1052 from unihorn/121
server: add unit tests
2014-09-15 13:20:50 -07:00
6cd4434ff3 server: add unit tests
Make test coverage >= 90%
2014-09-15 13:16:48 -07:00
bc5791af11 Merge pull request #1077 from coreos/wal_cut
wal: cut(i uint64) -> cut
2014-09-15 10:37:41 -07:00
69f2d5c590 wal: refactor 2014-09-15 10:35:36 -07:00
77fbd2610c wal: add comment 2014-09-15 10:17:21 -07:00
1d09c25f5f wal: add walName function; cleanup test 2014-09-15 10:17:21 -07:00
cec1956b8f wal: better comment 2014-09-15 10:14:18 -07:00
8e0ee1cc5e wal: remove wrong comment for cut 2014-09-15 10:14:18 -07:00
1164c4b83d wal: recover writting seq 2014-09-15 10:14:18 -07:00
21860bc017 wal: cut(i uint64) -> cut 2014-09-15 10:14:18 -07:00
f9c12e2053 Merge pull request #1075 from coreos/fix_heartbeat
raft: fix heartbeat
2014-09-15 10:04:12 -07:00
38c074cb05 Merge pull request #1067 from unihorn/122
raft: write entry 0 into log
2014-09-15 10:00:49 -07:00
21d116d3e1 raft: fix heartbeat 2014-09-15 09:58:22 -07:00
140fd6d6c4 raft: restart using last written entry also 2014-09-15 09:56:33 -07:00
a9af70c52b raft: write entry 0 into log 2014-09-15 09:55:52 -07:00
29f9372370 Merge pull request #1080 from coreos/check_id
main: check node id is not noneid
2014-09-14 23:28:39 -07:00
e7ea6a374a main: check node id is not noneid 2014-09-14 23:28:11 -07:00
ff7f340bba Merge pull request #1063 from coreos/node_run_test
raft: test node block proposal
2014-09-14 22:46:50 -07:00
ed57a7b561 Merge pull request #1079 from philips/fix-procfile-non-zero
Procfile: don't use a 0x0 peer
2014-09-14 22:40:16 -07:00
e6e1f2ff7d Procfile: don't use a 0x0 peer
0x0 peer id is no longer valid, don't use it.
2014-09-14 22:39:46 -07:00
e085cc4e06 Merge pull request #1042 from unihorn/118
raft: set none to be 0
2014-09-14 22:32:37 -07:00
2927cc6e3b raft: refine plus assignment 2014-09-14 22:07:32 -07:00
03f0ed657a Merge pull request #1076 from coreos/test_race
test: test with race by default
2014-09-14 21:42:45 -07:00
10c9f7389b test: turn off go 1.2 testing on travis 2014-09-14 21:40:09 -07:00
e9b790e27b Merge pull request #1078 from unihorn/124
raft: remove unused field
2014-09-14 17:24:51 -07:00
da575c46fa raft: remove unused field 2014-09-14 13:08:35 -07:00
79b8153eac test: test with race by default 2014-09-14 13:08:14 -07:00
1037e7ce55 Merge pull request #1055 from bcwaldon/proxy-monster
proxy mode, pt II
2014-09-12 23:01:24 -07:00
a155f0bda6 proxy: rewrite stdlib ReverseProxy
The ReverseProxy code from the standard library doesn't actually
give us the control that we want. Pull it down and rip out what
we don't need, adding tests in the process.

All available endpoints are attempted when proxying a request. If a
proxied request fails, the upstream will be considered unavailable
for 5s and no more requests will be proxied to it. After the 5s is
up, the endpoint will be put back to rotation.
2014-09-12 22:56:23 -07:00
54b9c55af3 etcdserver: remove useless sleep
etcdserver.Do will block until there exists leader
2014-09-12 13:01:33 -07:00
34db45a948 raft: set propc, readyc to be nil before run loop 2014-09-12 12:57:50 -07:00
ccee264b7d raft: move defer after run 2014-09-12 12:28:15 -07:00
45f56a5377 raft: forceGoSched -> forceGosched 2014-09-12 12:27:18 -07:00
df253a2b14 Merge pull request #1066 from philips/add-raft-doc
add-raft-doc
2014-09-12 12:21:53 -07:00
5c884c7797 raft: better comment and naming 2014-09-12 12:18:30 -07:00
0c09862494 raft: add isStateEqual test 2014-09-12 11:59:32 -07:00
f9ef453894 raft: test contain updates 2014-09-12 11:51:25 -07:00
b261a5edc1 raft: test node block proposal 2014-09-12 11:51:25 -07:00
30289dad5c raft: more descriptive panic info 2014-09-12 11:39:53 -07:00
072a21782e Merge pull request #1049 from unihorn/120
raftLog: enhance check in compact
2014-09-12 11:35:41 -07:00
d31443f5a3 raftLog: compact applied entries only
compact MUST happen on entries that have been applied, or
1. it may screw up the log by setting wrong commitIndex
2. discard unapplied entries
2014-09-12 11:34:08 -07:00
6edb471d58 Merge pull request #1045 from unihorn/119
wal: change wal filename format
2014-09-12 11:31:46 -07:00
2030ca202f wal: change wal filename format
Make raftIndex section to be expected raftIndex of next entry.

It makes filename more intuitive and straight-forward.

The commit also adds comments for filename format.
2014-09-12 11:24:28 -07:00
1a0ad54d3e Merge pull request #1059 from coreos/node_test
test node step
2014-09-12 10:23:53 -07:00
98f9ee3613 raft: add useful comments
These comments were things I learned about the units, use case or
meaning of various fields and functions in the raft package.
2014-09-12 09:58:04 -07:00
58b8610024 raft: add a doc.go file
Explain the package from a high level.
2014-09-12 09:57:48 -07:00
50c1a34f78 Merge pull request #1060 from jonboulle/peers
etcdserver/etcdhttp: split out peers and add tests
2014-09-11 23:53:54 -07:00
073411f23f raft: remove vote with default value 2014-09-11 23:17:13 -07:00
dc1357afa9 raft: use raft helper function in testing 2014-09-11 19:26:29 -07:00
0e0fc2bd24 raft: use [1,n] as address list for raft state machines 2014-09-11 19:23:05 -07:00
84c2bd0b7d raft: set From of local message to be local id 2014-09-11 19:18:47 -07:00
20776f1947 etcdserver: use int64slice directly 2014-09-11 19:17:07 -07:00
281afa74ee raft: comments for TestNodeStep 2014-09-11 19:00:40 -07:00
e18b8c12be etcdserver: switch to proper int64Slice for sorting 2014-09-11 17:28:08 -07:00
81b5967e0a Merge pull request #1054 from philips/add-wal-doc
wal: add a doc file
2014-09-11 17:18:53 -07:00
eb1dcb324c raft: test node step 2014-09-11 17:10:36 -07:00
5f66b35852 etcdserver/etcdhttp: split out peers and add tests 2014-09-11 16:53:55 -07:00
c03798f99b Merge pull request #1011 from jonboulle/clean_http
Validate HTTP API user input
2014-09-11 15:31:25 -07:00
786982d8e5 simplify 2014-09-11 15:13:56 -07:00
52ddd389ff etcdhttp: use Form values over query parameters 2014-09-11 15:12:31 -07:00
40341b488c Merge pull request #1058 from philips/grammar-fix
raft: log comment grammar fix
2014-09-11 14:06:33 -07:00
3bc4b2db12 raft: log comment grammar fix 2014-09-11 13:59:50 -07:00
f7f65ec464 Merge pull request #1056 from coreos/test
test: test wait pkg
2014-09-11 13:56:51 -07:00
884c702512 wal: wal.OpenFromIndex -> wal.OpenAtIndex
The first entry read from the wal should be the index provided. This
name makes that more clear.
2014-09-11 12:52:06 -07:00
413b6a59ff wal: add more explanation to wal filename format 2014-09-11 12:51:50 -07:00
9bd9d88a9d test: sort the pkgs 2014-09-11 12:48:18 -07:00
0feb153034 test: test wait pkg 2014-09-11 12:38:43 -07:00
7c03704b19 etcdserver: restructure to hopefully simplify
Obviate parseBool helper, define emptyReq locally to parseRequest,
have writeEvent return an error which gets logged
2014-09-11 08:50:41 -07:00
04abd5603f wal: add a doc file 2014-09-10 20:40:20 -07:00
71a1c1aa84 Merge pull request #1053 from philips/proxy-in-procfile
Procfile: add a proxy
2014-09-10 18:47:53 -07:00
1ee8392a8f Procfile: add a proxy
Woo! Now we have a cluster and a proxy and etcdctl works when running
the procfile by default!
2014-09-10 18:47:32 -07:00
338ca6050e Merge pull request #1048 from bcwaldon/proxy-monster
proxy mode
2014-09-10 18:09:50 -07:00
7415d53020 proxy: add proxy-mode functionality to etcd daemon 2014-09-10 18:06:56 -07:00
e5a482266f proxy: introduce director
The director class drives an httputil.ReverseProxy. This is used when
etcd is deployed in proxy mode.
2014-09-10 18:04:03 -07:00
a3334eed23 main: break out startEtcd func 2014-09-10 18:04:02 -07:00
bafe960dba etcdhttp: add Peers.Endpoints 2014-09-10 18:02:02 -07:00
2b39ee1bb3 Merge pull request #1051 from bcwaldon/Id
*: s/Id/ID/
2014-09-10 16:13:04 -07:00
c251304068 *: s/Id/ID/
golang convention dictates that the individual characters in an
abbreviation should all have the same case. Use ID instead of Id.

The protobuf generator still generates code that does not meet
this convention, but that's a fight for another day.
2014-09-10 16:09:08 -07:00
e2d01eff35 etcdserver: switch to using etcd.Error 2014-09-10 15:46:13 -07:00
21c214ac03 Merge pull request #1050 from jonboulle/ignore
gitignore: ignore vim swap files
2014-09-10 15:09:45 -07:00
2342402434 etcdserver: address style comments 2014-09-10 14:14:14 -07:00
255e62dcdd gitignore: ignore vim swap files 2014-09-10 12:06:28 -07:00
bed63cddf7 etcdhttp: add tests for ParseBool/ParseUint64 helpers 2014-09-10 12:05:36 -07:00
e736a11ac4 etcdhttp: perform validation of query parameters
Add basic input validation of all query parameters supported by
serveKeys. Also restructures etcdhttp a bit to better facilitate
testing.

Test coverage is slightly improved.
2014-09-10 12:01:58 -07:00
3d272c2686 Merge pull request #1044 from unihorn/119
http: check err return from http.NewRequest
2014-09-09 20:48:56 -07:00
51e4bbfeb0 http: check err return from http.NewRequest 2014-09-09 20:46:56 -07:00
4e31bb308d raft: use const firstId to track ids 2014-09-09 19:07:20 -07:00
8c58684fb7 etcdserver: fix testServer 2014-09-09 16:59:42 -07:00
bac88c047b Merge pull request #1039 from philips/Procfile-note
Procfile: add a comment on how to use this
2014-09-09 16:49:08 -07:00
a9c288aadc Procfile: add a comment on how to use this 2014-09-09 16:48:25 -07:00
b50f96e2e1 raft: set none to be 0 2014-09-09 16:47:21 -07:00
70443adc8d Merge pull request #1038 from philips/vegan-etcd
*: stop using 0xBEEF
2014-09-09 16:43:54 -07:00
24fd126822 *: stop using 0xBEEF
Using 0xBEEF is annoying in examples because it makes it makes it look
like the user can use ascii or something. In the Procfile use
0x0,0x1,0x2,etc and use 0xBAD0 in test.
2014-09-09 16:40:51 -07:00
d9b35470a1 Merge pull request #1023 from unihorn/117
etcdhttp: add /v2/admin/machines endpoint
2014-09-09 16:23:23 -07:00
01871e7c29 http: use sort.Strings 2014-09-09 16:20:02 -07:00
68aa114301 Merge pull request #1035 from coreos/no_copy
raft: do not need to copy committed entries
2014-09-09 16:07:20 -07:00
d519491545 http: add TODO for peers var 2014-09-09 15:55:42 -07:00
7ac3afc02b Merge pull request #1037 from jonboulle/travis
build: add travis configuration
2014-09-09 15:50:21 -07:00
961a61d708 http: add allow func
For further extendability
2014-09-09 15:45:34 -07:00
0241b8ba9a build: add travis configuration 2014-09-09 15:44:41 -07:00
4087fa5c7a http: allow GET, HEAD for /v2/machines 2014-09-09 15:22:52 -07:00
0c1d1b7aeb etcdhttp: add /v2/machines endpoint 2014-09-09 15:00:29 -07:00
b8f2db36dd Merge pull request #1036 from philips/gitignore-etcd-data
gitignore: add _etcd_data directory ignores
2014-09-09 14:30:38 -07:00
6b647fd481 gitignore: add _etcd_data directory ignores
After 9a57d1067d we want to ignore all of
these _etcd_data directories.
2014-09-09 14:30:09 -07:00
e5cc58c179 Merge pull request #1032 from jonboulle/fix_tests
scripts: use bash for build script
2014-09-09 14:21:51 -07:00
eaffaacf5e raft: do not need to copy committed entries 2014-09-09 14:09:30 -07:00
1a677164be Merge pull request #1026 from coreos/fix_node
Fix node
2014-09-09 13:41:38 -07:00
a5e72258d2 Merge pull request #1029 from jonboulle/docker
scripts: remove non-functional Dockerfile
2014-09-09 12:15:23 -07:00
f7baea7406 Merge pull request #1017 from jonboulle/api_tests
HTTP API test coverage, pt 1
2014-09-09 12:12:56 -07:00
676b5be972 raft: use IsEmptyState 2014-09-09 11:58:15 -07:00
800de8e3bf scripts: use bash for build script 2014-09-09 11:34:55 -07:00
44acd57ea4 etcdserver: remove superfluous context 2014-09-09 11:18:25 -07:00
07ce8bc4bc etcdserver: split out functional test to new package 2014-09-09 11:18:24 -07:00
8473f3bf52 api: address review comments 2014-09-09 11:17:53 -07:00
c78239a629 etcdserver: add test coverage for parseRequest 2014-09-09 11:17:53 -07:00
b33b85870d etcdserver: add waitForEvent and encodeResponse coverage 2014-09-09 11:17:53 -07:00
f7444ff300 store: convert Watch to interface 2014-09-09 11:17:53 -07:00
7c8b1a553f Merge pull request #1028 from jonboulle/build
scripts: add build, cover and update test
2014-09-09 11:12:35 -07:00
6f06923e96 wal: test save empty state 2014-09-09 10:41:15 -07:00
ac0443bc89 raft: remove extra code 2014-09-09 10:16:39 -07:00
df259e5878 raft: add a newReady helper function 2014-09-09 10:16:39 -07:00
90c0db3d42 wal: do not save empty state 2014-09-09 10:15:29 -07:00
c28fef5fc4 raft: set ready.st to empty state, if current state is equal to previous state 2014-09-09 10:15:29 -07:00
b0d865e845 raft: record previous state is enough 2014-09-09 10:15:29 -07:00
0060c0749a raft: prev should be set only when we sucessfully send out rd to the channel 2014-09-09 10:15:29 -07:00
57ea72d3c4 Merge pull request #1030 from jonboulle/assorted
*: fix a few small issues identified by go vet
2014-09-09 07:46:45 -07:00
9997c9488a *: fix a few small issues identified by go vet 2014-09-08 23:52:36 -07:00
55b4267c30 Merge pull request #1001 from coreos/sender
etcdhttp: non-blocking sender
2014-09-08 23:36:10 -07:00
e7ad45b064 Merge pull request #1027 from jonboulle/master
raft: remove unused alwaysreadyc
2014-09-08 23:35:58 -07:00
e1d5caa7e8 scripts: remove non-functional Dockerfile 2014-09-08 23:20:14 -07:00
491362f5db scripts: add build, cover and update test
This adds a build script that attempts to be as user friendly as
possible: if they have already set $GOPATH and/or $GOBIN, use those
environment variables. If not, create a gopath for them in this
directory. This should facilitate both `go get` and `git clone` usage.

The `test` script is updated, and the new `cover` script facilitates
easy coverage generation for the repo's constituent packages by setting
the PKG environment variable.
2014-09-08 23:09:49 -07:00
946e35c958 raft: remove unused alwaysreadyc 2014-09-08 22:21:03 -07:00
4f330a9ba2 Merge pull request #999 from coreos/fix_flag_set
etcdhttp: set peer should clean up previous values
2014-09-08 22:11:51 -07:00
908d326e22 etcdhttp: use peer.String() in test 2014-09-08 20:50:35 -07:00
378cadf073 etcdhttp: implment Peers.String() 2014-09-08 20:45:10 -07:00
f4a33dd6df etcdhttp: simple test for peer set cleanup 2014-09-08 17:04:36 -07:00
5c8839387d etcdhttp: set peer should clean up previous values 2014-09-08 16:38:01 -07:00
9215ebb6aa Merge pull request #992 from coreos/wal
wal
2014-09-08 16:24:28 -07:00
12c1300d48 Merge pull request #987 from philips/add-test-script
test: introduce test script
2014-09-08 16:23:15 -07:00
4a02a1a60c main: clarify fatal message for unexpect nodeid 2014-09-08 16:21:27 -07:00
91c52630b6 test: introduce test script
Why do this? `go test ./...` has a ton of annoying output:

```
?   	github.com/coreos/etcd	[no test files]
?   	github.com/coreos/etcd/crc	[no test files]
?   	github.com/coreos/etcd/elog	[no test files]
?   	github.com/coreos/etcd/error	[no test files]
ok  	github.com/coreos/etcd/etcdserver	0.267s
ok  	github.com/coreos/etcd/etcdserver/etcdhttp	0.022s
?   	github.com/coreos/etcd/etcdserver/etcdserverpb	[no test files]
ok  	github.com/coreos/etcd/raft	0.157s
?   	github.com/coreos/etcd/raft/raftpb	[no test files]
ok  	github.com/coreos/etcd/snap	0.018s
?   	github.com/coreos/etcd/snap/snappb	[no test files]
third_party/code.google.com/p/gogoprotobuf/proto/testdata/test.pb.go🔢
undefined: __emptyarchive__.Extension
ok  	github.com/coreos/etcd/store	4.247s
ok
github.com/coreos/etcd/third_party/code.google.com/p/go.net/context
2.724s
FAIL
github.com/coreos/etcd/third_party/code.google.com/p/gogoprotobuf/proto
[build failed]
ok
github.com/coreos/etcd/third_party/github.com/stretchr/testify/assert
0.013s
ok  	github.com/coreos/etcd/wait	0.010s
ok  	github.com/coreos/etcd/wal	0.024s
?   	github.com/coreos/etcd/wal/walpb	[no test files]
```

And we have no had to manually configure drone.io which I want to avoid:
https://drone.io/github.com/coreos/etcd/admin
2014-09-08 16:18:10 -07:00
f3348d6e13 raft: fix the comment in test 2014-09-08 16:16:58 -07:00
9a57d1067d main: make default data to have _data_etcd suffix 2014-09-08 16:15:18 -07:00
19235c8104 raft: refactor restart test 2014-09-08 16:10:13 -07:00
e4d2b2a06a Merge pull request #1022 from philips/add-ready-docs
raft: add doc for the Ready struct
2014-09-08 16:02:21 -07:00
145882244f raft: add doc for the Ready struct 2014-09-08 15:59:15 -07:00
54734b0903 main/wal: add a const for 0700 magic number 2014-09-08 15:45:58 -07:00
b094410066 wal: change entries->ents for consistency 2014-09-08 15:40:12 -07:00
adff0f3813 wal: named return values for ReadAll. 2014-09-08 15:36:25 -07:00
a3b6a646eb main: check the id read by from wal. 2014-09-08 15:31:11 -07:00
ffd198808e Merge pull request #1020 from jonboulle/master
docs: add note about version, remove old Vagrantfile
2014-09-08 15:09:27 -07:00
26a5aaec34 docs: add link to 32-bit issue 2014-09-08 15:08:07 -07:00
9180919a30 docs: remove build instructions from README 2014-09-08 14:57:16 -07:00
8cd1b3a4f2 docs: remove nonfunctional Vagrantfile and instructions 2014-09-08 14:49:35 -07:00
7caa33d819 docs: update README to warn about master branch 2014-09-08 14:45:38 -07:00
8eadc9b8a5 Merge pull request #1005 from philips/quorum-maintainers
MAINTAINERS: add Brandon Philips
2014-09-08 14:38:55 -07:00
0461c517e4 wal: clarify TODO 2014-09-08 13:57:35 -07:00
36730ca613 main: use -> using 2014-09-08 10:32:49 -07:00
138ac0b296 CONTRIBUTING: require two people to review on etcd 2014-09-07 19:46:06 -07:00
c7ff6d4410 MAINTAINERS: add Brandon Philips
Need to make sure we have a quorum :)
2014-09-07 19:45:34 -07:00
4f57330e29 Merge pull request #1003 from bmizerany/b-newemail
MAINTAINERS: change email
2014-09-07 19:26:29 -07:00
756b54b4c3 MAINTAINERS: change email 2014-09-07 17:53:52 -07:00
cbec48e8f6 etcdhttp: non-blocking sender 2014-09-05 13:54:40 -07:00
8c9d7e3e93 main: add a helper function for starting raft 2014-09-05 10:24:13 -07:00
0851a1fe7f main: better error msg 2014-09-05 10:02:46 -07:00
ee78890f22 main: use data-dir as the path to data directory flag 2014-09-05 09:56:25 -07:00
1a6e908971 *: add wal 2014-09-05 09:52:40 -07:00
769c043537 Merge pull request #995 from jonboulle/master
doc: update build instructions in README
2014-09-04 23:25:48 -07:00
4cc39e4517 doc: update build instructions in README 2014-09-04 23:21:21 -07:00
dd49b7a133 Merge pull request #988 from coreos/default_peers
etcdserver: add default peer
2014-09-04 22:33:18 -07:00
bca8f9e0ed etcdserver: change default id to 0x1 2014-09-04 22:26:42 -07:00
8e6c8e068d .: add MAINTAINERS file 2014-09-04 18:01:09 -07:00
8408acf995 .: explain the LGTM protocol 2014-09-04 17:08:21 -07:00
f41fac0719 Merge pull request #983 from marineam/doc
docs: fix documentation for HTTP read/write timeouts
2014-09-04 15:17:07 -07:00
5ddfe18cda Merge pull request #989 from coreos/fix_ignore_term
raft: fix ignore term
2014-09-04 14:36:56 -07:00
8dfa490e49 raft: fix ignore term 2014-09-04 14:33:51 -07:00
28102e536b Revert "build: add build script and update readme"
This reverts commit 2866a7488e.
2014-09-04 14:06:19 -07:00
08ad47fe1a Merge pull request #991 from jonboulle/master
build: add build script and update readme
2014-09-04 13:58:09 -07:00
2866a7488e build: add build script and update readme 2014-09-04 13:57:45 -07:00
25ee66c6c7 Merge pull request #990 from coreos/fix_node_test
Fix node test
2014-09-04 13:55:50 -07:00
e30505d33b raft: fix node test 2014-09-04 11:42:11 -07:00
d7a289ee41 raft: init prev: vote for none 2014-09-04 11:09:55 -07:00
c1e7a788cd etcdserver: add default peer 2014-09-04 10:11:32 -07:00
a7102d491b docs: fix documentation for HTTP read/write timeouts
The documentation for these options has been incorrect ever since their
addition via commit 084dcb55. This broke upgrading a CoreOS stable
cluster to 410.0.0 because the user was using the example TOML config
which contains:

    http_write_timeout = 10

This was silently ignored in the old stable version which predates the
addition of these options. After upgrading etcd began failing with:

    Type mismatch for 'config.Config.http_write_timeout': Expected float
    but found 'int64’.

Original issue: https://github.com/coreos/update_engine/issues/45
2014-09-03 23:36:36 -07:00
e393509879 Merge pull request #981 from coreos/v2prefix
etcdhttp: add v2prefix
2014-09-03 22:05:07 -07:00
e7eff1a975 Merge pull request #982 from coreos/fix_tick
Fix tick
2014-09-03 22:02:33 -07:00
8f4c615704 raft: leader should tick heartbeat 2014-09-03 22:01:31 -07:00
f1856abe60 etcdhttp: add v2prefix 2014-09-03 21:52:16 -07:00
efe2141c16 Merge pull request #980 from bmizerany/b-fixthings
fix vendoring and a test
2014-09-03 21:47:11 -07:00
d844377ca6 *: vendor context 2014-09-03 20:06:16 -07:00
172c1eae5d etcdhttp: fix test build 2014-09-03 20:01:54 -07:00
99c7371337 etcdserver: use vendored gogoproto 2014-09-03 19:47:05 -07:00
a4c8bfa7b4 Merge pull request #874 from etcd-team/raft
replace goraft
2014-09-03 17:07:54 -07:00
dae165eeaa Merge pull request #83 from etcd-team/snappb
snapshot: move pb to snappb; remove clusterId
2014-09-03 17:03:28 -07:00
16d337db70 Merge pull request #84 from etcd-team/walpb
wal: move pb files to walpb
2014-09-03 17:03:16 -07:00
b98cf17209 wal: move pb files to walpb 2014-09-03 16:46:42 -07:00
9e77d180c4 snapshot: move pb to snappb; remove clusterId 2014-09-03 16:33:41 -07:00
3ee83bc194 Merge pull request #82 from etcd-team/b-fiximports
coerce gogoproto files to import from third_party
2014-09-03 16:20:58 -07:00
5a62df3691 Merge pull request #81 from etcd-team/b-fixbrokenwaltests
wal: fix broken tests
2014-09-03 16:07:45 -07:00
3aa90b32f9 snap: coerce import gogoproto from third_party 2014-09-03 16:01:18 -07:00
10b73418cf wal: coerce import gogoproto from third_party 2014-09-03 16:00:42 -07:00
46a7a61b7d wal: fix broken tests 2014-09-03 15:56:28 -07:00
814558306e raft: coerce import gogoproto from third_party 2014-09-03 15:51:09 -07:00
215662188b Documentation: Clarify etcd security documentation
Signed-off-by: Vincent Ambo <vincent@kivra.com>
2014-09-04 00:40:22 +02:00
077f57d1c6 Merge pull request #80 from etcd-team/b-rmconf
raft: remove configuration
2014-09-03 15:26:35 -07:00
8d9b7b1680 raft: remove entry type 2014-09-03 15:24:47 -07:00
8463421448 raft: remove configuration 2014-09-03 15:23:05 -07:00
ade71208a2 Merge pull request #70 from etcd-team/wal_crc
wal: add basic crc
2014-09-03 15:12:08 -07:00
bdb954b2f5 wal: fix wal 2014-09-03 15:10:15 -07:00
70580de197 Merge pull request #79 from etcd-team/use_msg
raft: make tick send out messages.
2014-09-03 13:50:59 -07:00
3c77693881 raft: make tick send out messages. all state machine actions should be taken inside step function. 2014-09-03 10:17:09 -07:00
966cfd6e8e raft: fix elapsed reset 2014-09-03 09:20:20 -07:00
01be21985d third_party: remove go-etcd/go-systemd dependencies 2014-09-03 09:20:20 -07:00
2ba57ee75d *: remove unused pkgs 2014-09-03 09:20:20 -07:00
03174c9361 etcdhttp: log m.From 2014-09-03 09:20:20 -07:00
146e447cea etcdhttp: remove sending log 2014-09-03 09:20:20 -07:00
f2d200a826 raft: log only new/no leader 2014-09-03 09:20:20 -07:00
db8e4a2fc0 raft: remove debug logging 2014-09-03 09:20:20 -07:00
cf91035a36 main: log hex of id 2014-09-03 09:20:20 -07:00
576e26ea39 oops 2014-09-03 09:20:20 -07:00
d218034630 boom 2014-09-03 09:20:20 -07:00
fa11eef6d0 all campaign 2014-09-03 09:20:19 -07:00
bb185a858f raft: fix params 2014-09-03 09:20:19 -07:00
b796d227f1 add some logging 2014-09-03 09:20:19 -07:00
06dea4830d Procfile 2014-09-03 09:20:19 -07:00
dcd64f2a59 ... 2014-09-03 09:20:19 -07:00
728690fa03 hanging 2014-09-03 09:20:19 -07:00
8f3544ece8 server of one is alive! 2014-09-03 09:20:19 -07:00
cb7b321240 boom 2014-09-03 09:20:19 -07:00
c87f1d3924 fix printf 2014-09-03 09:20:19 -07:00
24afe8d22b remove prefix 2014-09-03 09:20:19 -07:00
9cdb7f073d ... 2014-09-03 09:20:19 -07:00
51d3dc7f6b typo 2014-09-03 09:20:19 -07:00
22c8ec0a80 ... 2014-09-03 09:20:18 -07:00
fc9fc3f888 ... 2014-09-03 09:20:18 -07:00
6d720fb33f raft: replace Context with Stop 2014-09-03 09:20:18 -07:00
a0922ebd0f etcdserver: light docs 2014-09-03 09:20:18 -07:00
6d7acc6b1e etcdhttp: never return 0 from genId 2014-09-03 09:20:18 -07:00
56c6fab53c etcdserver: refactor a bit 2014-09-03 09:20:18 -07:00
2b260a7ae5 etcdserver: QGET 2014-09-03 09:20:18 -07:00
2d9553cb18 etcdserver: cleanup 2014-09-03 09:20:18 -07:00
68968c2cb0 etcdserver: randomize Step 2014-09-03 09:20:18 -07:00
f4613dd466 store: remove Root 2014-09-03 09:20:18 -07:00
ba7d174349 etcdserver: add docs 2014-09-03 09:20:18 -07:00
2a212c9016 etcdserver: replace fmt with t.Logf 2014-09-03 09:20:18 -07:00
e9bb7c26fa etcdserver: set 10x the keys in test 2014-09-03 09:20:17 -07:00
97ee4dc847 etcdserver: working test 2014-09-03 09:20:17 -07:00
f8be54b416 ...deadlocked... 2014-09-03 09:20:17 -07:00
17e56a1c57 etcdserver/etcdhttp: basic test working 2014-09-03 09:20:17 -07:00
7469871d20 raft: remove proposal id / add test 2014-09-03 09:20:17 -07:00
c84a25e433 etcdhttp: parse boolpointer 2014-09-03 09:20:17 -07:00
c7cb8275c3 etcdserver: move protobuf to etcdserverpb 2014-09-03 09:20:17 -07:00
e8e588c67b raft: move protobufs into raftpb 2014-09-03 09:20:17 -07:00
59115b85f7 etcdserver/etcdhttp: remove unncessary else 2014-09-03 09:20:17 -07:00
163b27c759 etcdserver/etcdhttp: remove error return from parseRequest 2014-09-03 09:20:17 -07:00
05b2d76d54 etcdserver/etcdhttp: parseRequest 2014-09-03 09:20:17 -07:00
07058d3e0b etcdserver/etcdhttp: be specific about the keys path match 2014-09-03 09:20:17 -07:00
ddd219f297 many: marshal message 2014-09-03 09:20:16 -07:00
1eb2512961 raft: only allow one message to Step 2014-09-03 09:20:16 -07:00
38e8f3b764 etcdserver/etcdhttp: fix typo 2014-09-03 09:20:16 -07:00
c4defbc45c etcdserver/etcdhttp: break out wait
The assignment of ev was getting burried in the select. This makes it
easier to grok encodeResponse.
2014-09-03 09:20:16 -07:00
8c3450e200 etcdserver/etcdhttp: cancel wait on conn close 2014-09-03 09:20:16 -07:00
665af71888 etcdserver/etcdhttp: apply in single goroutine to avoid race 2014-09-03 09:20:16 -07:00
cd3f047ccd etcdserver/etcdhttp: remove closenotify watch 2014-09-03 09:20:16 -07:00
7638acdf37 etcdserver/etcdhttp: response with 504 2014-09-03 09:20:16 -07:00
735647e6a3 etcdserver/etcdhttp: cancel long requests on conn close 2014-09-03 09:20:16 -07:00
8cffd75e00 etcdserver/etcdhttp: encode response 2014-09-03 09:20:16 -07:00
b2e0836bb3 etcdserver/etcdhttp: wip 2014-09-03 09:20:16 -07:00
2d3cef2496 etcdserver: set -> existsSet 2014-09-03 09:20:16 -07:00
78d7b38a17 etcdserver: introduce Set 2014-09-03 09:20:15 -07:00
e79e9c4853 etcdserver: give update/create higher priority 2014-09-03 09:20:15 -07:00
5585984ed7 etcdserver: add CompareAndDelete 2014-09-03 09:20:15 -07:00
07c997f98c etcdserver: add create and delete 2014-09-03 09:20:15 -07:00
30fa119345 etcdserver: use context.TODO() 2014-09-03 09:20:15 -07:00
d2b99aa7c9 etcdserver: note that apply may need Context 2014-09-03 09:20:15 -07:00
f4d8c3fc66 etcdserver: more methods added 2014-09-03 09:20:15 -07:00
225e618b8f raft: add Id to Entry 2014-09-03 09:20:15 -07:00
3dd6280df5 etcdserver: need to add id to proposal :/ 2014-09-03 09:20:15 -07:00
c98f1cb501 etcdserver: remove panic and return default err 2014-09-03 09:20:15 -07:00
021e231476 raft: ReadState -> Ready, which returns a chan 2014-09-03 09:20:15 -07:00
432bc74a58 etcdserver: Send and Save 2014-09-03 09:20:15 -07:00
008337e150 etcdserver: wip 2014-09-03 09:20:14 -07:00
edac2e909b etcdserver: wip 2014-09-03 09:20:14 -07:00
91b62c0fbf raft: messages -> byMsgType 2014-09-03 09:20:14 -07:00
ad307c6965 raft: go fmt 2014-09-03 09:20:14 -07:00
7486d3d4c5 raft: mention error in doc 2014-09-03 09:20:14 -07:00
481e229ad4 raft: unblock progress by deproitizing proposals in Step 2014-09-03 09:20:14 -07:00
f87a6f3c1f raft: sift proposals from other message types in Step 2014-09-03 09:20:14 -07:00
4aa15294a8 raft: re-remove clusterId from raft 2014-09-03 09:20:14 -07:00
134a962222 raft: move raft2 to raft 2014-09-03 09:20:14 -07:00
15bb84d320 raft: move in entry.proto 2014-09-03 09:20:14 -07:00
5e91b3b716 raft: remove unused commentted-out code 2014-09-03 09:20:14 -07:00
9acb4cf2b0 raft: move raft.nextEnts to tests 2014-09-03 09:20:14 -07:00
c4b6896338 raft: add/deleteIns -> add/delProgress 2014-09-03 09:20:13 -07:00
5abdfda06a raft: pendingConf -> configuring 2014-09-03 09:20:13 -07:00
dd7aa95379 raft: remove atomicInt 2014-09-03 09:20:13 -07:00
75dce35a5d raft: correct hasLeader 2014-09-03 09:20:13 -07:00
72c65e74f5 raft: remove setX methods 2014-09-03 09:20:13 -07:00
5deaada0dc raft: remove EmptyState 2014-09-03 09:20:13 -07:00
9616162dbc raft: remove return bool 2014-09-03 09:20:13 -07:00
022a663e91 raft: newStateMachine -> newRaft 2014-09-03 09:20:13 -07:00
a8c123c6c2 raft: ins -> prs 2014-09-03 09:20:13 -07:00
79de1dc339 raft: sm -> r 2014-09-03 09:20:13 -07:00
3c483e19d7 raft: index{} -> progress{} 2014-09-03 09:20:13 -07:00
1b37f313a6 raft: remove unused IsMsgApp 2014-09-03 09:20:13 -07:00
0f50188652 raft: remove clearState 2014-09-03 09:20:12 -07:00
3823b74208 raft: remove unneeded fields 2014-09-03 09:20:12 -07:00
1d40440830 raft: remove old pointer 2014-09-03 09:20:12 -07:00
ea66d94273 raft: fix ReadState 2014-09-03 09:20:12 -07:00
61a413c219 raft: block ReadState until state updates 2014-09-03 09:20:12 -07:00
10eb997621 raft: whoops 2014-09-03 09:20:12 -07:00
c312d6efad raft: use Equal in example 2014-09-03 09:20:12 -07:00
92bdb1390d raft: update based on example 2014-09-03 09:20:12 -07:00
ff14d1de52 raft: example 2014-09-03 09:20:12 -07:00
6e6d81f094 raft: copy ents to avoid races 2014-09-03 09:20:12 -07:00
71ed92b6bd raft: implement ReadState 2014-09-03 09:20:12 -07:00
f1f8fc4228 raft: sm.vote -> State.Vote 2014-09-03 09:20:12 -07:00
40ed560e16 raft: index -> State.LastIndex 2014-09-03 09:20:12 -07:00
c7e17e2f9e raft: term -> State.Term 2014-09-03 09:20:11 -07:00
220a923a2d raft: remove info 2014-09-03 09:20:11 -07:00
0453d09af6 raft: moved into new raft 2014-09-03 09:20:11 -07:00
f03c3bce05 raft: seperate dequeuing from slicing 2014-09-03 09:20:11 -07:00
e17f79ee70 raft: start tick 2014-09-03 09:20:11 -07:00
8d37587e47 raft: remove sync
We don't need SyncNode. We only care about things that have made it
through the store. We can do this there.
2014-09-03 09:20:11 -07:00
ce7536e564 raft2: wip - to bring in ../raft soon 2014-09-03 09:20:11 -07:00
e2d8e1868b wait: Waiter -> WaitList 2014-09-03 09:20:11 -07:00
f9c4ba3ea3 wait: init 2014-09-03 09:20:11 -07:00
85103adfe0 wal: move record method to record.go 2014-09-03 09:20:11 -07:00
3699f2e5f9 etcdserver: rename someMachineMessage->machineMessage 2014-09-03 09:20:11 -07:00
4c116a5a01 etcd: add consistent get 2014-09-03 09:20:10 -07:00
f6a9599eb4 *: rename etcd to etcdserver 2014-09-03 09:20:10 -07:00
2ff75cda0e server: remove panic or fatal in participant.run 2014-09-03 09:20:10 -07:00
ebafba0043 server: don't print out errors that cannot be resolved 2014-09-03 09:20:10 -07:00
fab17f216d server: recover peerHub when restart from snapshot 2014-09-03 09:20:10 -07:00
27c9a0535c server: add tests for on-disk snapshot 2014-09-03 09:20:10 -07:00
5fdc124578 etcd: clean up snap 2014-09-03 09:20:10 -07:00
a28dc4559b raft/etcd: recover node 2014-09-03 09:20:10 -07:00
63489b9ef5 etcd: snap and wal init 2014-09-03 09:20:10 -07:00
442cae6844 wal: support multiple files 2014-09-03 09:20:10 -07:00
4296cd3fa4 *: remove old server 2014-09-03 09:20:10 -07:00
f891199ab0 snap: refactoring 2014-09-03 09:20:09 -07:00
f664c02a40 snap: handle snapshot file error robustly 2014-09-03 09:20:09 -07:00
338f120cbf snap: check mkdir error in tests 2014-09-03 09:20:09 -07:00
aff5b75487 snap: separate Load to Load and snapNames 2014-09-03 09:20:09 -07:00
71d12d3330 snap: fix typo 2014-09-03 09:20:09 -07:00
3b2a90e775 snap: separate different sections in the filename by adding dash 2014-09-03 09:20:09 -07:00
f7417cf693 server: add testCluster.Add
and fix possible testing error.
2014-09-03 09:20:09 -07:00
f7580cd3b6 snap: fix missing continue 2014-09-03 09:20:09 -07:00
12a9b84b2b snap: better naming 2014-09-03 09:20:09 -07:00
94521738a9 snap: init commit 2014-09-03 09:20:09 -07:00
c1da78601a server: use random generated node id 2014-09-03 09:20:09 -07:00
a5df254e53 raft: add clusterId to snapshot 2014-09-03 09:20:08 -07:00
c1c2aeffab etcd: attach default scheme to the peer-list if scheme is not given 2014-09-03 09:20:08 -07:00
cc1df691cc store: fix the bug caused by random iteration order over map 2014-09-03 09:20:08 -07:00
e9a22d0f34 etcd: make retry configurable 2014-09-03 09:20:08 -07:00
33465a7e42 server: fix testings
Make WaitMode panic to alert.
2014-09-03 09:20:08 -07:00
bb95187bc7 server: more better testing 2014-09-03 09:20:08 -07:00
cce88a8504 etcd: better testing... 2014-09-03 09:20:08 -07:00
6e9947599a server: add testServer and testCluster 2014-09-03 09:20:08 -07:00
14a6584a22 etcd: defer afterTest 2014-09-03 09:20:08 -07:00
0ba26afb4d etcd: remove skipped test 2014-09-03 09:20:08 -07:00
d71865e094 etcd: cleanup tests 2014-09-03 09:20:08 -07:00
8e2557697f etcd: rename initTestServer -> newUnstartedTestServer 2014-09-03 09:20:08 -07:00
3229c91dbb etcd: replace buildServer with runServer in tests 2014-09-03 09:20:07 -07:00
0881021e54 all config -> cfg 2014-09-03 09:20:07 -07:00
a5eec89113 cfg/ -> conf/ 2014-09-03 09:20:07 -07:00
08b370ebe4 main: remove query_params*.go 2014-09-03 09:20:07 -07:00
3653287c97 Revert "Documentation -> doc"
This reverts commit 9c179224aa04f0f25c52dd7b66576c3faf56cfc9.
2014-09-03 09:20:07 -07:00
9203f68894 server: add /v2/stats/self 2014-09-03 09:20:07 -07:00
5574b6e224 server: add /v2/stats/leader 2014-09-03 09:20:07 -07:00
41ccf13393 config -> cfg
It is extremely confusing to use variables named the same as a package.
Please no longer do this.
2014-09-03 09:20:07 -07:00
18c4be469f move ./http to main 2014-09-03 09:20:07 -07:00
6f3162af69 Documentation -> doc 2014-09-03 09:20:06 -07:00
b4fd9353cf remove fixtures 2014-09-03 09:20:06 -07:00
a2b9f9310c remove pkg/strings 2014-09-03 09:20:06 -07:00
1039f3dcea remove bench 2014-09-03 09:20:06 -07:00
d77773acb3 server: ignore server in build/tests 2014-09-03 09:20:06 -07:00
afc69b6a74 remove osext 2014-09-03 09:20:06 -07:00
ecc0f97e27 remove go-log 2014-09-03 09:20:06 -07:00
e2798405f6 remove test.sh 2014-09-03 09:20:06 -07:00
7b2474681b remove pkg/http 2014-09-03 09:20:06 -07:00
0ecbe891b5 remove pkg/btrfs 2014-09-03 09:20:05 -07:00
68b3644ac7 remove vestigial build script 2014-09-03 09:20:05 -07:00
7aa0da7c91 remove go_version 2014-09-03 09:20:05 -07:00
902f1864b1 remove contrib 2014-09-03 09:20:05 -07:00
45dc778fbb remove goprotobuf 2014-09-03 09:20:05 -07:00
0f1e18f8f0 remove toml dep 2014-09-03 09:20:05 -07:00
65f7833c22 remove go-httpclient 2014-09-03 09:20:05 -07:00
91daf1da86 remove gorilla and its users 2014-09-03 09:20:05 -07:00
7da180cfc5 metrics: remove old metrics 2014-09-03 09:20:05 -07:00
e9a45ae35d remove goraft 2014-09-03 09:20:05 -07:00
1805c15093 config: remove toml 2014-09-03 09:20:04 -07:00
622ee60d4f etcd: remove unused field seeds in participant struct 2014-09-03 09:20:04 -07:00
cc1b4b7ef0 etcd: no more mutex 2014-09-03 09:20:04 -07:00
d9ff56d7b7 etcd: cleanup locking in run 2014-09-03 09:20:04 -07:00
3af8c7da3c etcd: we should trust people 2014-09-03 09:20:04 -07:00
55c4a3307d server: cleanup participant stop 2014-09-03 09:20:04 -07:00
20c995c142 server: remove return value of func run 2014-09-03 09:20:04 -07:00
d8424a15dd etcd: remove unnecessary StopProposalWaiters function 2014-09-03 09:20:04 -07:00
b5b2031d5b wal: prune repeative logging 2014-09-03 09:20:04 -07:00
c19932c9ba raft: prune unnecessary logging - fixes #15 2014-09-03 09:20:04 -07:00
f911196e5f server: not add node that has been in the cluster 2014-09-03 09:20:04 -07:00
c9edb762b7 server: add TLSHandshakeTimeout for peer hub client 2014-09-03 09:20:03 -07:00
394893ff92 server: not set participant status for peer that points to itself 2014-09-03 09:20:03 -07:00
01fdaea8a6 server: not create new peer if exists 2014-09-03 09:20:03 -07:00
434bf8ca81 server: rewrite keepSetting in TestMultiNodeKillOne
It avoids blocking http request.
2014-09-03 09:20:03 -07:00
b1426e2635 server: wait for entries to be committed in TestClusterConfigReload 2014-09-03 09:20:03 -07:00
659eb5fd2a wal: make record a protobuf type 2014-09-03 09:20:03 -07:00
d0dc7427dd server: serve /v2/admin on raftPubAddr 2014-09-03 09:20:03 -07:00
8e06333d45 raft: make State a protobuf type 2014-09-03 09:20:03 -07:00
b9e7c20a4c etcd: make cmd a protobuf type
Conflicts:
	etcd/v2_apply.go
	etcd/v2_store.go
2014-09-03 09:20:03 -07:00
d6c3ebb1a0 raft: make Info a protobuf type 2014-09-03 09:20:03 -07:00
a191df10a3 server: p.Get -> p.QuorumGet 2014-09-03 09:20:03 -07:00
cd4b35c841 server: add QuorumGet 2014-09-03 09:20:02 -07:00
5ffc0adccc server: participant.Get -> participant.Store.Get 2014-09-03 09:20:02 -07:00
3529c381cf server: add TODO for /v2/stats 2014-09-03 09:20:02 -07:00
4b3c3203ff server: stop timer when exit 2014-09-03 09:20:02 -07:00
4f10917ce9 etcd: add a read/write timeout to server
The default is for connections to last forever[1]. This leads to fds
leaking. I set the timeout so high by default so that watches don't have
to keep retrying but perhaps we should set it slower.

Tested on a cluster with lots of clients and it seems to have relieved
the problem.

[1] https://groups.google.com/forum/#!msg/golang-nuts/JFhGwh1q9xU/heh4J8pul3QJ

Original Commit: 084dcb5596
From: philips <brandon@ifup.org>
2014-09-03 09:20:02 -07:00
e587402c26 server: Flush headers when using wait=true and stream=true
Many http clients will missbehave unless they get an initial http-
response, even when long-polling. It also saves the user/client from
having to handle headers on the first action of the watch, but rather
handle the response immediately.

Original commit: 2338481bb1
From: Christoffer Vikström
2014-09-03 09:20:02 -07:00
431ff3cce1 raft: minor change on code 2014-09-03 09:20:02 -07:00
7c3e202c94 etcd: add recover 2014-09-03 09:20:02 -07:00
15029381e1 raft: fix promotable 2014-09-03 09:20:02 -07:00
01c40fcf50 raft: not recover from outdated snapshot 2014-09-03 09:20:02 -07:00
ba63cf666d raft: add recover 2014-09-03 09:20:02 -07:00
6030261363 etcd/raft: add snap 2014-09-03 09:20:02 -07:00
943fede19c server: panic when fail to save in wal 2014-09-03 09:20:01 -07:00
2d870fa65b wal: add first level logging 2014-09-03 09:20:01 -07:00
969b529b08 wal: fix O_RDONLY attr when opening old file 2014-09-03 09:20:01 -07:00
38ec659cd6 raft: make Entry a protobuf type 2014-09-03 09:20:01 -07:00
193679e041 server: wait longer in afterTest
Because we sets dial timeout to be 200ms, afterTest should wait
> 200ms.
2014-09-03 09:20:01 -07:00
7bb6230588 peerHub: add response timeout for http client 2014-09-03 09:20:01 -07:00
069a288a59 peer: wait a little before closing idle connections
It seems that it needs some time to set connections that just used
as idle.
2014-09-03 09:20:01 -07:00
611d564865 raft: remove unused prevTerm field 2014-09-03 09:20:01 -07:00
43c9ca895b wal: fix append entry 2014-09-03 09:20:01 -07:00
54b4f52e48 raft: add index to entry 2014-09-03 09:20:01 -07:00
46eab903e9 etcd: do not generate id if next state is stop 2014-09-03 09:20:01 -07:00
0197ce4c66 server: move TestMultiNodeKillAllAndRecovery to etcd/ 2014-09-03 09:20:00 -07:00
215820dd40 server: move TestMultiNodeKillOne to etcd/ 2014-09-03 09:20:00 -07:00
a0fbc289ec server: move discovery tests to etcd/
TestDiscoveryDownNoBackupPeersWithDataDir -> TestRunByDataDir
remove TestDiscoveryRestart
2014-09-03 09:20:00 -07:00
5283002132 server: set short dial timeout for raft communication 2014-09-03 09:20:00 -07:00
28634fce47 wal: Flush -> Sync 2014-09-03 09:20:00 -07:00
2b0936271c server: fix 2nd watch timeout in TestSingleNodeRecovery
When recovering from data dir, the node needs election timeout to
elect itself to be the leader.
2014-09-03 09:20:00 -07:00
01322cd243 server: move TestClusterConfigReload to etcd/ 2014-09-03 09:20:00 -07:00
21fb7b4fbb server: improve TestKillLeader and TestKillRandom
Remove testing on 11-node cluster due to lack of fds
2014-09-03 09:20:00 -07:00
efaef49734 server: move TestSingleNodeRecovery under etcd/ 2014-09-03 09:20:00 -07:00
ffa5eb08c3 server: apply ents when loading log 2014-09-03 09:20:00 -07:00
a6132d459f server: save correct nodeId for participant 2014-09-03 09:20:00 -07:00
12dd380d26 etcd: use tmpDir as testing directory 2014-09-03 09:20:00 -07:00
653a63fa00 etcd: add destoryCluster for testing 2014-09-03 09:19:59 -07:00
88e5bce63d wip: wal glue 2014-09-03 09:19:59 -07:00
d70df4a15d wal: reorgnize wal file 2014-09-03 09:19:59 -07:00
a25cd45876 wal: add CoreOS copyright 2014-09-03 09:19:59 -07:00
b383cd5acf raft: refactor recover 2014-09-03 09:19:59 -07:00
9f5c7b310c wal: add newWal helper func 2014-09-03 09:19:59 -07:00
9c6f2ed5bb wal: use buffer 2014-09-03 09:19:59 -07:00
5baefcce26 wal: cleanup 2014-09-03 09:19:59 -07:00
363e952551 wal: add Read 2014-09-03 09:19:59 -07:00
3c7935a21d wal: check written data in tests 2014-09-03 09:19:59 -07:00
2bd74bc328 raft: add Load 2014-09-03 09:19:59 -07:00
d1cdc02afc wal: add tests for write 2014-09-03 09:19:59 -07:00
7b180d585e wal: make new work 2014-09-03 09:19:58 -07:00
e72e75876c wal: init 2014-09-03 09:19:58 -07:00
3fba10c8e6 etcd: add version handlers 2014-09-03 09:19:58 -07:00
e850c644da raft: return offset for unstableEnts 2014-09-03 09:19:58 -07:00
311db876b0 raft: add unstableState 2014-09-03 09:19:58 -07:00
609e13a240 raft: add node.Unstable
Be able to return all unstable log entries. Application must store unstable
log entries before send out any messages after calling step.
2014-09-03 09:19:58 -07:00
05e77ecf90 server: move id to the head of log line 2014-09-03 09:19:58 -07:00
e7bc7becf3 server: add first level logging 2014-09-03 09:19:58 -07:00
1288e1f39d raft: log->raftlog 2014-09-03 09:19:58 -07:00
c7d1beaaa5 raft: add first level logging
We log the message to step and the state of the statemachine before and after
stepping the message.
2014-09-03 09:19:58 -07:00
d7eef6a64e etcd: add a bootstrap test 2014-09-03 09:19:58 -07:00
b49cbc959b etcd: fix start test goroutine leak 2014-09-03 09:19:57 -07:00
b652a0d232 etcd: reorganize etce_start test 2014-09-03 09:19:57 -07:00
93104f114e all: discovery moved to etcd/ yet 2014-09-03 09:19:57 -07:00
6534525cf8 server: add bootstrap tests 2014-09-03 09:19:57 -07:00
c952e91c4f server: add discovery 2014-09-03 09:19:57 -07:00
2665cc1cc8 raft: heartbeat should not contain entries 2014-09-03 09:19:57 -07:00
7aa9838d8d server: move TestModeChange to functional tests 2014-09-03 09:19:57 -07:00
0c26c0bfab etcd: add a simple endtoend benchmark 2014-09-03 09:19:57 -07:00
1be8550672 etcd: refactor waitCluster 2014-09-03 09:19:57 -07:00
061fad12a9 main: do not pass id to etcd 2014-09-03 09:19:57 -07:00
30099d9135 etcd: generate a id for the new participant after a mode switch 2014-09-03 09:19:57 -07:00
8111930981 etcd: standby does not need to send join 2014-09-03 09:19:57 -07:00
155bd09902 etcd: add clusterid to participant 2014-09-03 09:19:56 -07:00
13ec81c87f raft: fix panic in putVarint; varint can take up to 10 bytes for a 64bit integer. 2014-09-03 09:19:56 -07:00
bb328d5aa5 etcd: fix standby test 2014-09-03 09:19:56 -07:00
468c345e74 etcd: standby should not be in a tight loop 2014-09-03 09:19:56 -07:00
060de128a7 raft: add clusterId 2014-09-03 09:19:56 -07:00
9793c518ab raft: forbid to use none as id 2014-09-03 09:19:56 -07:00
79689872af raft: use From field to distinguish local message 2014-09-03 09:19:56 -07:00
daa49023cf etcd: remove nodes in standby 2014-09-03 09:19:56 -07:00
b4cf146a52 server: notice 2013 -> 2014 2014-09-03 09:19:56 -07:00
0429fe04df server: add notice comment to all files 2014-09-03 09:19:56 -07:00
5bfaaa7964 etcd: fix serverHttp 2014-09-03 09:19:56 -07:00
0b77b42cad standby: fix leader var race 2014-09-03 09:19:55 -07:00
92778afd0b server: retry remove in TestBecomeStandby
To prevent from false error message.
2014-09-03 09:19:55 -07:00
2f51735e8a etcd: move raftprefix to raft_handler 2014-09-03 09:19:55 -07:00
7e7cfb1ce8 etcd: remove participant.seeds 2014-09-03 09:19:55 -07:00
9ffc0b9f2c etcd: remove unncessary code in participant 2014-09-03 09:19:55 -07:00
2e59635bea etcd: fix a race in peer.go 2014-09-03 09:19:55 -07:00
6dc49def25 server: move var noneId to standby.go 2014-09-03 09:19:55 -07:00
d120962959 server: remove func barrier
It could be replaced by func watch.
2014-09-03 09:19:55 -07:00
1c9928d721 participant: retry join more times 2014-09-03 09:19:55 -07:00
e709f1b572 server: fix possible race when switching mode 2014-09-03 09:19:55 -07:00
6059db1f4b participant: stop http serving when stopped 2014-09-03 09:19:55 -07:00
6d46fc39aa server: remove modeC var 2014-09-03 09:19:55 -07:00
5d498918bf etcd: abstract out mode change logic 2014-09-03 09:19:54 -07:00
4c324fe3a4 etcd: cleanup etcd.go 2014-09-03 09:19:54 -07:00
6d81aabd48 server: refactor server 2014-09-03 09:19:54 -07:00
447f6a16cc etcd: stop peerhub 2014-09-03 09:19:54 -07:00
d198173fd7 etcd: cleanup peerhub 2014-09-03 09:19:54 -07:00
92cc288f6e server: fix possible join back in TestRemove 2014-09-03 09:19:54 -07:00
e02baf33c9 etcd: unknowNode -> unknownPeer 2014-09-03 09:19:54 -07:00
e0e8495ace etcd: move fetch logic into peerhub 2014-09-03 09:19:54 -07:00
9756dba57a etcd: fix cluster sync 2014-09-03 09:19:53 -07:00
9746de91bf server: clean new func 2014-09-03 09:19:53 -07:00
46974ef473 server: add stop serving func to v2_client 2014-09-03 09:19:53 -07:00
7bf3e062bd server: fix standby waitgroup on doing requests 2014-09-03 09:19:53 -07:00
6f481af383 etcd: clean up sync 2014-09-03 09:19:53 -07:00
a922947bb0 etcd: move s.setClusterConfig to v2_admin.go 2014-09-03 09:19:53 -07:00
a50857d38a etcd: move s.ClusterConfig to v2_admin.go 2014-09-03 09:19:53 -07:00
da19964959 etcd: fix mode change race 2014-09-03 09:19:53 -07:00
8ea840c19a store: fix index data race 2014-09-03 09:19:53 -07:00
7adb765660 etcd: fix datarace in peer.go 2014-09-03 09:19:53 -07:00
b8b5734689 etcd: transporter->rafthandler 2014-09-03 09:19:53 -07:00
d2a553f6c4 etcd: refactor transporter 2014-09-03 09:19:53 -07:00
5f9a5e6a5d server: simplify mode transition 2014-09-03 09:19:52 -07:00
18001dd779 server/v2_client: add func CloseConnections 2014-09-03 09:19:52 -07:00
404dc96645 server: add TestBecomeStandby 2014-09-03 09:19:52 -07:00
a274e5b192 server: use status for transporter 2014-09-03 09:19:52 -07:00
429b9487f7 server: use transporter as raft HTTP handler 2014-09-03 09:19:52 -07:00
a2c5c844a0 server: add standby 2014-09-03 09:19:52 -07:00
54e39a30f7 server: refactor client
To be more readable and get rid of false error message.
2014-09-03 09:19:52 -07:00
f21842cd04 etcd: reportLead -> getLead 2014-09-03 09:19:52 -07:00
bea28933d3 raft: init lead to none 2014-09-03 09:19:52 -07:00
0ccd09532b etcd: add joinThroughFollower test 2014-09-03 09:19:52 -07:00
638f36956b etcd: fix transporter leak in test 2014-09-03 09:19:51 -07:00
16e9aa77e3 server: clear proposal wait in time 2014-09-03 09:19:51 -07:00
ee2d5d66af v2_client: read whole response body before close
Client have to read whole response bodies
if they want the advantage of reusing TCP connections.

https://code.google.com/p/go/source/detail?r=d4e1ec84876c0f5611ab86a03826da14b866efb2&name=release-branch.go1.1&path=/src/pkg/net/http/transport.go
2014-09-03 09:19:51 -07:00
984f309815 server: use buffer for proposal channel 2014-09-03 09:19:51 -07:00
02922fa7a5 etcd: clean testAdd 2014-09-03 09:19:51 -07:00
a0c0638744 tests: remove unnecessary test 2014-09-03 09:19:51 -07:00
60c8dbe0c9 etcd: rewrite kill_leader and kill_random test 2014-09-03 09:19:51 -07:00
83e1fe77c8 server: refactor add 2014-09-03 09:19:51 -07:00
3ea913e76a etcd: refactor remove 2014-09-03 09:19:51 -07:00
b951aaf925 store: check remove func before call it 2014-09-03 09:19:50 -07:00
2e86cf2dc8 raft: add more randomness 2014-09-03 09:19:50 -07:00
9c8aff66a1 raft: randomize election timeout 2014-09-03 09:19:50 -07:00
3921295b21 raft: update lead to none when receives vaild msgVote 2014-09-03 09:19:50 -07:00
605c4ce702 etcd: fix TestGetAdminMachinesEndPoint 2014-09-03 09:19:50 -07:00
a69e416604 etcd: group the prefix consts 2014-09-03 09:19:50 -07:00
7b11dc1c05 server: maintain cluster members in nodes var 2014-09-03 09:19:50 -07:00
5562c3b4ec server: v2 propose sends error back 2014-09-03 09:19:50 -07:00
5af8fe9a84 server: use /v2/admin/machines/ http endpoint to join 2014-09-03 09:19:50 -07:00
041524432d server: implement join and remove http endpoint 2014-09-03 09:19:50 -07:00
f34b77216f server: add add function 2014-09-03 09:19:50 -07:00
5fc5681cb4 server: make removal go through run loop
It should not send to raft endpoint directly.
2014-09-03 09:19:50 -07:00
98fdbaaae0 server: add remove function 2014-09-03 09:19:50 -07:00
f1853b4364 raft: add msgDenial to deny removed nodes 2014-09-03 09:19:49 -07:00
690edb2c56 raft: update lead for follower sm when receiving msgApp
Or follower may take `none` as its leader forever if it just launched
a failed election whose term is the same as the current leader.
2014-09-03 09:19:49 -07:00
edd8d7e534 etcd: add /v2/admin/machines/ endpoint 2014-09-03 09:19:49 -07:00
f95f53e446 etcd: add /v2/admin/config endpoint 2014-09-03 09:19:49 -07:00
447d7dc51b raft: fix log append; add tests 2014-09-03 09:19:49 -07:00
8ccb8b1f9f etcd: fake standby 2014-09-03 09:19:49 -07:00
44836d9099 etcd: move server/usage.go to etcd/v2_usage.go 2014-09-03 09:19:49 -07:00
b8d71dfe70 v2: remove old tests 2014-09-03 09:19:49 -07:00
02ced2c2d7 v1: deprecate v1 support
Etcd moves to 0.5 without the support of v1.
2014-09-03 09:19:49 -07:00
8d758be3e4 server: remove unused file 2014-09-03 09:05:15 -07:00
042a8e3d4f etcd: move util to test 2014-09-03 09:05:15 -07:00
00935c873f etcd: refactor tests 2014-09-03 09:05:14 -07:00
2ff3ce74c5 raft: add sm.Index 2014-09-03 09:05:14 -07:00
0886e0ddf4 raft: change term to atomicInt 2014-09-03 09:05:14 -07:00
30f4d9faea raft: change index and term to int64 2014-09-03 09:05:14 -07:00
e11c7f35b4 raft: add atomicInt 2014-09-03 09:05:14 -07:00
284e76f0da etcd: fix data race in transporter 2014-09-03 09:05:14 -07:00
3f435571d3 raft: atomic load id 2014-09-03 09:05:14 -07:00
18d95b336f main: generate 64bit id 2014-09-03 09:05:14 -07:00
c4e7432ef9 etcd: support cors 2014-09-03 09:05:14 -07:00
45c6bf80e1 etcd: support etcd server tls 2014-09-03 09:05:14 -07:00
4181f1b2e1 etcd: support raft tls 2014-09-03 09:05:14 -07:00
c3f8eabac3 etcd: separate raft and client port 2014-09-03 09:05:13 -07:00
10b2f88b83 etcd: support v2 store stats endpoint 2014-09-03 09:05:13 -07:00
9a59f16964 etcd: support v2 peers endpoint 2014-09-03 09:05:13 -07:00
f534d6c8f6 etcd: fix machines endpoint test 2014-09-03 09:05:13 -07:00
6fb2c7c883 etcd: support v2 leader endpoint 2014-09-03 09:05:13 -07:00
6234164f28 etcd: add a kv tests todo 2014-09-03 09:05:13 -07:00
ac44e56ea0 etcd: support v2/machines endpoint 2014-09-03 09:05:13 -07:00
5e486dd912 etcd: use v2 machines prefix 2014-09-03 09:05:13 -07:00
a88f077348 config: remove unused map 2014-09-03 09:05:13 -07:00
77233b26d0 etcd: support old flags 2014-09-03 09:05:13 -07:00
02c854717b config: make config a self-contained pkg 2014-09-03 09:05:13 -07:00
60b1f2f437 config: remove deprecated flags 2014-09-03 09:05:13 -07:00
fc35324ba7 etcd: pass v2 kv api tests 2014-09-03 09:05:13 -07:00
2af0ad505a raft: make id int64 2014-09-03 09:05:12 -07:00
5651272ec8 raft: handle snapshot message 2014-09-03 09:05:12 -07:00
2a11c1487c raft: sm.compact and sm.restore 2014-09-03 09:05:12 -07:00
62a90e77b3 raft: send Normal with nil Data when leader is elected out 2014-09-03 09:05:12 -07:00
064004b899 raft: add log compact 2014-09-03 09:05:12 -07:00
6a232dfc13 raft: add offset for log 2014-09-03 09:05:12 -07:00
7be945f59b etcd: glue 2014-09-03 09:05:12 -07:00
8eac28350d raft: avoid unexpected self-bootstrap state machine 2014-09-03 09:05:12 -07:00
c86f484712 raft: make judge clear 2014-09-03 09:05:12 -07:00
7dc02b947d raft: refine TestVote 2014-09-03 09:05:12 -07:00
095251f1fa raft: Network supports discontinuous ids 2014-09-03 09:05:12 -07:00
62bdcf6f49 raft: range over sm.ins 2014-09-03 09:05:12 -07:00
e9cb510ef5 raft: node.Add needs the pubAddr field 2014-09-03 09:05:12 -07:00
5778c49689 raft: set term in reset 2014-09-03 09:05:11 -07:00
67808f8db1 raft: remove vestigial canStep 2014-09-03 09:05:11 -07:00
6044b1a0d7 raft: break Step into pieces 2014-09-03 09:05:11 -07:00
f387e3e27d raft: add Entry.isConfig 2014-09-03 09:05:11 -07:00
3817661f82 raft: rename ConfigAdd/ConfigRemove -> AddNode/RemoveNode 2014-09-03 09:05:11 -07:00
9f315ffe10 raft: make entry type public 2014-09-03 09:05:11 -07:00
584186c7ff add HasLeader function 2014-09-03 09:05:11 -07:00
dd94d5d4e8 raft: move tick comments into cases 2014-09-03 09:05:11 -07:00
15a8b46359 raft: add/remove -> addNode/removeNode 2014-09-03 09:05:11 -07:00
e5b9e22518 raft: Step returns ok 2014-09-03 09:05:11 -07:00
a10461f60d raft: Add/Remove -> add/remove 2014-09-03 09:05:11 -07:00
8344303b1a raft: addr -> id 2014-09-03 09:05:11 -07:00
cb2095cddc raft: fix typo 2014-09-03 09:05:10 -07:00
cc3a8e26c8 raft: add leader change test for configuration 2014-09-03 09:05:10 -07:00
3a85d97fd9 raft: group Node fields 2014-09-03 09:05:10 -07:00
6e95448ad7 raft: correct comment for n.Next 2014-09-03 09:05:10 -07:00
7e27d588ff raft: return all the appliable entries 2014-09-03 09:05:10 -07:00
f8a3ac9338 raft: make Msgs one line 2014-09-03 09:05:10 -07:00
d12b2c39dd raft: blake is OCD 2014-09-03 09:05:10 -07:00
78bbb37018 raft: Config -> config 2014-09-03 09:05:10 -07:00
fb1ca245a7 raft: remove unused ClusterId 2014-09-03 09:05:10 -07:00
8c12d6d00f raft: refactor Node.Add/Remove 2014-09-03 09:05:10 -07:00
96059a496a raft: replace Node.id 2014-09-03 09:05:10 -07:00
abd2448931 raft: addr -> id 2014-09-03 09:05:10 -07:00
c24b6b4150 raft: init stateMachine in New 2014-09-03 09:05:10 -07:00
7cdd148e24 raft: StartCluster -> Dictate 2014-09-03 09:05:09 -07:00
1a75beb57c raft: add confAdd and confRemove entry type 2014-09-03 09:05:09 -07:00
b5f887f5d2 raft: add cluster test 2014-09-03 09:05:09 -07:00
5cad4e595c raft: add create cluster of itself 2014-09-03 09:05:09 -07:00
193756fa38 raft: add remove node 2014-09-03 09:05:09 -07:00
961518c893 raft: execute log entries in node.step 2014-09-03 09:05:09 -07:00
989f41477d raft: rename peer -> peers 2014-09-03 09:05:09 -07:00
8ce6b94e05 raft: add and remove 2014-09-03 09:05:09 -07:00
d293c4915c raft: fix pendingConf 2014-09-03 09:05:09 -07:00
c03fbf68d6 raft: add conf safety
To make configuration change safe without adding configuration protocol:

1. We only allow to add/remove one node at a time.

2. We only allow one uncommitted configuration entry in the log.

These two rules can make sure there is no disjoint quorums in both current cluster and the
future(after applied any number of committed entries or uncommitted entries in log) clusters.

We add a type field in Entry structure for two reasons:

1. Statemachine needs to know if there is a pending configuration change.

2. Configuration entry should be executed by raft package rather application who is using raft.
2014-09-03 09:05:09 -07:00
853a458a0d raft: change ins from array to map 2014-09-03 09:05:09 -07:00
f9c299da8b raft: return after handling msgBeat
It makes the workflow more clear.
2014-09-03 09:05:09 -07:00
c7e358922b raft: add elaspe reset test 2014-09-03 09:05:09 -07:00
5d710c0f7a raft: add recvMsgBeat test 2014-09-03 09:05:08 -07:00
12572e5412 raft: add state transition test 2014-09-03 09:05:08 -07:00
920b80c41f raft: add single node commit test 2014-09-03 09:05:08 -07:00
8111d4fbb8 raft: introduce network.cut 2014-09-03 09:05:08 -07:00
a6a63d116f raft: add a test for commit rule 2014-09-03 09:05:08 -07:00
28f87c2a43 raft: use sm.maybeCommit; should not call log.maybeCommit directly 2014-09-03 09:05:08 -07:00
4d22ff90d5 raft: refactor network simulator
Signed-off-by: Blake Mizerany <blake.mizerany@gmail.com>
2014-09-03 09:05:08 -07:00
a9c81088f8 raft: add new diff
Signed-off-by: Blake Mizerany <blake.mizerany@gmail.com>
2014-09-03 09:05:08 -07:00
c32d34166e raft: leader updates its own match; tries to commit after a prop 2014-09-03 09:05:08 -07:00
6fa74b0e33 raft: do bcast when receiving msgBeat 2014-09-03 09:05:08 -07:00
09d1575eeb raft: node.tick 2014-09-03 09:05:08 -07:00
eff3aadba1 raft: add full stop to every function comment 2014-09-03 09:05:08 -07:00
167ef7e8b0 raft: test leader replies to appResp 2014-09-03 09:05:08 -07:00
9bb7265d64 raft: leader only sends append to the unsynced peer when get a bad appResp 2014-09-03 09:05:07 -07:00
88674a623a raft: use if statement to handle voteResp 2014-09-03 09:05:07 -07:00
b3de2b3450 raft: testVote - breaks state machine init to multiple lines 2014-09-03 09:05:07 -07:00
59a720d8be raft: vote test for candidate and leader 2014-09-03 09:05:07 -07:00
828a8cf326 raft: leader denies vote with the same term 2014-09-03 09:05:07 -07:00
93b08502e4 raft: check voteFor 2014-09-03 09:05:07 -07:00
c1c45575be raft: ins: []*index -> []index
It could make raft faster, use less storage.
2014-09-03 09:05:07 -07:00
1170c21f89 raft: add a single candidate test 2014-09-03 09:05:07 -07:00
2066ff5acb raft: candidate should become leader directly if it is a one node cluster 2014-09-03 09:05:07 -07:00
0cdd1b58a4 raft: rename log.commit to log.committed 2014-09-03 09:05:07 -07:00
9cd3b2153f raft: comment log.nextEnts 2014-09-03 09:05:07 -07:00
a06729a96a raft: use log.lastIndex() 2014-09-03 09:05:07 -07:00
888ddacd3c raft: remove the init cap of log entries 2014-09-03 09:05:06 -07:00
2ef9498d6f raft: remove TLA comment 2014-09-03 09:05:06 -07:00
1f0e13e956 raft: remove sm.voteWorthy 2014-09-03 09:05:06 -07:00
bee9d8bea5 raft: add log.maybeAppend 2014-09-03 09:05:06 -07:00
b70be19653 raft: add log.maybeCommit 2014-09-03 09:05:06 -07:00
092461d7c8 raft: rename log.len to log.lastIndex 2014-09-03 09:05:06 -07:00
8f3d109c18 raft: rename log.isOk to log.matchTerm 2014-09-03 09:05:06 -07:00
4c609ec59c raft: new log struct 2014-09-03 09:05:06 -07:00
cb7b75c15f raft: remove unused function maybeAppend
Signed-off-by: Blake Mizerany <blake.mizerany@gmail.com>
2014-09-03 09:05:06 -07:00
74737b76cc raft: leader commit and test
Signed-off-by: Blake Mizerany <blake.mizerany@gmail.com>
2014-09-03 09:05:06 -07:00
c223eca938 raft: clean stateMachine 2014-09-03 09:05:06 -07:00
5b052e1e10 raft: prop msg type should be MsgProp 2014-09-03 09:05:06 -07:00
ab79550693 raft: use becomeFollower in cadidate state 2014-09-03 09:05:06 -07:00
73e3394d2d raft: reverse sort to figure out the ci 2014-09-03 09:05:05 -07:00
8ddcd9799d raft: go fmt 2014-09-03 09:05:05 -07:00
6e0a668455 raft: add Node.Next 2014-09-03 09:05:05 -07:00
9545662c6b raft: return *Node 2014-09-03 09:05:05 -07:00
50e0db4038 raft: attempt first version of Interface 2014-09-03 09:05:05 -07:00
8d7be33dd8 raft: move to raft pkg 2014-09-03 09:05:05 -07:00
f6f4329899 raft: test logs converge 2014-09-03 09:05:05 -07:00
935320289e raft: remove defunct empty var 2014-09-03 09:05:05 -07:00
8353340697 raft: remove defunct println 2014-09-03 09:05:05 -07:00
45500c5e7b raft: test candidate concede 2014-09-03 09:05:05 -07:00
8942415933 raft: test failed election 2014-09-03 09:05:05 -07:00
fcc7a42d6c raft: remove heal from network 2014-09-03 09:05:05 -07:00
13012ddd9a raft: test vote 2014-09-03 09:05:04 -07:00
706c6df2ce raft: add TODO 2014-09-03 09:05:04 -07:00
0ac49ba58d raft: fix logDiff false positives 2014-09-03 09:05:04 -07:00
b06c0cc3ec raft: ignore old messages 2014-09-03 09:05:04 -07:00
895d80d0e1 raft: test dualing proposers 2014-09-03 09:05:04 -07:00
0ca153e1e5 raft: make testing logs easier 2014-09-03 09:05:04 -07:00
9f8ede7b03 start new raft implementation 2014-09-03 09:05:04 -07:00
0a2384bf4d Merge pull request #969 from jurmous/patch-5
Add Etcd4j as a new Java client option
2014-08-29 09:15:16 -07:00
be0bb56525 Add Etcd4j as a new Java client option 2014-08-29 10:45:46 +02:00
6e70dfc33a Merge pull request #967 from jurmous/patch-3
Update clients-matrix.md
2014-08-28 14:38:58 -07:00
0e1f0a734b Swapped the clients with the features on the clients matrix so it is more comprehensible. The old version got too large to show on the screen. This new layout added a language column so you can quickly see the language of the client library.
Added alphabetical sorting to the clients list.

Also moved v1-only clients to the bottom since v2 is what most people are looking for today.
2014-08-28 23:20:23 +02:00
2b6e45d0ee Merge pull request #966 from justintime/patch-1
Add link to etcd-browser under Tools heading
2014-08-28 11:11:19 -07:00
07217b8d7c Add link to etcd-browser under Tools heading 2014-08-28 12:02:39 -05:00
6ea8da077e Merge pull request #1 from coreos/master
Pull coreos changes into this fork
2014-08-28 10:14:14 +02:00
ab4bcc1869 Merge pull request #962 from aterreno/master
Added etc-clojure to the list of clients supporting V.2 api
2014-08-27 17:31:06 -07:00
0e53287ea2 Added etc-clojure to the list of clients supporting V.2 api 2014-08-27 09:50:08 +01:00
3fc68f00f0 Merge pull request #956 from jurmous/patch-2
Remove an invalid comma from api.md example
2014-08-25 08:20:31 -07:00
4a04a89cb4 Merge pull request #955 from jurmous/patch-1
Adding missing comma to api.md
2014-08-25 08:18:21 -07:00
b3970c8db1 Merge pull request #942 from robszumski/master
docs: clarify tuning timeouts
2014-08-25 08:16:33 -07:00
36c57b7717 Merge pull request #939 from suzaku/ignore
Add .dockerignore to avoid including .git in docker build context
2014-08-25 08:15:03 -07:00
8f629aae4b Remove an invalid comma from api.md example 2014-08-25 11:09:15 +02:00
dead5e0eef Adding missing comma to api.md
Invalid json example
2014-08-25 10:55:56 +02:00
fa156aaf53 Merge pull request #954 from ddysher/master
Fix Typo in api.md.
2014-08-24 13:36:49 -07:00
e491c16afa Fix Typo in api.md. 2014-08-24 10:42:47 -04:00
95fe075a17 Merge pull request #950 from zxc122333/patch-1
doc:[readme.md] fix Planning/Roadmap 404
2014-08-22 15:58:40 -07:00
e698c378e7 doc:readme.md fix Planning/Roadmap 404 2014-08-21 16:08:03 +08:00
b083766608 Merge pull request #937 from andybons/patch-3
Update to Go 1.3.1
2014-08-20 12:55:33 -07:00
82db1e7919 Merge pull request #923 from unihorn/113
docs: set snapshot to be true in default configuration
2014-08-20 10:02:04 -07:00
7c7a70202b docs: clarify tuning timeouts 2014-08-18 16:15:59 -04:00
f734ba9974 Add .dockerignore to avoid including .git in docker build context
.git is currently the biggest directory
2014-08-15 16:38:29 +08:00
511ac3280f Merge pull request #927 from bmatsuo/topic/Documentation/fix-tuning-timeout-toml
Documentation: fix timeout tuning TOML example
2014-08-14 00:52:39 -07:00
a32cd31d3b Update to Go 1.3.1 2014-08-13 10:54:51 -07:00
186879cce0 Merge pull request #928 from grossws/patch-1
Typo fixes
2014-08-12 11:40:27 -07:00
dd9aa95f1f Merge pull request #918 from edwardcapriolo/patch-1
Update libraries-and-tools.md
2014-08-12 11:38:36 -07:00
616db55e08 Typo fix 2014-08-11 15:57:00 +04:00
b52d4cdbb2 Documentation: fix timeout tuning TOML example
this makes the TOML example for tuning the peer election timeout
consistent with the guide's advice and with the other examples.
2014-08-10 20:09:14 -07:00
d99567f698 Update clients-matrix.md 2014-08-10 16:48:59 -04:00
629c578cea docs: set snapshot to be true in default configuration
If snapshot is false, it will consume much memory and become rather
slow after several days. Make it on as default.
2014-08-09 09:35:29 -07:00
95d295da54 Documentation: remove "token" from discovery docs
It was a bit confusing how the term "token" was overriden in various ways in this doc. Clean it up by referring to it as a discovery URL.
2014-08-08 17:56:58 -07:00
97a1ca1ad3 Update libraries-and-tools.md
Added a new small c++ library
2014-08-06 10:50:28 -04:00
c9db87a302 server: bump to 0.4.6+git 2014-07-29 10:33:44 -07:00
49e0dff2b8 CHANGELOG: v0.4.6 2014-07-29 10:31:48 -07:00
686837227e fix(docs/api): mention version endpoint is per instance 2014-07-28 11:28:16 -07:00
f2652f005e Merge pull request #882 from cap10morgan/patch-1
add the /version endpoint to the API docs
2014-07-28 11:26:24 -07:00
5490eb5406 Merge pull request #907 from MattParker89/patch-1
Adds units of time to flag docs
2014-07-27 22:37:42 -07:00
70dda950ed Adds units of time to flag docs
This fixes issue #905 based on the comments provided in server/cluster_config.go
2014-07-27 00:39:02 -04:00
a884f2a18a Merge pull request #881 from unihorn/111
standby server: save Running info correctly
2014-07-24 17:29:25 -07:00
bdeb96be0f Merge pull request #900 from unihorn/fix-timer
server: fix timer leak
2014-07-21 16:37:04 -07:00
c00594e680 server: fix timer leak 2014-07-21 14:23:52 -07:00
919cd380ec Merge pull request #883 from philips/add-consistent-note
Documentation: add note about consistent=true
2014-07-14 14:39:38 -08:00
b83aec6b87 Merge pull request #889 from robszumski/uuid
fix(docs): name defaults to uuid not hostname
2014-07-14 14:13:55 -07:00
05bfb369ef Documentation: add note about consistent=true 2014-07-13 11:07:59 -08:00
0639c4c86d fix(docs): name defaults to uuid not hostname 2014-07-11 11:30:05 -07:00
877b3d51bb Merge pull request #886 from christriddle/master
Added Access-Control-Allow-Headers for CORS requests
2014-07-10 13:05:07 -07:00
d9df58beb8 Added Access-Control-Allow-Headers to allow cors requests with those headers 2014-07-10 17:02:41 +01:00
1cffdb3a48 Merge pull request #866 from coreos/qread
feat(get): get from quorum
2014-07-08 18:30:18 -07:00
0593a52107 add the /version endpoint to the API docs
I had to find this by accident. It should be documented here.
2014-07-08 17:26:47 -04:00
f7854c4ab9 standby server: save Running info correctly
Running should be true when Start, and set to false when switching to
the other mode.
2014-07-08 08:29:17 -07:00
13b0e72304 CHANGELOG: v0.4.5 2014-07-07 18:11:29 -07:00
43791a2f41 Merge pull request #877 from Rawn/flush-headers-on-wait-stream
server: Flush headers when using wait=true and stream=true
2014-07-07 17:04:02 -07:00
a8d966d8f3 Merge pull request #880 from philips/add-http-server-timeouts
etcd: add a read/write timeout to server
2014-07-07 16:02:27 -07:00
ad7194d5d0 Documentation: remove etcd-py since it was removed
URL is no longer working
2014-07-07 14:26:56 -07:00
084dcb5596 etcd: add a read/write timeout to server
The default is for connections to last forever[1]. This leads to fds
leaking. I set the timeout so high by default so that watches don't have
to keep retrying but perhaps we should set it slower.

Tested on a cluster with lots of clients and it seems to have relieved
the problem.

[1] https://groups.google.com/forum/#!msg/golang-nuts/JFhGwh1q9xU/heh4J8pul3QJ
2014-07-07 11:42:56 -07:00
8a0266a806 Merge pull request #867 from iand/json-headers
fix(server/server.go): /v2/stats endpoints emit application/json content type header
2014-07-07 10:33:27 -07:00
2338481bb1 server: Flush headers when using wait=true and stream=true
Many http clients will missbehave unless they get an initial http-
response, even when long-polling. It also saves the user/client from
having to handle headers on the first action of the watch, but rather
handle the response immediately.
2014-07-03 18:04:36 +02:00
ce1e19ae2f Merge pull request #849 from colegleason/max-cluster-size
docs(cluster-size): remove outdated references to flag max-cluster-size
2014-07-02 12:21:14 -07:00
a288333e6f fix(server/server.go): /v2/stats endpoints emit application/json content type header 2014-06-30 10:50:43 +01:00
097aac79f5 flags: remove MaxClusterSize variable 2014-06-27 10:52:16 -07:00
cd820269a6 Merge branch 'master' of github.com:coreos/etcd 2014-06-25 08:57:54 -07:00
ac7e6bb002 Merge https://github.com/coreos/template-project
Conflicts:
	CONTRIBUTING.md
	LICENSE
2014-06-25 08:57:02 -07:00
4b45cd4110 Merge pull request #869 from sivaramsk/patch-2
Update optimal-cluster-size.md
2014-06-25 08:17:07 -07:00
fb426aec9e Update optimal-cluster-size.md 2014-06-25 14:20:59 +05:30
774cb03f83 server: bump to 0.4.4+git 2014-06-24 10:58:11 -07:00
4fb6087f4a CHANGELOG: release 0.4.4 2014-06-24 10:56:53 -07:00
5524131a9e Merge pull request #865 from robstrong/hotfix/contentType
fix(peer_server) set content type to application/json in admin
2014-06-23 16:31:49 -07:00
3efb4d837b Merge pull request #844 from unihorn/102
chore(peer_server): improve log for auto removal
2014-06-23 14:19:48 -07:00
20147c5357 flags: alias max-cluster-size to cluster-active-size as deprecated flag 2014-06-23 10:50:40 -07:00
973bde9a07 feat(get): get from quorum 2014-06-22 21:33:38 -07:00
494d2c67aa fix(peer_server) set content type to application/json in admin 2014-06-21 13:13:10 -04:00
fb32a999a6 doc: add note about removal of leader mod 2014-06-19 17:10:34 -07:00
d2f5934aa1 mod: remove defunct leader test 2014-06-19 17:10:34 -07:00
4f3fb5a702 Merge pull request #861 from andybons/patch-2
Update to Go v1.3
2014-06-19 13:54:34 -07:00
9f5ec7732e Update to Go v1.3
Now I’m just being OCD about it.
2014-06-19 10:25:52 -04:00
774cf34827 CONTRIBUTING: add a section about not emailing maintainers
Setup some expectation for etiquette.
2014-06-18 18:38:28 -07:00
92df44276d CONTRIBUTING: remove the subject verbs
After talking to a few people on the team we have decided that the
feat/fix/etc tags aren't adding much value. Use a simpler format
instead.
2014-06-18 18:36:00 -07:00
eb00f200d3 Merge pull request #856 from robn/patch-1
Add p5-etcd (Perl client lib) to clients-matrix
2014-06-18 10:45:11 -07:00
38d16775ab Merge pull request #858 from mikeumus/patch-1
docs(readme.md): spelling fix "oon" to "on"
2014-06-17 23:20:23 -07:00
690fd12b07 docs(readme.md): spelling fix "oon" to "on" 2014-06-18 02:11:32 -04:00
b31483b2be Merge pull request #850 from robszumski/update-config
feat(docs): add cluster config section
2014-06-17 17:45:50 -07:00
e9a21dda4b Merge pull request #851 from unihorn/103
docs(configuration): add cluster configuration
2014-06-17 17:44:51 -07:00
2134036942 Merge pull request #857 from tarnfeld/tools-discodns
Added discodns to the list of tools using etcd
2014-06-17 16:10:57 -07:00
6bd2ee4c49 Added discodns to the list of tools using etcd 2014-06-18 00:08:21 +01:00
fcd429467e Add p5-etcd (Perl client lib) to clients-matrix 2014-06-18 08:15:03 +10:00
e5e759b962 docs(config): refine cluster configuration 2014-06-17 09:31:08 -07:00
d8a08f53e3 feat(docs): add cluster config section 2014-06-16 22:31:13 -07:00
3e95bf0fa3 Merge pull request #854 from brianredbeard/moarthings
docs(libraries-and-tools.md) Add vulcan proxy and kubernetes
2014-06-16 20:05:43 -07:00
0d2512cb99 docs(libraries-and-tools.md) Add vulcan proxy and kubernetes
Both vulcan proxy (vulcand) and Google kubernetes utilize etcd as
as storage engine.
2014-06-16 20:03:47 -07:00
a29f6fb799 docs(configuration): add cluster configuration 2014-06-16 13:58:00 -07:00
f4f429d4e3 docs(cluster-size): remove outdated refrences to flag max-cluster-size 2014-06-16 09:41:37 -07:00
fc2afe1ed2 Merge pull request #847 from pwaller/patch-1
docs(production-ready.md): Tiny typo fix
2014-06-13 08:58:33 -07:00
24a442383b docs(production-ready.md): Tiny typo fix 2014-06-13 14:41:23 +01:00
f387bf8464 chore(peer_server): improve log for auto removal 2014-06-12 10:02:56 -07:00
83b06c0715 Merge pull request #841 from andybons/patch-1
Update to Go v1.2.2
2014-06-11 09:43:25 -07:00
75dc10c39d Update to Go v1.2.2 2014-06-09 16:03:01 -04:00
66acf8a4e9 Merge pull request #839 from jonboulle/jonboulle-master
docs(cluster-discovery): fix bad link and confusing port references
2014-06-09 09:47:58 -07:00
1359d29fa4 docs(cluster-discovery): fix bad link and confusing port references 2014-06-08 23:58:14 -07:00
dc1f4adcd0 chore(server): bump to 0.4.3+git 2014-06-07 18:17:54 -07:00
9970141f76 chore(server): bump to 0.4.3 2014-06-07 18:17:05 -07:00
16c2bcf951 chore(server): go fmt
blame me for not running test first.
2014-06-07 18:03:22 -07:00
868b7f7902 Merge pull request #836 from philips/reduce-heartbeat-logs
fix(server): reduce the screaming heartbeat logs
2014-06-07 17:48:22 -07:00
1c958f8fc3 fix(server): reduce the screaming heartbeat logs
Currently the only way we know that a peer isn't getting a heartbeat is
an edge triggered event from go raft on every missed heartbeat. This
means that we need to do some book keeping in order to do exponential
backoff.

The upside is that instead of screaming thousands of log lines before a
machine hits the default removal of 30 minutes it is only ~100.
2014-06-07 17:47:10 -07:00
dfeecd2537 Merge pull request #835 from unihorn/101
chore(server): set DefaultRemoveDelay to 30mins
2014-06-06 17:56:01 -07:00
ed58193ebe chore(server): set DefaultRemoveDelay to 30mins
Its value was 5s before, which could remove the node insanely fast.
2014-06-06 16:57:35 -07:00
79c650d900 Merge pull request #834 from unihorn/100
fix(raft/protobuf): avoid panic on unexcepted data
2014-06-06 15:08:13 -07:00
a451cf2333 fix(raft/protobuf): avoid panic on unexcepted data 2014-06-06 14:34:32 -07:00
3455431da3 Merge pull request #833 from unihorn/99
bump(code.google.com/p/gogoprotobuf): 7fd1620f09
2014-06-06 13:48:47 -07:00
9424a10f49 bump(code.google.com/p/gogoprotobuf): 7fd1620f09 2014-06-06 13:35:59 -07:00
fbcfe8e1c4 Merge pull request #807 from Shopify/raft-server-stats-struct-field-tag-fix
style(server): changed a LeaderInfo struct field from "startTime" to "StartTime"
2014-06-05 12:45:34 -07:00
757bb3af13 Merge pull request #830 from unihorn/98
fix(raft/log): truncate file and reset offset correctly
2014-06-05 12:40:23 -07:00
2cd367e9d9 fix(raft/log): truncate file and reset offset correctly 2014-06-05 12:09:25 -07:00
a974bbfe4f chore(server): bump to 0.4.2+git 2014-06-02 15:26:06 -07:00
99dcc8c322 chore(server): bump back to 0.4.2 2014-06-02 15:25:03 -07:00
3d2523e7e0 Merge pull request #825 from unihorn/98
fix(multi_node_kill_all_and_recovery_test): ensure cluster is up
2014-06-02 15:12:05 -07:00
25e69d9659 fix(multi_node_kill_all_and_recovery_test): ensure cluster is up 2014-06-02 14:43:51 -07:00
707174b56a chore(server): bump to 0.4.2+git 2014-06-02 14:19:52 -07:00
ce92cc3dc5 feat(CHANGELOG): bump to v0.4.2 2014-06-02 14:17:38 -07:00
5bfbf3a48c Merge pull request #824 from unihorn/97
fix(remove_node_test): remove unnecessary cluster configuration
2014-06-02 14:12:08 -07:00
e04a188358 fix(remove_node_test): remove unnecessary cluster configuration
The cluster configuration operation is originally to make sure
the instance won't be added back automatically between removal and
check for the number of existing peer-mode instances. But this
could make some node removed before the removal command.

Use longer sync interval instead to avoid this problem.
2014-06-02 13:30:19 -07:00
a51fda3e5e Merge pull request #822 from philips/add-notes-about-discovery
docs(cluster-discovery): add caution to use old discovery endpoint
2014-06-02 12:06:00 -07:00
ca44801650 docs(cluster-discovery): add caution to use old discovery endpoint 2014-06-02 11:34:56 -07:00
2387ef3f21 Merge pull request #819 from unihorn/97
fix(server): joinIndex is not set after recovery from full outage
2014-06-02 11:04:07 -07:00
d5bfca9465 Merge pull request #814 from unihorn/91
fix(server/v2): set correct content-type for etcdError response
2014-06-02 10:38:36 -07:00
7cb126967c fix(simple_snapshot_test): enlarge reasonable index range 2014-05-31 10:42:31 -07:00
444e017c05 fix(remove_node_test): ensure cluster config is activated 2014-05-31 10:32:03 -07:00
356675b70f fix(multi_node_kill_all_and_recovery_test): ensure cluster running 2014-05-31 10:15:03 -07:00
d7768635fd fix(server): set joinIndex when recovered 2014-05-31 10:03:39 -07:00
37796ed84c tests: add TestMultiNodeKillAllAndRecorveryAndRemoveLeader
This one breaks because it doesn't set joinIndex correctly.
2014-05-31 10:01:45 -07:00
f007cf321d Merge pull request #818 from unihorn/96
fix(standby_server): able to join the cluster containing itself
2014-05-30 18:36:58 -07:00
ca29691543 tests(standby_test): comments 2014-05-30 18:36:23 -07:00
4bebb538eb fix(standby_server): able to join the cluster containing itself
Standby server will switch to peer server if it finds that
it has been contained in the cluster.
2014-05-30 14:03:49 -07:00
c27db1ec5e Merge pull request #816 from unihorn/95
docs(clustering): limit for peer-address changing
2014-05-30 13:45:12 -07:00
a5fc1d214d Merge pull request #817 from cholcombe973/master
Adding autodock into the libraries and tools section
2014-05-30 13:41:32 -07:00
1df0b941d7 Adding autodock into the libraries and tools section 2014-05-30 13:20:28 -07:00
3a71eb9d72 Merge pull request #808 from robszumski/update-optimal-size
fix(docs): add information about standbys
2014-05-30 12:26:07 -07:00
001cceb1cd fix(docs): update doc with standby info 2014-05-30 12:23:22 -07:00
98ff4af7f2 docs(clustering): limit for peer-address changing 2014-05-30 08:50:16 -07:00
db4c5e0eaa fix(server/v2): set correct content-type for etcdError response
"net/http".Error reset the content type, so we get rid of it and
write our own one.
2014-05-29 14:18:50 -07:00
b3c5ed60bd chore(pkg/btrfs): remove accidental swp file. 2014-05-22 09:50:40 -07:00
673d90728e style(server): changed a LeaderInfo struct field from "startTime" to "StartTime"
Changed the LeaderInfo struct "start time" field from "startTime" to "StartTime" so that it is an exported identifier. This required adding the `json:"startTime"` structure field tag so that the encoding/json package correctly performs JSON encoding (i.e. the correct property name --> startTime).
2014-05-21 11:19:56 -04:00
22c944d8ef chore(server): bump 0.4.0+git 2014-05-20 20:55:57 -07:00
a2d16b52bb chore(server): bump to 0.4.1 2014-05-20 20:46:46 -07:00
b637b3a607 Merge pull request #806 from philips/add-machine-api-docs
fix(server): add user facing remove API
2014-05-20 20:41:21 -07:00
0eba3c9000 feat(Documentation): document the entire admin machines API
Flesh out this document a bit more completely.
2014-05-20 20:25:34 -07:00
c3aab42959 fix(Documentation): update based on standby refactor
These docs were not updated after the refactoring of the standy mode.
Fix that now.
2014-05-20 20:07:47 -07:00
62560f9959 fix(server): add user facing remove API
This was accidently removed as we refactored the standy stuff. Re-add this
user facing remove endpoint that matches the config endpoints.
2014-05-20 20:01:10 -07:00
3c04f8b664 fix(scripts/build-release): put everything into a release dir 2014-05-20 17:53:17 -07:00
cc37c58103 chore(server): bump to 0.4.0+git 2014-05-20 17:10:28 -07:00
07d1eb0edb chore(server): bump to 0.4.0 2014-05-20 17:09:22 -07:00
9a006d673b doc(README): add note about 32bit systems - fixes 358 2014-05-20 16:23:33 -07:00
6860bfdd28 Merge pull request #805 from xiangli-cmu/fix_test
fix(test/remove_node_test.go) fix a deadlock in the test
2014-05-20 14:37:53 -07:00
aaedf32c04 fix(test/remove_node_test.go) fix a deadlock in the test
The go-etcd client waits for the response from the paused node. And the test waits for the reponse to continue.
Actually we do not even need that small test, since we will check the machine status afterwards.
2014-05-20 14:34:59 -07:00
16d89c906b Merge pull request #804 from xiangli-cmu/fix_curr_index_race
fix(store): synchronize access to CurrentIndex
2014-05-20 14:32:45 -07:00
516ebdb49e fix(store): synchronize access to CurrentIndex 2014-05-20 13:53:47 -07:00
1e7a7b11dd Merge pull request #799 from xiangli-cmu/deny_unknow_peer
hack(server): notify removed peers when they try to become candidates
2014-05-20 13:37:14 -07:00
4c953a7ca2 Merge pull request #803 from unihorn/94
fix(peer_server): set store and registry when setting raft server
2014-05-20 13:36:16 -07:00
934c28d498 fix(peer_server): set store and registry when setting raft server
New raft server needs new store and registry.
2014-05-20 13:12:12 -07:00
0c8b13c04f Merge pull request #19 from unihorn/92
tests(remove_node): add TestRemovePausedNode
2014-05-20 11:06:00 -07:00
9e5b12f591 tests(remove_node): add TestRemovePausedNode 2014-05-20 11:01:14 -07:00
189fece683 hack(server): notify removed peers when they try to become candidates
A peer might be removed during a network partiton. When it comes back it
will not have received any of the log entries that would have notified
it of its removal and go onto propose a vote. This will disrupt the
cluster and the cluster should give the machine feedback that it is no
longer a member.

The term of a denied vote is MaxUint64. The notification of the removal
is a raft event. These two modification are quick heck.

In reaction to this notification the machine should shutdown. In this
case the shutdown just moves it towards becoming a standby server.
2014-05-20 10:17:32 -07:00
ad27aa0f70 Merge pull request #791 from yifan-gu/ipv6_zone_fix
Ipv6 zone fix
2014-05-20 09:37:28 -07:00
dffe460210 Merge pull request #793 from binocarlos/patch-1
Added the -peer-heartbeat-interval option
2014-05-20 09:30:11 -07:00
b4e4bf4b75 fix(config.go)
return a valid URL struct from sanitizeURL()
pass the URL struct above to sanitizeBindAddr()

Since url.Parse() will return an error when parsing an already-parsed
ipv6 url string, (e.g. [http://[fe80::6203:8ff:fe9e:ace%25eth0]:7001),
so I just return the valid URL struct from sanitizeURL() and send it to
sanitizeBindAddr(), then there is no need to parse it again in sanitizeBindAddr().

Besides, for IPV6 url, the percent sign should be escaped, see:
http://en.wikipedia.org/wiki/IPv6_address#Link-local_addresses_and_zone_indices
2014-05-18 12:42:47 -07:00
e9482167a8 Added the -peer-heartbeat-interval option 2014-05-18 19:22:48 +01:00
cbcf55dabb Merge pull request #744 from unihorn/71
docs(api): add Cluster Config API
2014-05-18 10:09:07 -07:00
1084e51320 Merge pull request #786 from unihorn/91
feat(standby_server): write cluster info to disk
2014-05-18 10:08:52 -07:00
ad9155c82a Merge pull request #789 from bass3m/master
Add Julia etcd client
2014-05-17 16:15:35 -07:00
84f71b6c87 chore(standby_server): remove error return
because standby server should be started in best efforts.
2014-05-16 18:07:49 -04:00
d2d68f96fc Add Julia etcd client 2014-05-16 10:11:31 -07:00
71679bcf56 feat(standby_server): make atomic move for file
to avoid the risk of writing out a corrupted file.
2014-05-16 01:00:07 -04:00
a824be4c14 feat(standby_server): save/load Running into disk 2014-05-16 00:10:15 -04:00
35cc81e22f feat(standby_server): save/load syncInterval to disk 2014-05-15 23:57:58 -04:00
716496ec42 chore(standby_server): still sleep for the first time 2014-05-15 23:18:59 -04:00
e5ce4fca2e docs(standbys): clarify pseudocode 2014-05-15 22:47:12 -04:00
9940347eea Merge pull request #788 from alex-sherwin/patch-1
fix(doc): fixed typo for etcd lock examples
2014-05-15 18:30:15 -07:00
d2a2cc13b0 fixed typo for etcd lock examples 2014-05-15 21:27:50 -04:00
b7d9fdbd39 feat(standby_server): write cluster info to disk
For better fault tolerance and availability.
2014-05-15 07:47:15 -04:00
7cf8a4a8d0 Merge pull request #779 from unihorn/89
feat: implement standby mode
2014-05-14 10:03:03 -07:00
851026362a chore(standby_server): let syncInterval represent in second unit
This is done to keep consistency with other namings.
2014-05-14 10:13:05 -04:00
fc77b3e9e6 fix(simple_snapshot_test): enlarge reasonable index range 2014-05-13 22:28:28 -04:00
f6591b95c7 chore(standby): minor changes based on comments 2014-05-13 22:19:52 -04:00
403f709ebd chore(cluster_config): set default timeout to 5s
Or the leader death could let the standbys down for a rather long time.
2014-05-13 16:13:44 -04:00
cbb706cd47 bump(goraft/raft): c76c5d95 2014-05-13 11:08:03 -04:00
c0027bfc78 feat(cluster_config): change field from int to float64
This is modified for better flexibility, especially for testing.
2014-05-12 22:42:18 -04:00
735ffb3092 Merge pull request #782 from unihorn/90
fix(TestV1Watch): ensure server has started
2014-05-09 15:51:48 -07:00
6a64141962 fix(TestV1Watch): ensure server has started 2014-05-09 15:42:18 -07:00
5367c1c998 chore(standby): minor changes based on comments 2014-05-09 15:38:03 -07:00
c6b1a738c3 feat(option): add cluster config option
It will be used when creating a brand-new cluster.
2014-05-09 15:22:11 -07:00
6d4f018887 chore(cluster_config): rename SyncClusterInterval to SyncInterval
for better naming
2014-05-09 13:28:21 -07:00
765cd5d8b3 refactor(find_cluster): make it simpler 2014-05-09 02:27:04 -07:00
baadf63912 feat: implement standby mode
Change log:
1. PeerServer
- estimate initial mode from its log through removedInLog variable
- refactor FindCluster to return the estimation
- refactor Start to call FindCluster explicitly
- move raftServer start and cluster init from FindCluster to Start
- remove stopNotify from PeerServer because it is not used anymore
2. Etcd
- refactor Run logic to fit the specification
3. ClusterConfig
- rename promoteDelay to removeDelay for better naming
- add SyncClusterInterval field to ClusterConfig
- commit command to set default cluster config when cluster is created
- store cluster config info into key space for consistency
- reload cluster config when reboot
4. add StandbyServer
5. Error
- remove unused EcodePromoteError
2014-05-09 01:56:55 -07:00
5bd08a327d docs(standbys): specification for standby module 2014-05-08 15:02:55 -07:00
f1c13e2d9d Merge pull request #774 from unihorn/83
feat(join): check cluster conditions before join
2014-05-08 14:08:38 -07:00
6c950eaf97 Merge pull request #772 from unihorn/81
feat(peer_server): stop service when removed
2014-05-08 14:02:09 -07:00
5c7a963cf0 chore(peer_server): adjust code to make it more clear 2014-05-08 13:20:46 -07:00
c92231c91a Merge branch 'master' of github.com:coreos/etcd
Conflicts:
	server/peer_server_handlers.go
2014-05-08 13:17:51 -07:00
e960a0e03c chore(client): minor changes based on comments
The changes are made on error handling, comments and constant.
2014-05-08 13:15:10 -07:00
015d228b04 Merge pull request #763 from unihorn/77
fix(raft_server_stats): set startTime when init
2014-05-08 12:28:44 -07:00
e31249fa22 Merge pull request #778 from unihorn/88
fix(TestV2Watch): ensure server has started
2014-05-08 12:26:56 -07:00
b3e66ee980 fix(TestV2Watch): ensure server has started 2014-05-08 12:18:08 -07:00
af33d61774 Merge pull request #775 from unihorn/84
refactor(tests/server_utils): use etcd instance
2014-05-08 11:53:46 -07:00
bc4a98c386 Merge pull request #776 from unihorn/85
feat(peer_server): add State field to machineMessage
2014-05-08 11:53:26 -07:00
fb17ccf5ee chore(cors): more explanation for flush in ServeHTTP 2014-05-08 10:54:50 -07:00
04f09d2fd0 feat(peer_server): add State field to machineMessage
State field indicates the state of each machine.
For now, its value could be follower or leader.
2014-05-08 10:25:39 -07:00
6450d6dfb9 Merge pull request #777 from unihorn/86
fix(registry): fetch peers from store instead of cache
2014-05-08 09:11:04 -07:00
0558b546ff fix(registry): fetch peers from store instead of cache
The current cache implmentation may contain removed machines, so we
fetch peers from store for correctness.
2014-05-08 08:44:32 -07:00
5465201292 chore(peer_server): more explanation for asyncRemove 2014-05-07 16:31:17 -07:00
ae81f843f1 refactor(client): remove useless logic in redirection 2014-05-07 16:09:08 -07:00
c9ce14c857 chore(peer_server): set client transporter separately
It also moves the hack on timeout from raft transporter to
client transporter.
2014-05-07 13:26:05 -07:00
bed20b7837 chore(peer_server): add more function description 2014-05-07 12:51:41 -07:00
206881bfec fix(peer_server): check running status before start/stop
This makes peer server more robust.
2014-05-07 12:44:48 -07:00
cf25650b3c fix(etcd): exit 0 when removed 2014-05-07 12:39:07 -07:00
7dce4c8fbb refactor(tests/server_utils): use etcd instance
Remove duplicated etcd start code.
2014-05-07 11:49:03 -07:00
b0ffb4fd10 chore(config): move Sanitize and Force check to boot process
Make Load function just load parameters. So etcd instance could
use Config struct to start service.
2014-05-07 11:48:53 -07:00
001b1fcd46 feat(join): check cluster conditions before join 2014-05-07 11:46:21 -07:00
4e14604e5c refactor(server): add Client struct
This is used to send request to web API.
It will do this behavior a lot in standby mode, so I abstract this
struct first.
2014-05-07 11:46:15 -07:00
b56aa62bcc Merge pull request #773 from unihorn/82
tests(snapshot): expand reasonable range for index
2014-05-07 13:02:41 -04:00
ba36a16bc5 feat(peer_server): stop service when removed
It doesn't modify the exit logic, but makes external code know
when removal happens and be able to determine what it should do.
2014-05-07 10:00:27 -07:00
997e7d3bf4 Merge pull request #771 from unihorn/80
refactor(peer_server): remove standby mode in peer server
2014-05-07 09:57:02 -07:00
c4cd86e094 tests(snapshot): expand reasonable range for index
snapshot file was createed with name '0_503.ss' and '0_1010.ss' when testing.
2014-05-07 09:41:36 -07:00
17e299995c refactor(peer_server): remove standby mode in peer server 2014-05-07 09:10:09 -07:00
e11fd7cd40 Merge pull request #770 from shawnps/patch-1
Fix comment typo
2014-05-07 11:09:34 -04:00
d78116c35b Merge pull request #675 from unihorn/56
fix(peer_server): exit all server goroutines in Stop()
2014-05-07 08:09:14 -07:00
6516cf854c chore(server): rename daemon to startRoutine
For better understanding.
2014-05-07 07:51:44 -07:00
e55512f60b fix(peer_server): graceful stop for peer server run
Peer server will be started and stopped repeatedly in the design.
This step ensures its stop doesn't affect the next start.
The patch includes goroutine stop and timer trigger remove.
2014-05-07 07:43:27 -07:00
43ad623965 Merge pull request #740 from unihorn/67
docs(upgrade): instructions for upgrade to v0.4
2014-05-07 07:01:20 -07:00
2d5c7d7fb0 docs(upgrade): instructions for upgrade to v0.4 2014-05-07 07:00:35 -07:00
38b88589da Merge pull request #748 from unihorn/73
docs(discovery): update discovery process based on the change
2014-05-07 06:55:59 -07:00
c6be7887e5 docs(discovery): update cluster finding process 2014-05-07 06:55:09 -07:00
da3bbc5206 Fix typo 2014-05-07 21:50:48 +09:00
8b5d9cc1fb docs(api): make Cluster Config API part clearer 2014-05-05 18:49:21 -07:00
c692a8f0a7 fix(raft_server_stats): set startTime when init
This helps one-node cluster get rid of bogus startTime.
2014-04-29 09:59:02 -07:00
a563d82f95 Merge pull request #752 from unihorn/75
fix(server): dispatch SetClusterConfigCommand correctly
2014-04-22 14:55:17 -07:00
c7116a37c0 fix(server): dispatch SetClusterConfigCommand correctly 2014-04-22 14:02:54 -07:00
9af9438ed0 Merge pull request #751 from unihorn/75
Revert "Merge pull request #631 from metaflow/fix-delete-key-as-director...
2014-04-21 17:59:07 -07:00
fa54866e99 Revert "Merge pull request #631 from metaflow/fix-delete-key-as-directory"
This reverts commit b87972713e, reversing
changes made to bd8d45ce28.
2014-04-21 17:55:44 -07:00
ff172ae3a5 Merge pull request #749 from unihorn/74
chore: gofmt go files
2014-04-21 15:03:05 -07:00
32d23fdb11 chore: gofmt go files 2014-04-21 14:59:06 -07:00
14ae764283 Merge pull request #712 from sym3tri/dashboard-rewrite
Dashboard rewrite
2014-04-21 12:11:09 -07:00
b87972713e Merge pull request #631 from metaflow/fix-delete-key-as-directory
Fix delete key as directory
2014-04-21 11:45:18 -07:00
bd8d45ce28 Merge pull request #746 from andybons/patch-1
Update to Go v1.2.1
2014-04-21 11:37:29 -07:00
7cebc3999a api(delete) now you get an error trying to delete files a directory (http.StatusForbidden) 2014-04-21 19:50:57 +07:00
1b78cc1389 Update to Go v1.2.1 2014-04-19 13:09:33 -04:00
204f2d38af docs(api): add Cluster Config API 2014-04-18 18:24:19 -07:00
215ff2839d Merge pull request #743 from unihorn/70
fix(btrfs): build btrfs based on platform
2014-04-18 14:34:58 -07:00
ece25833aa Merge pull request #738 from unihorn/68
feat(peer_server): forbid rejoining with different name
2014-04-18 11:49:36 -07:00
21693b70f7 Merge pull request #737 from ghodss/fix-dir-ttl-response
fix(store.go) include node.dir = true when updating a directory's ttl
2014-04-18 11:47:29 -07:00
7bf1936df3 fix(btrfs): build btrfs based on platform 2014-04-18 11:20:38 -07:00
000e3ba651 chore(rejoin_test): rewrite some printout 2014-04-18 10:48:14 -07:00
9f228550a2 Merge pull request #730 from unihorn/65
chore(server): deprecate mod temporarily
2014-04-18 10:46:09 -07:00
a2749bad53 docs(modules): make reasons for deprecation much more clear 2014-04-18 10:36:59 -07:00
e0fbe27c99 fix(join_command): use RaftURL as peer address 2014-04-18 10:28:24 -07:00
5602d4a2ee docs(modules): make reasons for deprecation more clear 2014-04-18 09:31:57 -07:00
b742af56ec Merge pull request #723 from unihorn/63
tests: add TestJoinThroughFollower
2014-04-17 19:44:46 -07:00
b17703a9e4 chore(tests/join): adjust output 2014-04-17 19:28:58 -07:00
0c95e1eabb feat(peer_server): forbid rejoining with different name
Or it will confuse the cluster, especially the heartbeat between nodes.
2014-04-17 15:46:33 -07:00
b0ac8a4b4b Merge pull request #624 from unihorn/36
chore(server/transporter): set RequestTimout reasonable
2014-04-17 15:19:10 -07:00
3ae0a1e1a6 fix(store.go) include node.dir = true when updating a directory's ttl, fixes coreos/etcd#736 2014-04-17 15:15:41 -07:00
cc329bfa55 Merge pull request #643 from unihorn/45
fix(server): rejoin cluster with different ip
2014-04-17 10:24:04 -07:00
732fb7c160 tests(rejoin): add TestReplaceWithDifferentPeerAddress
The functionality has not been implemented yet.
2014-04-17 10:17:26 -07:00
6988676f43 docs(clustering): docs about rejoin 2014-04-17 10:16:53 -07:00
273c293645 fix(server): rejoin cluster with different ip 2014-04-17 10:16:30 -07:00
d368405d05 Merge pull request #734 from unihorn/67
chore: gofmt go files
2014-04-17 08:49:46 -07:00
82dee82bfd chore: gofmt go files 2014-04-17 08:47:48 -07:00
93d1293b9d Merge pull request #733 from unihorn/66
chore: rename proxy mode to standby mode
2014-04-17 08:40:50 -07:00
67600603c5 chore: rename proxy mode to standby mode
It makes the name more reasonable.
2014-04-17 08:04:42 -07:00
1eaa9c9899 docs: record module deprecation 2014-04-16 23:24:11 -07:00
a1a91ab75a chore(server): deprecate mod temporarily 2014-04-15 12:50:36 -07:00
9caa801469 chore(server/transporter): remove unnecessary timeout 2014-04-15 12:08:58 -07:00
65b872c8b5 Merge pull request #725 from dougm/server-lifecycle-fixes
fix(server): avoid race conditions in Run/Stop
2014-04-15 11:54:35 -07:00
3a5cb26973 chore(etcd): loose request timeout
This is a hack to improve multi-etcd boot process.
It could make users alwasy start etcd cluster successfully.
2014-04-15 11:48:22 -07:00
26c77fcf9e chore(config): reset retry interval
Make retry interval random one to avoid join collision.
2014-04-15 11:48:18 -07:00
68afedbd16 chore(server/transporter): set RequestTimout reasonable 2014-04-15 11:13:43 -07:00
63d965133f Merge pull request #729 from unihorn/65
chore: gofmt go files
2014-04-15 10:00:13 -07:00
adf4acf947 chore: gofmt go files 2014-04-15 09:42:25 -07:00
fa95ca0aa8 Merge pull request #728 from unihorn/64
fix(tests/v1_migration): correct HTTP response
2014-04-15 09:35:32 -07:00
d88b52c5f3 fix(tests/v1_migration): correct HTTP response
The bug is introduced in 03839ca8 due to the mistake.
2014-04-15 09:25:14 -07:00
d73390a674 fix(server): avoid race conditions in Run/Stop
- don't close ready channel until PeerServer is listening.
  avoids possible panic in Stop() if PeerServer is nil.

- avoid data race in Run() (err variable was shared between 2 goroutines)

- avoid data race in PeerServer Start/Stop (PeerServer.closeChan)
2014-04-15 09:24:54 -07:00
66c552d048 Merge pull request #724 from bcwaldon/doc-fleet
doc(tools): Add fleet to list of projects using etcd
2014-04-14 14:44:15 -07:00
f5ee9b97de doc(tools): Add fleet to list of projects using etcd 2014-04-14 14:43:37 -07:00
8bcfb2ecaf Merge pull request #707 from unihorn/62
fix(peer_server): recover from outage with discovery
2014-04-14 13:58:43 -07:00
03839ca806 fix(peer_server): recover from outage with discovery
This patch also contains the refactor of find cluster process.
It is changed based on @xiangli-cmu 's commits in 627 issue.
2014-04-14 13:56:47 -07:00
de9c318436 tests: add TestJoinThroughFollower 2014-04-14 13:41:45 -07:00
0b790abd46 Merge pull request #705 from unihorn/61
feat: set NOCOW for log directory when in btrfs
2014-04-14 16:40:38 -04:00
2dc182189a Merge pull request #710 from xiangli-cmu/fix_race
Fix race
2014-04-14 15:53:04 -04:00
8d68e2f5f0 chore(dashboard): recompile with new resources 2014-04-14 12:16:33 -07:00
af6d5efb83 chore(dashboard/fonts): remove unused font files 2014-04-14 12:16:29 -07:00
c08bcb6f5b fix(dashboard/build): update gruntfile for release build 2014-04-14 12:16:24 -07:00
ef99b9ac49 feat(dashboard/stats): stats page 2014-04-14 12:16:18 -07:00
689de466de chore(dashboard/stats): add vega depencency 2014-04-14 12:16:11 -07:00
9e5ada880d feat(dashboard): key/value browser. 2014-04-14 12:13:04 -07:00
151b9c6ed2 feat(dashboard): project setup 2014-04-14 12:13:04 -07:00
35ddb6627e chore(dashboard): move dashboard server & fix routing. 2014-04-14 12:13:00 -07:00
d266f9dec7 Merge pull request #713 from unihorn/63
fix(server/key): unable to update unexpired ttl
2014-04-14 11:06:31 -07:00
1af51ca0c5 docs(ttl): the way to unset ttl 2014-04-14 11:05:52 -07:00
c8de5eee85 fix(server/key): unable to update unexpired ttl 2014-04-14 11:03:46 -07:00
842dd5cab0 chore(dashboard): remove old dashboard 2014-04-14 10:52:26 -07:00
77270c6b00 feat(dashboard): add sigle-page-app html5 pushstate support 2014-04-14 10:50:37 -07:00
d4b33c7e12 Merge pull request #718 from bmizerany/master
docs(production-ready): explain the state of etcd clearly
2014-04-14 00:43:15 -04:00
a05ff7f83d docs(production-ready): explain the state of etcd clearly 2014-04-13 21:38:38 -07:00
8071dd054c Merge pull request #717 from xiangli-cmu/fix_join_redirection
fix(peer join) fix wrong join command redirection
2014-04-13 21:59:39 -04:00
4fd9e627c0 fix(peer join) fix wrong join command redirection
1. We use PUT request to do a V2 join. So we should redirect a PUT request rather than a POST.
2. /admin only accept V2Join request. Send out V2Join instead of V1Join.
2014-04-13 21:33:02 -04:00
56ef6fbcae make necessary changes 2014-04-11 17:00:14 -07:00
bc70cdc242 tests(snapshot_test) loose the timing assumption for snapshot test
Test run slowly on drone after open race option.
2014-04-11 19:49:57 -04:00
dce461dbd7 tests(test.sh) open race option 2014-04-11 19:49:41 -04:00
79a89dcb82 Revert "Revert "fix(server): only set NOCOW for log file""
This reverts commit 9540575690.

Conflicts:
	etcd/etcd.go
2014-04-11 16:33:50 -07:00
fc84da29e8 fix(internal_version_test.go) protect the checkedVersion by a lock 2014-04-10 23:35:55 -04:00
2817baf3f8 fix(discovery_test.go) protect the garbageHandler by a lock 2014-04-10 23:28:40 -04:00
a9dff278b5 fix(store.go) send event to watcher after we finish modifying it 2014-04-10 23:27:50 -04:00
af87fa40c2 fix(registry.go) protect the peer and proxy map in the registry by lock 2014-04-10 23:24:09 -04:00
6d08976cbe fix(raft_server_stats.go) protect raft stats by a lock 2014-04-10 22:50:44 -04:00
11525d357f fix(CONTRIBUTING): point to new mailing list 2014-04-10 15:20:28 -07:00
2a8c2c6a0b fix(README): use the new etcd-dev mailing list
We moved to google groups, update the URLs
2014-04-10 15:18:13 -07:00
bda8849c3b chore(btrfs): rename fs to btrfs
This is because the actions is specific for btrfs.
2014-04-09 15:06:17 -07:00
375aeb57af fix(fs): make check on NOCOW 2014-04-09 14:44:54 -07:00
9540575690 Revert "fix(server): only set NOCOW for log file"
This reverts commit 1eff547af6.
2014-04-09 14:39:16 -07:00
8c0c427870 Merge pull request #694 from unihorn/59
chore(discovery): adjust error message
2014-04-09 13:50:28 -07:00
6d77e4dfd6 fix(fs): rewrite test to avoid side effect 2014-04-09 13:11:23 -07:00
fe5eb31ca7 Merge pull request #706 from unihorn/62
bump(goraft/raft): cfa43a115
2014-04-09 12:53:25 -07:00
66ce075ce1 bump(goraft/raft): cfa43a115 2014-04-09 12:42:20 -07:00
1eff547af6 fix(server): only set NOCOW for log file 2014-04-09 12:35:32 -07:00
d871324e93 chore(pkg/fs): rewrite comment 2014-04-09 10:15:28 -07:00
b06d2796f8 feat: set NOCOW for log directory when in btrfs 2014-04-09 10:00:21 -07:00
84ad6ddd79 chore(build): set build path to gopath/
With this, pkg/ could be used as normal directory, and it doesn't need
to gitignore pkg/, which shields pkg/http and pkg/strings.
2014-04-09 09:51:58 -07:00
4ce8c3499b Merge pull request #702 from unihorn/60
feat(server): make header-only requests work
2014-04-08 17:58:38 -07:00
76ac1da7ea feat(server): add HEAD for v1/watch 2014-04-08 17:37:05 -07:00
89d3df242c chore(server): handle HEAD for key space efficiently
Implement HEAD in server/v1 and server/v2 functions to avoid
time wasting on JSON marhsal.
2014-04-07 18:55:07 -07:00
28f19dec60 feat(server): make header-only requests work 2014-04-07 13:51:33 -07:00
3b2d039664 Merge pull request #699 from stevecrozz/suppress-debconf-warnings
fix(Dockerfile): debconf use noninteractive
2014-04-07 09:33:29 -07:00
d66efc550d fix(Dockerfile): debconf use noninteractive
DEBIAN_FRONTEND=noninteractive tells apt-get install to use the
noninteractive front end for debconf. This keeps the system from
attempting to interact with the user during package configuration.
Without it, debconf issues warnings like:
```
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can't locate Term/ReadLine.pm in @INC (@INC contains:
/etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2
/usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14
/usr/local/lib/site_perl .) at
/usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
debconf: falling back to frontend: Teletype
```
2014-04-05 14:06:19 -07:00
2c65e9852c Merge pull request #698 from unihorn/61
bump(goraft/raft): 585c58026c
2014-04-04 17:13:58 -07:00
ef98f6051c bump(goraft/raft): 585c58026c 2014-04-04 17:10:18 -07:00
e650329eac Merge pull request #697 from unihorn/60
correctly restart etcd node after snapshotting
2014-04-04 16:56:14 -07:00
d2c0a008ce bump(goraft/raft): f94d98c 2014-04-04 16:45:15 -07:00
1c40f327be test(snapshot): test restart with snapshot 2014-04-04 16:45:02 -07:00
be9ee58a52 Merge pull request #696 from joshuaconner/fix_https_googlefonts_error
dashboard: remove protocol from google fonts links so they work with https
2014-04-04 16:05:35 -07:00
5987917c0a dashboard: remove protocol from google fonts links so they work with htttps 2014-04-04 15:40:39 -07:00
12b106c0f0 Merge pull request #692 from jonboulle/master
Clean up README and merge new contribution guidelines
2014-04-04 14:11:30 -07:00
dbaa2cbdee chore(discovery): adjust error message 2014-04-04 12:59:22 -07:00
cbcd0aff9e Merge pull request #693 from unihorn/58
fix test error
2014-04-04 11:46:42 -07:00
e624d4ef33 fix(build): make build run well
1. remove unnecessary target directory
2. comparison update to run on linux
2014-04-04 11:32:19 -07:00
fd9ad4fa2c docs(readme/contrib): clean up README, merge changes from CONTRIBUTING.md and split out DCO 2014-04-04 10:58:34 -07:00
0a4b6570e1 chore(tests): start TLS cluster slowly to evade problem 2014-04-04 10:57:11 -07:00
e01a1f70c3 Merge pull request #2 from jonboulle/master
Clean up CONTRIBUTING.md and other bits of template-project
2014-04-04 10:41:40 -07:00
2e4ea503b0 chore(contributing): clean up CONTRIBUTING.md and split out DCO 2014-04-04 10:40:37 -07:00
d8a53ca716 Merge pull request #635 from metaflow/benchmarking
feat(benchmark) fix of flag arguments and updated logging
2014-04-04 09:57:36 -07:00
bec7d7f614 Merge pull request #688 from unihorn/57
fix test error
2014-04-03 17:36:14 -07:00
915cc53d83 chore(test.sh): move gofmt check to the end of testing
So it won't be blocked on gofmt check.
2014-04-03 17:04:35 -07:00
f0dee63716 chore(build): update gofmt target 2014-04-03 17:03:50 -07:00
9129475a51 Merge pull request #646 from metaflow/api-doc-release-lock
doc(api) correct release lock curl command
2014-04-03 16:59:31 -07:00
41ad9ebb48 Merge pull request #665 from unihorn/52
feat(test): check format conditions in test
2014-04-02 17:58:28 -07:00
3fece6a716 feat(test): check format conditions in test
And add option '--fmt' in build script to gofmt files automatically.
2014-04-02 17:57:53 -07:00
1f12e163de Merge pull request #650 from cenkalti/main
refactor(main): move main logic to separate package
2014-04-01 15:19:54 -07:00
7c1b7d764a fix(main): remove duplicate line in etcd.go 2014-04-01 14:22:07 -07:00
58e1e02688 refactor(main): return only receiving channel from Etcd.ReadyNotify() 2014-04-01 12:54:38 -07:00
d000ba3ed3 chore(main): add a space line between the two if statements 2014-04-01 12:54:38 -07:00
1b59eacb72 refactor(main): rename etcd.go to main.go 2014-04-01 12:54:38 -07:00
3eb74fc32c chore(main): add todo item and update comments 2014-04-01 12:54:37 -07:00
a9e77c022c refactor(main): reorder code 2014-04-01 12:54:37 -07:00
dfbabc5a77 refactor(main): remove Etcd.StopNotify() method 2014-04-01 12:50:44 -07:00
c5632b039a fix(main): stop PeerServer on Etcd.Stop() 2014-04-01 12:50:43 -07:00
46623c00a8 fix(main): fix ready notifier 2014-04-01 12:50:43 -07:00
ccb960f47f refactor(main): close peer server first 2014-04-01 12:41:33 -07:00
561ad16757 refactor(main): rename Etcd.Close() to Etcd.Stop() 2014-04-01 12:41:33 -07:00
399f491fd7 feat(main): add close and ready notifiers for etcd instance 2014-04-01 12:41:33 -07:00
c463293d39 feature(main): add Etcd.Close() method 2014-04-01 12:41:33 -07:00
094cc6347d refactor(main): move main logic to separate package
The use case is to make it easy to embed etcd into another programs.
Currently, the only way of doing this to copy and paste the contents
of the `main()` in etcd.go.
With this commit, contents of the `main()` is moved into `Etcd.Run()`.
2014-04-01 12:41:33 -07:00
022908f1fa Merge pull request #670 from daniel-garcia/patch-1
Update clients-matrix.md
2014-04-01 11:09:03 -07:00
2ad9ea8c57 Update clients-matrix.md
go-etcd does not currently support Lock or Leader modules.
2014-04-01 09:24:00 -05:00
b2f787a2fd Merge pull request #653 from unihorn/49
chore(etcd): print out go-etcd log in VeryVeryVerbose Mode
2014-03-31 16:55:20 -07:00
ea701b3adb chore(etcd): print out go-etcd log in VeryVeryVerbose Mode 2014-03-31 16:53:48 -07:00
eb21381ddd fix(Documentation/cluster-discovery): link to optimal cluster size 2014-03-31 14:48:25 -07:00
534b5feca6 Merge pull request #668 from darron/patch-1
2 nodes isn't durable - to be somewhat expected.
2014-03-31 14:46:33 -07:00
754159b60f Update cluster-discovery.md 2014-03-31 15:45:23 -06:00
fa7c77a6e0 2 nodes isn't durable - to be somewhat expected.
So maybe we add this small documentation patch to show minimum 3 nodes.
2014-03-31 15:07:18 -06:00
5b4a473f14 Merge pull request #667 from unihorn/53
chore(tests): test TestTLSMultiNodeKillAllAndRecovery now
2014-03-27 22:40:09 -04:00
eeca12a4c0 Merge pull request #663 from tsenart/master
Making code formatting consistent.
2014-03-27 17:08:12 -07:00
4e747d24dd chore(tests): test TestTLSMultiNodeKillAllAndRecovery now
It is fixed.
2014-03-27 17:06:18 -07:00
4f1607b775 Merge pull request #651 from unihorn/48
fix(tests): pass all tests using latest raft
2014-03-27 16:19:59 -07:00
140329d927 Merge pull request #654 from robszumski/timeout-docs
feat(docs): document peer timeout flag and env var
2014-03-27 07:27:52 -07:00
b6053d6a86 Making code formatting consistent.
$ gofmt -s -w  && goimports -w
2014-03-27 14:19:08 +01:00
1f10c4d352 Merge pull request #662 from bmizerany/skip
test(tests/functional): skip TestTLSMultiNodeKillAllAndRecovery until fi...
2014-03-26 19:24:43 -07:00
4bce3e4810 test(tests/functional): skip TestTLSMultiNodeKillAllAndRecovery until fixed 2014-03-26 19:22:59 -07:00
99c8b097d1 ignore .etcd dirs 2014-03-26 12:19:20 -07:00
f4aaef5955 Merge branch 'master' of https://github.com/coreos/etcd 2014-03-26 10:43:37 -06:00
85301dbc4e Add mod/lock timeout.
Added timeout goroutine to stop waiting on lock after timeout
expiration.

This necessitated reworking the flow of the acquire handler.  createNode
now _only_ creates the node; it no longer waits on the lock itself.
getLockIndex (perhaps this is poorly named) extracts out the lock
checking routine so that it can be used by "get" and "watch", both.
get() was added to instantaneously attempt to acquire a lock with no
waiting.

If a lock fails to acquire, for whatever reason, an error is returned,
resulting in a code 500 to the client.
2014-03-26 10:39:48 -06:00
8afa93ed59 chore(server/listener): improve comment 2014-03-25 22:51:52 -07:00
2bba9a984e Merge pull request #657 from cenkalti/errors
refactor(errors): use map literal syntax
2014-03-26 00:19:18 -04:00
303a3096d4 refactor(errors): use map literal syntax
Error strings align better this way.
2014-03-25 20:17:21 -07:00
e86fe8e749 feat(docs): document peer timeout flag and env var 2014-03-25 13:07:22 -07:00
a3cbf02597 fix(tests): pass all tests using latest raft 2014-03-24 17:35:45 -07:00
802aaf59db Merge pull request #582 from benbjohnson/proxy
Proxies & Config API
2014-03-24 16:30:47 -06:00
62b89a128a Merge branch 'master' of https://github.com/coreos/etcd into proxy
Conflicts:
	config/config.go
	server/peer_server.go
	server/transporter.go
	tests/server_utils.go
2014-03-24 15:30:14 -07:00
174b9ff343 bump(github.com/goraft/raft): 6bf34b9
Move from coreos/raft to goraft/raft and update to latest.
2014-03-24 15:09:47 -07:00
a20ce3e7a5 doc(api) correct release lock curl command
related to #638 issue - DELETE request body is ignored
typo fixed
2014-03-23 21:53:54 +07:00
aeb9e0633a Merge pull request #641 from mdlayher/patch-1
docs(Documentation/api): fix JSON spacing, syntax highlighting
2014-03-22 09:30:21 -07:00
38631395b6 docs(Documentation/api): fix JSON spacing, syntax highlighting 2014-03-20 02:36:35 -04:00
7d4fda550d Machine join/remove v2 API. 2014-03-18 16:25:21 -06:00
4b5765e2c7 Merge pull request #634 from unihorn/42
fix(test/server): minimize the process of getting watch result
2014-03-18 11:44:31 -07:00
df2b565397 fix(test/server): avoid watch test timeout by moving json decode
These tests were timing out because the combination of the GET and JSON
decode was taking longer than the timeout. Pull the JSON decode out of
the go routine that is being timed.
2014-03-18 08:49:14 -07:00
1a8a6ce872 Merge pull request #637 from xetorthio/patch-1
Add etcd-fs as a tool
2014-03-18 07:53:28 -07:00
bb3b71a43f Add etcd-fs as a tool 2014-03-18 10:37:24 -04:00
803aeb8fae feat(benchmark) fix of flag arguments and updated logging 2014-03-18 12:33:19 +07:00
15126a680f Merge pull request #621 from unihorn/34
chore(fixtures/ca): make all certificates generated by etcd-ca
2014-03-17 13:47:59 -07:00
50d9e6a7fd chore(fixtures/ca): make all certificates generated by etcd-ca 2014-03-17 12:32:55 -07:00
838a945862 feat(Vagrantfile): Add Vagrantfile for easy start 2014-03-15 12:48:48 -07:00
79e4c838f4 Merge pull request #626 from xiangli-cmu/refactor_listener
refactor(listener) refactor listener related code
2014-03-13 20:05:54 -07:00
3ae792b159 refactor(listener) refactor listener related code
Remove duplicate code around creating http listener.
Start to listen incoming http requests just before serving them.
2014-03-13 15:47:27 -07:00
a9d5cc5a50 Merge pull request #610 from metaflow/master
docs(api) added note for CAS about prevIndex=0 and `cause` meaning in server response
2014-03-11 20:25:31 -07:00
b8f59340af docs(api): updated examples and description of CAS and CAD 2014-03-12 09:33:47 +07:00
c8e65c1315 Merge pull request #616 from xiangli-cmu/add_snapshot_post
fix(server/transporter.go) fix the short timeout problem of sending snapshot
2014-03-11 18:51:47 -07:00
0ea6141dc8 Merge pull request #614 from metaflow/fix-611
fix Compare and swap returns incorrect cause
2014-03-10 18:16:49 -07:00
e9a1ac15d9 Allow partial cluster config updates. 2014-03-10 16:05:03 -07:00
c0a59b3a27 Add minimum active size and promote delay. 2014-03-10 14:44:04 -06:00
074c78d725 fix(store): corrected CAS and CAD fail cause in response
specifically when both prevIndex and prevValue are provided
2014-03-08 14:50:34 +07:00
312ac5d066 fix(server/transporter.go) fix the short timeout problem of sending snapshot
Snapshot can be tens of MB. We need to have a minute level timeout for sending snapshot.
We add a separate snapshot http client for snapshot request, which has 120s timeout.
2014-03-08 00:15:47 -05:00
c91688315a Minor fixes to proxies. 2014-03-07 07:38:40 -07:00
653274b9f6 fix(CONTRIBUTING): minor grammar fixes 2014-03-06 14:12:51 -08:00
3fff1a8dcd Add /machines and /machines/:name endpoints. 2014-03-06 15:11:31 -07:00
12c334a141 Merge pull request #613 from unihorn/29
docs(CONTRIBUTING): add code style section
2014-03-06 16:53:55 -05:00
e80a35edbe docs(CONTRIBUTING): add code style section 2014-03-06 13:38:20 -08:00
c3247755ea Merge branch 'proxy' of https://github.com/benbjohnson/etcd into proxy 2014-03-06 13:39:05 -07:00
3cd83c61c4 Fix PUT /config response and log errors. 2014-03-06 13:35:46 -07:00
2a7fdfe189 Merge pull request #4 from philips/benbjohnson-proxy
feat(scripts/test-cluster): create three proxy nodes
2014-03-06 10:13:13 -08:00
ac872b3855 Merge pull request #607 from Asmod4n/patch-1
Added Error 107 to Documentation
2014-03-05 09:18:44 -08:00
b1916b30fb Merge pull request #612 from congpeijun/master
Add PHP library.
2014-03-05 09:17:23 -08:00
3a1d9e683b Add PHP library.
We implement the api client useing php.
2014-03-05 20:01:42 +08:00
148ac97742 docs(errorcode.md): add the EcodeRootROnly error 2014-03-05 09:18:10 +01:00
ddce52c44e feat(scripts/test-cluster): create three proxy nodes
This uses some sleep hackery to make sure that window 1 has followers
and window 2 has proxy machines. Seems to work!
2014-03-04 18:58:39 -08:00
fe4dee03ab Minor fixes. 2014-03-04 09:29:44 -07:00
c3b4afc139 Fix JoinCommand comment. 2014-03-04 08:56:10 -07:00
063f3b574c Check for peer before demotion. 2014-03-04 08:53:13 -07:00
49253d8fdf Merge pull request #604 from ccding/master
fix trivial issues as I see them
2014-03-03 16:21:04 -08:00
dbed0f7d6a fix(Documentation/*): fix various typos 2014-03-03 16:12:15 -08:00
c8d6b26dfd Add auto-demotion after peer inactivity. 2014-03-03 11:15:05 -07:00
f3cc456385 Merge pull request #598 from unihorn/19
fix bugs that are found in issue #579
2014-03-01 00:30:58 -08:00
349a802a82 chore(server): remove useless CancelWhenTimeout
Setting request timeout is covered by go-httpclient now.
2014-02-28 21:52:56 -08:00
69adb78433 fix(transporter): CancelRequest doesn't work on HTTPS connections blocked
Currently this is a workaround. And it should be fixed in Go1.3.
2014-02-27 14:31:46 -08:00
e99bc99dcc fix(tests/multi_node_kill_all_and_recovery): wait for cluter to build over 2014-02-27 14:31:46 -08:00
df49265674 fix(discovery): remove its own address from peer list to join 2014-02-27 14:31:28 -08:00
e5797a54a1 fix(README): remove the drone.io badge
the drone.io badge is either cached wrong by github or links to a wrong version when we build a branch, just remove it.
2014-02-27 12:48:07 -08:00
a60481c6b1 Merge pull request #593 from benbjohnson/lock-fix
fix(mod/lock): correct watch index to remove cpu load
2014-02-26 17:34:22 -07:00
dde2b71850 fix(mod/lock): correct watch index to remove cpu load
The waitIndex was being pulled from the wrong node in the lock parent which caused the watch to be returned immediately. This caused a continuous set of calls while a client was waiting for a lock.
2014-02-26 17:26:25 -07:00
fddbf35df2 Add automatic node promotion / demotion. 2014-02-25 10:02:01 -07:00
23ffafefc0 Merge pull request #596 from philips/add-file-upload-docs
feat(Documentation/api): document file upload
2014-02-24 18:49:11 -08:00
f5698d3566 Proxy promotion. 2014-02-24 17:01:04 -07:00
02a053a4b8 feat(Documentation/api): document file upload
This gets asked about a lot int IRC/mailinglist/etc. Fixes this issue:
https://github.com/coreos/etcd/issues/383#issuecomment-31183603
2014-02-23 10:17:05 -08:00
4c17dc3431 Merge pull request #592 from Plasma/patch-1
Trivial formatting correction
2014-02-22 18:49:57 -08:00
e6e6f7d8d0 Trivial formatting correction 2014-02-23 12:48:35 +11:00
1d961b8e56 Add proxy mode. 2014-02-22 15:02:20 -07:00
f922a08a27 Merge pull request #586 from wereHamster/patch-1
docs: Add links to haskell bindings and scrz project
2014-02-21 10:03:35 -08:00
7289224af9 Merge pull request #585 from philips/document-consistent
feat(Documentation): add a section on consistent reads
2014-02-21 09:40:47 -08:00
035bbc6913 feat(Documentation): add a section on consistent reads
We have waited too long to document `consistent=true`. Document it!
2014-02-21 09:39:54 -08:00
ae8d416c57 Add links to haskell bindings and scrz project 2014-02-21 02:59:38 +00:00
46d817f91b Merge pull request #577 from unihorn/6
chore: rename 'heartbeat timeout' to 'heartbeat interval'
2014-02-18 17:11:31 -08:00
f434177a9a chore: rename 'heartbeat timeout' to 'heartbeat interval'
Heartbeat timeout means the period length that indicates heartbeat is
out of service, which is different from heartbeat interval.

So we should use '-peer-heartbeat-interval' instead of
'-peer-heartbeat-timeout' in etcd.

'-peer-heartbeat-timeout' is deprecated but still could be used.
2014-02-18 16:37:20 -08:00
8485987b74 Merge pull request #524 from yifan-gu/remove_omitempty_on_value
remove omitempty on value
2014-02-18 07:08:00 -08:00
9cfd8c5f0b fix(store): make NodeExtern.Value a *string
Before this change if the value of a Node was "" it would get dropped from the json
encoding and the Node.Value field would be missing. Fix this problem by making
NodeExtern.Value a *string so that an empty string will be encoded but a nil value
will drop the field.
2014-02-18 00:50:44 -05:00
04f21b5976 Merge pull request #569 from unihorn/5
Ordering and functionality of `-discovery` `-peers` and data dir to find peers
2014-02-17 14:34:53 -08:00
cf38910601 docs: boot order to find peers 2014-02-17 14:17:14 -08:00
3a4df1612c feat(discovery): adjust boot order to find peers
The boot order for peers is -discovery, -peers, log data, forming
new cluster itself.

Special rules:
1. If discovery succeeds, it would find peers specified by discover URL
only.
2. Etcd would fail when meeting bad -discovery, no -peers and log data.

Add TestDiscoveryDownNoBackupPeersWithDataDir as the test.
2014-02-17 12:53:39 -08:00
bd56b15b6e fix(tests/discovery): use host as -peers parameter instead of url
Or it cannot test the functionality correctly.
Moreover, add TestDiscoveryNoWithBackupPeers as the test for it.
2014-02-14 18:23:41 -08:00
a72f913a60 fix(tests/functional): some squashing mistakes in PR merge
accidental squash mistake in the last PR that was merged caused a
function to be renamed but not it's caller.
2014-02-14 18:17:30 -08:00
7599a285c3 Merge pull request #574 from unihorn/6
Fix the bug that TestSimpleMultiNodeTls may error sometimes
2014-02-14 18:08:01 -08:00
efdc741e5c feat(tests/util): wait until server is up when creating cluster
Wait until server is up instead of for some time
2014-02-14 18:06:43 -08:00
93a02b619e Merge pull request #573 from cenkalti/stream-bug
Store: Fix slow consumer bug
2014-02-14 20:46:37 -05:00
e69118ade7 chore(tests/multi_node_kill_one): check function-call result
To stop test in time if error occurs
2014-02-14 17:36:11 -08:00
8bed1e1f15 fix(store/watch): fix the slow consumer bug 2014-02-14 16:52:40 -08:00
e73e61f238 test(store/watch): add test case for slow event consumers 2014-02-14 16:12:53 -08:00
9247486576 Merge pull request #568 from pjjw/fix-dash
Fix directory browsing in dashboard
2014-02-14 14:41:29 -08:00
1cc60df5f3 fix(Documentation): example of discovery in conf and env vars 2014-02-14 08:59:17 -08:00
b85eb2a44c feat(README): link to raft homepage 2014-02-13 21:58:39 -08:00
5de1caf057 Fix directory browsing in dashboard 2014-02-13 22:42:21 -05:00
be069d5918 fix(Documentation/tuning): fix incorrect comment about snapshot 2014-02-13 13:54:09 -08:00
bb911e6ab8 Merge pull request #566 from unihorn/3
chore(test): remove useless node1.etcd dir
2014-02-13 10:01:58 -08:00
7ad2dadabf chore(test): remove useless node1.etcd dir
It is a directory checked in from an etcd test run in mistake.
2014-02-13 08:52:16 -08:00
98396e8367 Merge pull request #565 from philips/cleanup-version
fix(etcd): get consistent with etcdctl on printing versions
2014-02-13 07:59:27 -08:00
fccecd4a05 fix(etcd): get consistent with etcdctl on printing versions
Lets get a bit more consistent in printing the versions:

```
$ ./bin/etcd -version
etcd version 0.3.0+git
$ ./bin/etcdctl -v
etcdctl version 0.3.0+git
```
2014-02-13 07:54:44 -08:00
db1b53fde7 chore(server): add +git to the version
we need to automate this but make sure versions built from git have
+git after the version number.
2014-02-12 22:02:00 -08:00
c423f38700 Merge pull request #563 from benbjohnson/raft
bump(github.com/coreos/raft): cff0a00
2014-02-11 16:34:50 -07:00
193fe2df71 bump(github.com/coreos/raft): cff0a00 2014-02-11 16:09:04 -07:00
6f14467383 Merge pull request #559 from philips/document-missing-stats
fix(Documentation): single machine clusters have some stats undefined
2014-02-11 10:17:45 -08:00
7015214fbb Merge pull request #554 from mfischer-zd/tls_fixes
fix(server/tls_info): use all certificates in CA file
2014-02-11 10:17:33 -08:00
e1af3dbde6 fix(server/tls_info): use all certificates in CA file
fixes coreos/etcd#553
2014-02-10 22:31:22 -08:00
040c1f591e Merge pull request #560 from marineam/test-v1
add(server/v1/tests): Port many of the v2 HTTP handler tests to v1
2014-02-10 22:29:35 -08:00
f206db2cee add(server/v1/tests): Port many of the v2 HTTP handler tests to v1
This should cover most aspects of the v1 API but being new to the etcd
code base I cannot promise that or that the tests are even correct.
They do pass though :)
2014-02-10 22:18:06 -08:00
ba8e5d7add fix(Documentation): single machine clusters have some stats undefined
document that single machine clusters will omit sendBandwidthRate and
sendPkgRate.

Via http://thread.gmane.org/gmane.comp.distributed.etcd/218
2014-02-10 21:58:09 -08:00
ac5e35101c Merge pull request #558 from philips/v1-put-crash-fix
fix(server/v1): don't fail put on new v1 key
2014-02-10 19:57:00 -08:00
68383b1293 fix(server/v1): don't fail put on new v1 key
We weren't checking for PrevNode being nil in the v1 code path. Do this
and add a test.

Fixes #557
2014-02-10 18:59:56 -08:00
137f87c414 Merge branch 'mod-lock-fixes' of https://github.com/nabeken/etcd into nabeken-mod-lock-fixes
Conflicts:
	mod/lock/v2/acquire_handler.go
2014-02-10 08:05:57 -07:00
f5be7c9136 Merge pull request #551 from bcwaldon/doc-compareAndDelete
Document CompareAndDelete
2014-02-09 15:29:24 -08:00
a00bf38f16 feat(scripts): use zip for windows and darwin
zip files are more common on OSX and windows. Use those file formats for
those two platforms.
2014-02-09 12:11:14 -08:00
c34a2b85ed Merge pull request #550 from badboy/patch-1
Change token example to use returned value only
2014-02-08 09:22:45 -08:00
60a2709213 chore(gofmt): gofmt compare_and_delete_command.go 2014-02-08 07:28:16 -08:00
1fcbc83503 doc(CompareAndSwap): clarify prevIndex in CAS 2014-02-08 07:27:59 -08:00
08818886b2 doc(CompareAndDelete): Add missing CAD docs
Fixes issue #549
2014-02-08 07:27:33 -08:00
c6910a96de Change token example to use returned value only
The discovery.etcd.io/new already returns a complete URL containing the host, so there is no need to specify it on the command line.
2014-02-08 09:58:24 +01:00
86546c68b4 fix(README): move contact closer to contributing 2014-02-07 18:23:26 -08:00
0cc69abc70 bump(README): increase the version of the README to 0.3.0 2014-02-07 18:22:39 -08:00
f9d27c37aa Merge pull request #548 from philips/0.3.0
doc(CHANGELOG): document v0.3.0
2014-02-07 15:57:08 -08:00
ddc40e5b45 doc(CHANGELOG): document v0.3.0 2014-02-07 15:54:45 -08:00
0c2287b201 fix(scripts/build-release): use cross compilation 2014-02-07 15:50:57 -08:00
102d8e543d bump(mod/dashboard): rebuild the dashboard for the latest fixes 2014-02-07 15:17:00 -08:00
b4d5534c75 Merge pull request #546 from sym3tri/dashboard-tabindexes
fix(dashboard): disable some tab indexes.
2014-02-07 15:10:09 -08:00
4f72403acd Merge pull request #544 from bcwaldon/case-insensitive-query-params
fix(v2): Use case-insensitive check on bool query params
2014-02-07 15:09:51 -08:00
4c0c256a9d fix(dashboard): disable some tab indexes. 2014-02-07 15:09:30 -08:00
d0f254a278 Merge pull request #545 from bcwaldon/doc-prevNode
doc(api): Document prevNode
2014-02-07 15:08:28 -08:00
0696e5026f doc(api): Document prevNode 2014-02-07 15:03:15 -08:00
42363001b4 fix(v2): Use case-insensitive check on bool query params
Fix issue #261
2014-02-07 14:29:08 -08:00
ed3d63248a Merge pull request #543 from philips/bump-goraft
bump(github.com/coreos/raft): ef3280ce54f60fff98a72012f547ed2b3415841f
2014-02-07 12:33:25 -08:00
2a2714a4bf Merge pull request #514 from cenkalti/prevNode
feat(prevNode): add "prevNode" to "Set" response
2014-02-07 12:04:18 -08:00
27cb38f38c fix(Documentation): add etcd-dump to libraries and tools
Fixes #325
2014-02-07 11:35:19 -08:00
e8be43d4c6 Merge pull request #528 from coreos/restructure-dashboard
Restructure dashboard & bug fixes
2014-02-07 11:26:18 -08:00
76da437f29 bump(github.com/coreos/raft): ef3280ce54f60fff98a72012f547ed2b3415841f 2014-02-07 11:19:23 -08:00
b4635b0b80 Merge pull request #542 from philips/fix-the-build
Fix the tests
2014-02-07 07:01:00 -08:00
147235f8f5 fix(test.sh): re-add the config tests
These tests were left behind in the move to put config in its own
package.
2014-02-06 22:52:50 -08:00
aa5c8b8ffd test(config): unexport ETCD_DISCOVERY
if this is exported the next tests will try and use it and fail.
2014-02-06 22:52:18 -08:00
1b3481fe25 fix(server/peer_server): stop the raftServer in Stop()
Stop() the raftServer if we stop the peerServer so that tests that start
and stop PeerServers exit cleanly.
2014-02-06 22:10:10 -08:00
21d7d14178 chore(tests/discovery): remove errant debug statement 2014-02-06 22:10:10 -08:00
14f15c33fe fix(tests/server_utils): use a WaitGroup for RunServer
Make sure that all of the servers exit before we return by using a
WaitGroup in each handler. This was used to help track down the issue
with the TestDiscoverySecondPeerUp test and the hung go-etcd watcher.
2014-02-06 22:10:10 -08:00
bfbc539321 hack(tests/discovery): don't use go-etcd for watch
go-etcd has a bug in the watcher that holds open a goroutine. Avoid
goetcd for this operation until it is fixed.
2014-02-06 22:10:10 -08:00
5f124166eb feat(tests/discovery): use low retry interval
In TestDiscoverySecondPeerFirstNoResponse use a low retryinterval so the
test doesn't take forever.
2014-02-06 22:10:10 -08:00
468a68c96c feat(server): make the RetryInterval of PeerServer tunable
For tests and other environments it would be nice to be able to tune how
long to sleep between retries.
2014-02-06 22:10:09 -08:00
da3fe920cb fix(tests/v1_migration): add a -name flag
The info flag is ignored as of 1c91c167fc
so in order for this test to work we need to add `-name` flag.
2014-02-06 21:23:00 -08:00
3d9fc3846c fix(scripts/test-cluster): fix backwards logic on peers add 2014-02-06 21:15:38 -08:00
63fa35c99f refactor(tls): clarify & simplify tls configuration 2014-02-06 21:15:38 -08:00
68305181f9 Merge pull request #538 from xiangli-cmu/fix_hidden_watch
fix(watcher_hub)
2014-02-06 12:39:18 -05:00
c844fccf2a fix(watcher_hub) isHidden checks the length of the watchPath before getting subString of keyPath 2014-02-06 11:09:47 -05:00
f2452a4a3c fix(build): Use ngmin. Fix all introduced erros in previous commits. 2014-02-05 22:41:10 -08:00
4e21405647 fix(dashboard): bugs in key browser and stats page.
Fixed key add, key delete bugs. More refactoring.
2014-02-05 22:40:04 -08:00
06f990236c refactor(dashboard): Restructured front-end dashboard code. 2014-02-05 22:39:46 -08:00
8a172322ff Merge pull request #537 from xiangli-cmu/fix_hidden_watch
fix(watch hidden key)
2014-02-05 23:43:41 -05:00
1b5f9eb013 test (isHidden) add unit test for isHidden function 2014-02-05 23:32:12 -05:00
5851cb5b8d chrod(watcher_hub) add comment to isHidden function 2014-02-05 23:31:38 -05:00
ba98de6ef0 fix(watch hidden key) Fix hidden keys preventing deeper recursive watches from receiving events
If a watcher has given the correct hidden directory, we should allow it to watch the non-hidden events under that hidden directory. This pull request achieves this by checking if the path after the watching prefix has a "/_" which indicates a hidden key.
2014-02-05 22:34:41 -05:00
d2a0f8f2fd Merge pull request #535 from robszumski/master
fix(docs): explicitly create links instead of using the markdown parser
2014-02-05 16:53:56 -08:00
445b584333 fix(docs): explicitly create links instead of using the markdown parser 2014-02-05 16:52:31 -08:00
f7dae0de02 Merge pull request #533 from robszumski/master
fix(docs): add full command example and link to discovery spec
2014-02-05 16:29:43 -08:00
1c6a41dda4 Merge pull request #532 from philips/remove-info-file
feat(config): remove the info file
2014-02-05 16:21:27 -08:00
1c91c167fc feat(config): remove the info file
The info file was meant to help the user from accidently making a
mistake but often times it just confuses people:

https://github.com/coreos/etcd/issues/356
https://github.com/coreos/etcd/issues/531
https://github.com/coreos/etcd/issues/318

Lets remove the info file for this next release.
2014-02-05 16:20:50 -08:00
c7aef5fdf2 Merge pull request #1 from bcwaldon/fix-case
fix(CONTRIBUTING.md): Fix title case
2014-02-05 15:52:24 -08:00
c4605160c5 fix(CONTRIBUTING.md): Fix title case 2014-02-05 15:51:24 -08:00
39518b463a Merge pull request #534 from philips/discovery-protocol-fix
fix(discovery): use prevExist instead of prevValue=init
2014-02-05 15:15:08 -08:00
cbdf4a738c fix(discovery): use prevExist instead of prevValue=init
Use PUT /_state?prevExist=true in the protocol instead of PUT
/_state?prevValue=init. This lets people point one vanilla etcd at the
key prefix of another vanilla etcd and have it just work.
2014-02-05 15:14:57 -08:00
1d4912b22f fix merge conflicts 2014-02-05 14:39:48 -08:00
bc7297c2d0 feat(docs): add cluster discovery documentation 2014-02-05 14:37:40 -08:00
39ddb29e63 Merge pull request #515 from robszumski/master
feat(docs): add cluster discovery documentation
2014-02-05 11:53:31 -08:00
fe35839a77 feat(docs): add cluster discovery documentation 2014-02-05 10:54:28 -08:00
297832ff91 Merge pull request #512 from philips/bootstrap-protocol
feat(discovery): initial working code
2014-02-05 09:27:52 -08:00
2d75ef0c7a feat(Documentation/discovery-protocol): explain heartbeating
Explain more information about how the TTL works and etcds role.
2014-02-05 09:27:40 -08:00
2822b9c579 tests(tests/functional): add tests for Discovery
This tests a variety of failure cases for the Discovery service
including:

- Initial leader failures
- Discovery service failures
- Positive tests for discovery working flawlessly
2014-02-05 09:27:39 -08:00
ff6090836c fix(tests/server_utils): add a metrics bucket
This is required to avoid getting nil pointer exceptions if a peer joins
this test server.
2014-02-05 09:27:39 -08:00
a8b07b1b48 chore(config): go fmt 2014-02-05 09:27:39 -08:00
8687dd3802 feat(discovery): fully working discovery now 2014-02-05 09:27:39 -08:00
40021ab72e bump(github.com/coreos/go-etcd): 526d936ffe75284ca80290ea6386f883f573c232 2014-02-05 09:27:39 -08:00
72514f8ab2 feat(bootstrap): initial working code
This is an initial version of the bootstrap code that seems to work
under the normal circumstances. I need to mock out a server that will
test out all of the error cases now.
2014-02-05 09:27:39 -08:00
40a8542c22 feat(bootstrap): wire up the flag
This wires up `-bootstrap-url` to some code (which crashes) :)
2014-02-05 09:27:39 -08:00
f56965b1c0 refactor(config): make config its own package
Refactor config into its own package. Trying to tease the config from
the server so that all of the control surfaces are exposed in the Server
for easier testing.
2014-02-05 09:27:39 -08:00
69922340f6 refactor(server): move utilities into pkg
like camlistore lets move these utilities into a `pkg` prefix.
2014-02-05 09:27:39 -08:00
0e50d9787a feat(*): bootstrap initial commit
Setup the flags, and checkin the docs. Lets do this!
2014-02-05 09:27:39 -08:00
9e43e726a9 Merge pull request #507 from philips/turn-snapshots-on-by-default
feat(*): enable snapshots by default
2014-02-05 09:08:43 -08:00
03cadc543f Merge pull request #525 from yifan-gu/fix_comments
fix some typos in comments in store.go
2014-02-04 11:46:29 -08:00
b61cf9cb8e fix a format error in libraries-and-tools.md 2014-02-04 14:30:40 -05:00
8d2a8e1c7a fix some typos in comments in store.go 2014-02-04 14:17:44 -05:00
72b393ca53 Merge pull request #519 from philips/fixup-server-tls-client-config
fix(server): fix client certificate verification
2014-02-03 17:33:45 -08:00
6398206e4f Merge pull request #1 from bcwaldon/fixup-server-tls-client-config
test(TLS): Add test coverage for etcd TLS
2014-02-03 17:33:34 -08:00
226c20c097 test(TLS): Add test coverage for etcd TLS 2014-02-03 17:32:24 -08:00
0b9c5c975e fix(test.sh): use . not source 2014-02-02 17:01:21 -08:00
272dc343ef Merge pull request #520 from philips/use-goven
Use goven for all third party dependencies
2014-02-02 16:58:07 -08:00
d7d20d1c3d bump(github.com/stretchr/testify): 9cc77fa25329013ce07362c7742952ff887361f2 2014-02-02 16:57:36 -08:00
2557992b70 fix(tests): use correct raft package 2014-02-02 16:57:36 -08:00
33be0e09fe fix(build/test.sh): use new GOPATH setup 2014-02-02 16:57:36 -08:00
13b6c1e684 chore(*): make everything use goven
for i in github.com/BurntSushi/toml github.com/coreos/go-etcd/etcd github.com/coreos/go-log/log github.com/gorilla/context github.com/rcrowley/go-metrics bitbucket.org/kardianos/osext github.com/coreos/go-systemd/journal github.com/coreos/raft code.google.com/p/goprotobuf/proto ; do goven  -copy -rewrite $i; done
2014-02-01 23:44:18 -08:00
ea8a353545 chore(*): gofmt everything 2014-02-01 23:44:10 -08:00
0566bf2d5d Revert "Fix compile bug in peer_server_handlers.go "
This reverts commit e1ed380f04.
2014-02-01 20:09:53 -08:00
93a129e55a Merge pull request #516 from augustoroman/patch-1
fix(server compilation): compile bug in peer_server_handlers.go
2014-02-01 19:52:08 -08:00
58e1f12240 doc(server): some basic docs on the tls_config object
This should be refactored but something to remember while refactoring.
2014-01-31 17:08:37 -08:00
0fa6d38574 fix(server): fix client certificate verification
In d0c4916fe9 the TLS CA Certificate
verification broke.

This was bisected using the following basic test:

```
./bin/etcd -f -name machine0 -data-dir machine0 -ca-file=/tmp/ca/ca.crt -cert-file=/tmp/ca/server.crt -key-file=/tmp/ca/server.key.insecure
```

And in another window doing

```
curl --key /tmp/ca/server2.key.insecure  --cert /tmp/ca/server2.crt -k -L https://127.0.0.1:4001/v2/keys/foo -XPUT -d value=bar -v
```

Before merging this PR there are a few things that need to be fixed up:

1) Tests for client certs both positive and negative
2) Refactor (or at least documentation of) the TLSConfig types
2014-01-31 16:56:15 -08:00
e1ed380f04 Fix compile bug in peer_server_handlers.go
resp.Success is a func() bool, not a bool.  Call it.
2014-01-30 15:31:36 -08:00
354a91290e feat(prevNode): add test for prevNode 2014-01-29 17:52:25 -08:00
3ec7004421 feat(prevNode): add "prevNode" to "Set" response 2014-01-29 17:30:33 -08:00
a542a7804b Merge pull request #508 from jonboulle/master
Various cleanup to API documentation
2014-01-25 13:06:29 -08:00
03ff4c8b76 Missed one 2014-01-25 12:22:37 -08:00
7992448f6a Various cleanup to API documentation 2014-01-25 12:08:57 -08:00
9a0ddb3760 feat(server): log on snapshot success or failure
lila.local: snapshot of 12 events completed at index 479
lila.local: snapshot of 12 events at index 491 attempted and failed: handling snapshot
2014-01-24 07:13:01 -08:00
7ee7e910eb feat(*): enable snapshots by default
Ben recently added test coverage for snapshots so we should enable it in
etcd. Lets do this.

1d66f6a111
2014-01-23 20:53:22 -08:00
281b0e7e59 Merge pull request #506 from philips/add-freebsd-docs
feat(Documentation): add instructions on freebsd
2014-01-23 16:44:38 -08:00
50e6256058 feat(Documentation): add instructions on freebsd 2014-01-23 16:43:38 -08:00
1b00c449a5 Revert "Better error message when setting values on directories"
This reverts commit d13dd50d51.
2014-01-23 11:22:11 -08:00
9848072d21 Merge pull request #487 from intjonathan/patch-1
English clarity in filesystem documentation.
2014-01-23 04:03:05 -08:00
2652e46d66 Merge pull request #504 from kelseyhightower/master
Better error message when setting values on directories
2014-01-23 03:59:40 -08:00
d13dd50d51 Better error message when setting values on directories
Without this commit etcd returns the following error message when
setting values on directories:

    {
      "errorCode":102,
      "message":"Not a file",
      "cause":"/postgres",
      "index":2
    }

While the above error message is accurate it's not very descriptive.
This commit adds a new error code/message which better describes why the
write operation failed. etcd now returns the following:

    {
      "errorCode":109,
      "message":"Cannot set value on directory",
      "cause":"/postgres",
      "index":2
    }
2014-01-22 23:02:33 -08:00
8fece992eb Update filesystem documenation for clarity. 2014-01-22 20:43:54 -08:00
3264b51a74 Merge pull request #501 from benbjohnson/snapshot-documentation
Add snapshot documentation
2014-01-22 15:26:53 -08:00
0692097a73 Add snapshot documentation. 2014-01-22 16:06:25 -07:00
19ef1042d6 Merge pull request #497 from philips/store-bench-no-rand
fix(store/store_bench): don't use rand
2014-01-22 13:19:04 -08:00
394e651591 Merge pull request #484 from bcwaldon/server-config
Refactor server init code
2014-01-22 11:39:27 -08:00
2fe22f1890 refactor(servers): emit http.Handlers from *Server 2014-01-22 11:17:58 -08:00
089021ca6d refacotor(transporter): make TLS config explicit 2014-01-22 11:17:58 -08:00
f158dfcd77 refactor(peerserver): Remove PeerServerConfig.Path 2014-01-22 11:17:58 -08:00
19980a7033 refactor(peerserver): remove timeouts from PeerServerConfig 2014-01-22 11:17:58 -08:00
a7d9efa900 refactor(server): Remove ServerConfig struct 2014-01-22 11:17:58 -08:00
0abd860f7e refactor(server): drop Serve code; rename cors object
* server/cors.go renamed to http/cors.go
* all CORS code removed from Server and PeerServer
* Server and PeerServer fulfill http.Handler, now passed to http.Serve
* non-HTTP code in PeerServer.Serve moved to PeerServer.Start
2014-01-22 11:17:57 -08:00
5c3a3db2d8 refactor(server): treat Server as an http.Handler 2014-01-22 11:17:57 -08:00
074099a1b2 refactor(cors): Simplify corsInfo struct 2014-01-22 11:17:57 -08:00
a2ee620394 refactor(raft): init raft transporter & server in main 2014-01-22 11:17:56 -08:00
ffa2b07dc4 refactor(transporter): Pass in everything the transporter needs 2014-01-22 11:17:43 -08:00
60bbc57aeb refactor(transporter): pass in timeouts 2014-01-22 11:17:43 -08:00
86718167e8 refactor(peer_server): move stats construction to factories 2014-01-22 11:17:42 -08:00
7bd4d05a38 refactor(peer-server): move listener init out of peer_server.go 2014-01-22 11:17:41 -08:00
d0c4916fe9 refactor(server): move listener init out of server.go 2014-01-22 11:17:26 -08:00
91fc6aabd2 chore(gofmt): Run gofmt 2014-01-22 11:17:26 -08:00
c0ff8f6026 chore(imports): Shift around some imports 2014-01-22 11:17:26 -08:00
a93d60be90 refactor(cors): Break apart CORS data and middleware 2014-01-22 11:17:26 -08:00
c47760382e refactor(Server): Use a config struct in Server 2014-01-22 11:17:25 -08:00
9c8a23c333 refactor(PeerServer): Use a config struct in PeerServer 2014-01-22 11:17:03 -08:00
91f768f9ae refactor(cors): Rename cors_handler.go to cors.go 2014-01-22 10:59:12 -08:00
6c48466bfe Merge pull request #500 from drusellers/patch-2
adding .net client to the matrix
2014-01-22 09:26:44 -08:00
5bf667851c adding .net client to the matrix 2014-01-22 10:00:22 -06:00
d77e3a203f Merge pull request #499 from drusellers/patch-1
adding .net client
2014-01-22 07:29:09 -08:00
c32dfa013d adding .net client 2014-01-22 09:24:54 -06:00
6b70efbe30 Merge pull request #498 from tobz/actually-hidden-keys
fix(store): properly hide hidden keys from watchers, not just gets
2014-01-22 06:52:31 -08:00
641edd4e6e test(store): group together all store tests that deal with hidden keys 2014-01-22 09:29:53 -05:00
823fdfab12 fix(store): make isHidden see if any portion of the path is hidden, not just the last element 2014-01-22 09:29:33 -05:00
0cacb6cba4 test(store): exercise watchers receiving notifications of non-hidden keys within hidden directories 2014-01-22 09:20:57 -05:00
7a948746a8 fix(store): move logic to handle whether or not to notify (re: hidden keys) entirely into watcher hub 2014-01-22 09:02:42 -05:00
1273875a00 fix(mod/lock): Use CreatedIndex in the first node to watch
ModifiedIndex in the lock directory is not incremented and the event
store has only 1000 histories for now.

Acquiring a lock is not queued while (index - ModifiedIndex) > 1000 and
prevIndex exists.
2014-01-22 20:00:15 +09:00
4c2942f9f9 fix(mod/lock): Use dedicated channel to shutdown goroutine properly
If closeChan is available and stopWatchChan was closed by defer
select selects a single channel randomly. This causes a panic sending to closed
channel.
2014-01-22 19:42:07 +09:00
139f59f7d1 fix(store): properly hide hidden keys from watchers, not just gets 2014-01-21 20:26:56 -05:00
80c22a4fb2 fix(store/store_bench): don't use rand
rand just introduces more noise to the results, don't use it.
2014-01-21 17:01:26 -08:00
a417782151 Merge pull request #483 from bcwaldon/metrics
Integrate go-metrics
2014-01-21 14:17:03 -08:00
e87f3231a1 Merge pull request #496 from bcwaldon/droneio
test(ci): Replace travis.ci with drone.io
2014-01-21 12:28:52 -08:00
fe39288ebf test(ci): Replace travis.ci with drone.io 2014-01-21 11:50:36 -08:00
97bc5b260d feat(metrics): Publish peer heartbeat events as metrics 2014-01-21 11:44:22 -08:00
47f24d1088 bump(github.com/coreos/raft): bf7accb84ce4fe446983abffe00dd18a6b8cbc18 2014-01-21 11:18:50 -08:00
3a75d0a465 Merge pull request #493 from xiangli-cmu/bench_watcher
test(store_bench_test.go) add watch bench
2014-01-21 07:35:18 -08:00
17c8f6d2e8 test(store_bench_test.go) add watch bench 2014-01-21 06:51:40 -05:00
7eaad5c8e0 feat(metrics): enable some metrics; push to graphite
* -trace flag controls whether or not to enable metrics-gathering
  and the /debug/* HTTP endpoints
* -graphite-host flag controls where metrics should be sent
* timer.ae.handle metric tracks execution time of AppendEntriesRequest
2014-01-20 15:39:36 -08:00
3e7c2dff96 feat(metrics): Add documentation and contrib scripts 2014-01-20 15:37:31 -08:00
14c96306a0 feat(metrics): Add metrics pkg 2014-01-20 13:32:42 -08:00
d122ed3bcd Merge pull request #492 from rwindelz/fix-ttl
fix(store): TTL should range 1..n rather than 1..n+1
2014-01-20 09:28:38 -08:00
451e874696 Merge pull request #480 from xiangli-cmu/store_bench
feat(store/store_bench_test.go) add a benchmark for set operation
2014-01-20 07:00:54 -08:00
290ca6bbc7 Merge pull request #491 from jkakar/master
Trivial typo fix in API documentation
2014-01-19 21:53:26 -08:00
a2e5bae951 fix(store): TTL should range 1..n rather than 1..n+1
was experiencing intermittent functional test fails where TTL was eg 101
when 100 was expected
informal testing on a windows platform shows Go times resolving to the
nanosecond but with an accuracy of approximately 1 millisecond
I believe some of the functional test steps would run in under a
millisecond and cause the TTL to be recomputed with the same time.Now()
value resulting in a TTL that was +1 from the expected
2014-01-19 21:45:53 -08:00
054de85da2 feat(*): initial commit 2014-01-19 12:25:11 -08:00
823e744ed9 - Fix typo. 2014-01-18 18:28:33 -08:00
35c89c7537 feat(metrics): Add github.com/rcrowley/go-metrics 2014-01-17 16:12:18 -08:00
77887e8253 fix(bench): remove trailing slash
Remove trailing slash. This works around
https://github.com/coreos/go-etcd/issues/82
2014-01-17 16:03:46 -08:00
1e6c0dee24 Merge pull request #488 from robszumski/master
feat(docs): Prepare to sync security doc to CoreOS website
2014-01-17 13:11:49 -08:00
e89e42382a fix(docs): remove header 2014-01-17 13:06:59 -08:00
184a5901e6 feat(docs): modify for sync to CoreOS website 2014-01-17 12:25:36 -08:00
6f8b0dc7ef add delete bench 2014-01-17 15:18:11 +08:00
21f0c6f9d4 feat(store_bench) add set bench for different value sizes 2014-01-17 14:19:31 +08:00
bd2b3793a6 Merge pull request #486 from philips/document-profiling-binary
fix(Documentation/profiling): note about using the right binary
2014-01-16 17:09:43 -08:00
25caac370f bump(github.com/coreos/go-log): 70d039bee4b0e389e5be560491d8291708506f59 2014-01-16 16:56:10 -08:00
0c8329a3fb fix(scripts/test-cluster): use v2 flags and find the path for etcd 2014-01-16 16:40:49 -08:00
444b5d329c fix(Documentation/profiling): note about using the right binary 2014-01-16 15:51:30 -08:00
7a7f6aea00 Merge pull request #479 from philips/add-debug-endpoint
add-debug-endpoint
2014-01-16 11:28:52 -08:00
b226b14eb2 add mem stats for sets benchmark 2014-01-16 16:06:18 +08:00
72b165ad4c Merge pull request #482 from bcwaldon/etcdbench
etcdbench -endpoint flag; error reporting
2014-01-15 22:37:33 -08:00
bd04905154 fix(etcdbench): Check for error in etcdbench set operation 2014-01-15 22:33:34 -08:00
471c40735c feat(etcdbench): Add -endpoint flag to etcdbench 2014-01-15 22:33:25 -08:00
c2d1dc4f51 add a setWithJson test 2014-01-16 09:16:33 +08:00
000290dc94 Merge pull request #481 from philips/fixup-test-cluster
fix(scripts/test-cluster): use ./bin/etcd now
2014-01-15 17:15:53 -08:00
3f3a324108 fix(scripts/test-cluster): use ./bin/etcd now 2014-01-15 17:15:18 -08:00
77477b3e43 feat(store/store_bench_test.go) add a benchmark for set operation of store pkg
We randomly generage N 3 level keys. We benchmark the speed of setting each key into etcd store.
2014-01-16 09:03:42 +08:00
c2077ed0b6 feat(server): add net/http/pprof endpoints
Add some basic profiling endpoints over http to start digging into
memory and request latencies.
2014-01-15 15:03:29 -08:00
ceefa98c76 Merge pull request #476 from ekristen/master
fixes bug with the etcd docker image not being able to run
2014-01-15 10:39:38 -08:00
d3fb9f0f0f etcd is in the bin directory, fixes bug with the docker image not working 2014-01-15 12:46:09 -05:00
d9088a5f18 Merge pull request #473 from bcwaldon/fix-peer-timeouts
Use election and heartbeat timeouts when building peer transporter
2014-01-15 02:11:40 -08:00
87113f985f Merge pull request #472 from benbjohnson/fix-error-codes
Fix mod/lock and mod/leader return error codes.
2014-01-15 01:14:59 -08:00
4da933e4a4 Merge pull request #475 from philips/fixup-travis
fix(travis): fixes from the third_party.go merge
2014-01-14 22:41:34 -08:00
56909bb6a3 fix(travis): fixes from the third_party.go merge 2014-01-14 22:36:40 -08:00
ecd73acc01 Merge pull request #460 from philips/use-third-party.go
chore(build): use third_party.go
2014-01-14 22:16:15 -08:00
e2e0853492 fix(server/release_version): checkin to git 2014-01-14 22:14:47 -08:00
0f97e3528a chore(build): use third_party.go
use the third_party.go project to replace our update script. This
requires moving a few things around and gets rid of a few annoying bugs:

- You can now bump individual packages
- A new src directory isn't created on build
- Less shell scripting!
- Things get built into ./bin/
2014-01-14 22:14:47 -08:00
89074ffcea Merge pull request #474 from jpetazzo/switch-to-go-1.2
Download and build Go 1.2 in the Dockerfile.
2014-01-14 21:54:14 -08:00
6b14fe7747 Download and build Go 1.2 in the Dockerfile.
The dependency BurntSushi/toml actually needs Go 1.2, because it uses
encoding.TextUnmarshaler, which didn't exist in Go 1.1. Since the PPA
that we use doesn't have Go 1.2 yet, we will use the same method as
Docker, i.e. download Go source tarball and compile it.
2014-01-14 18:19:37 -08:00
48e36422b5 chore(gofmt): Run gofmt on server/config.go 2014-01-14 09:18:09 -08:00
32df6f92fc fix(peer): Pass peer server timeouts through factory
The peer's heartbeat and election timeouts are needed to build
the transporter in the factory method.
2014-01-14 09:18:03 -08:00
cde184fdbf Fix mod/lock and mod/leader return error codes. 2014-01-14 07:57:30 -07:00
97f1363afa Merge pull request #470 from ranjib/consistent_curl_examples
style(Documentation/api): keep curl based examples consistent and correct
2014-01-12 21:54:39 -08:00
8b8b8d74fe style(Documentation/api): keep curl based examples consistent and correct
- fix curl examples where `http://` was missing.
- consistent passing HTTP method parameter (all examples now have -X ACTION at
 the end or the url, GET is implicit)
- quote url when it contains `&` , instead of escaping
2014-01-11 20:51:25 -08:00
5821a1390a Merge pull request #466 from bcwaldon/verbosity
Add more control over verbose logging
2014-01-10 14:30:32 -08:00
ae2130952b fix(config): Set VeryVerbose properly 2014-01-10 11:45:04 -08:00
b0cdf73565 feat(logging): Add VeryVeryVerbose opt to control raft trace info
Set very_very_verbose=true in a config file or use the -vvv CLI
option to get raft trace logs in addition to etcd debug logs.
2014-01-10 11:45:04 -08:00
c64c739fab Merge pull request #461 from xiangli-cmu/stream_watcher
feat(stream watchers) add stream watcher support
2014-01-10 08:42:31 -08:00
feb6f2dad7 Merge pull request #465 from philips/add-note-that-the-dahboard-is-compiled-in
feat(Documentation/modules): note the dashboard is compiled in
2014-01-10 06:10:36 -08:00
2c42271cea Merge pull request #18 from cenkalti/li
feat(stream watchers) fix locking issue
2014-01-10 06:07:14 -08:00
8597904bc2 feat(stream watchers) fix locking issue 2014-01-10 16:04:23 +02:00
227ea57c37 Merge pull request #17 from cenkalti/li
feat(stream watchers) disable double chunking
2014-01-10 05:17:44 -08:00
5b924dfd4e feat(stream watchers) disable double chunking 2014-01-10 15:09:35 +02:00
181805bb87 feat(Documentation/modules): note the dashboard is compiled in 2014-01-09 17:57:14 -08:00
63c06d6c79 Merge pull request #463 from robszumski/master
feat(docs): make clustering examples more complete
2014-01-09 17:07:12 -08:00
782166dadd feat(docs): make clustering examples more complete 2014-01-09 14:37:04 -08:00
7bfd11679b Merge pull request #462 from xiangli-cmu/sync_cnt_for_snapshot
fix(snapshot) count num of log entries rather than etcd transcations
2014-01-09 05:29:18 -08:00
f250649a5e fix(snapshot) count num of log entries rather than etcd transcations 2014-01-09 21:28:09 +08:00
629a827ee2 Merge pull request #16 from cenkalti/li
feat(stream watchers) end streaming if too many notifications
2014-01-09 04:21:26 -08:00
c247d807af feat(stream watchers) end streaming if too many notifications 2014-01-09 14:15:36 +02:00
22a25a18b3 feat(stream watchers) add stream watcher support 2014-01-09 15:28:33 +08:00
6b77b94127 Merge pull request #420 from benbjohnson/logging
Logging
2014-01-08 21:36:52 -08:00
2bfb8f5e4f Merge pull request #418 from xiangli-cmu/cancel_watcher
cancel watcher
2014-01-08 21:34:32 -08:00
dd6623be2f Merge pull request #454 from dsoprea/master
Added HTTPS for python-etcd-client.
2014-01-08 21:32:59 -08:00
fa3b4a7941 refactor(watcher) change newWatcher to Watch 2014-01-09 13:29:04 +08:00
8047cfd48e Merge pull request #447 from robszumski/master
Prepare docs to be synced to website
2014-01-08 16:38:44 -08:00
53477af1eb Merge branch 'master' of https://github.com/coreos/etcd into logging 2014-01-08 16:50:51 -07:00
355bd6df9b Fix Travis CI. 2014-01-08 16:41:01 -07:00
8d25dac1ba Revert test.sh changes. 2014-01-08 16:21:22 -07:00
b47042634a Add ThresholdMonitorTimeout. 2014-01-08 15:51:13 -07:00
e02441acb1 Merge pull request #455 from philips/fixup-cas-header
chore(Documentation/api): introduce acronym later in the text
2014-01-08 10:46:46 -08:00
ddd8e85146 chore(Documentation/api): introduce acronym later in the text 2014-01-08 10:46:05 -08:00
68546de2cb Merge pull request #444 from philips/document-stats-api
Documentation: document the stats API
2014-01-08 10:41:29 -08:00
7553a92232 feat(Documentation/api): document the store statistics 2014-01-08 10:40:57 -08:00
c7e642baa2 fix(Documentation/api): fixup the names in stats
This was fixed in #449
2014-01-08 10:36:44 -08:00
0377ea751d Added additional separator column. 2014-01-08 10:48:29 -05:00
5efad911d5 Added HTTPS for python-etcd-client. 2014-01-08 09:57:45 -05:00
d38a260e00 Merge pull request #452 from xiangli-cmu/fix_client-matrix_link
doc(Documentation/libraries-and-tools.md) fix link to clients-matrix
2014-01-07 22:32:51 -08:00
0cc2e8887f doc(Documentation/libraries-and-tools.md) fix link to clients-matrix 2014-01-08 14:26:56 +08:00
3736b7678a Merge pull request #449 from xiangli-cmu/fix_stats
fix(peer_server.go) init name field and update leader field
2014-01-07 19:21:30 -08:00
e373c9ac8c fix(docs): suggest cors flag for using dashboard 2014-01-07 17:08:15 -08:00
5f2d9b38dc fix(docs): reference correct cors flag 2014-01-07 17:03:45 -08:00
a7eeb01bc8 fix(docs): reference correct cors flag 2014-01-07 17:03:11 -08:00
c26215a740 Merge pull request #450 from dsoprea/master
Updated client matrix.
2014-01-07 16:06:10 -08:00
4e8828c5c4 Merge pull request #451 from philips/use-the-right-port
fix(README): use 4002 not 4001
2014-01-07 15:58:20 -08:00
2dde2cbb6f fix(README): use 4002 not 4001
The default port is 4001 not 4002. Fix this.
2014-01-07 15:57:18 -08:00
88e0263d08 Add heartbeat and timeout threshold loggers. 2014-01-07 16:17:48 -07:00
28652ed7af Updated client matrix. 2014-01-07 00:49:28 -05:00
60c2680bfd fix(peer_server.go) init name field and update leader field 2014-01-07 12:30:20 +08:00
9a8bd96ad3 feat(Documentation/api): add a statistics section 2014-01-05 23:06:56 -08:00
66271fe986 chore(Documentation/api): remove some whitespace 2014-01-05 23:05:15 -08:00
1caa3245e6 feat(Documentation/api): add some intro material
add some intro material and normalize the headers to the rest of the
coreos/docs.
2014-01-05 23:04:27 -08:00
04720bd8bf Merge pull request #442 from philips/remove-ETCD_WEB_URL
chore(server): remove web url
2014-01-05 20:41:28 -08:00
ecc96df699 chore(server): remove web url
web URL is not longer used so remove it from tests and configuration
documents.
2014-01-05 20:39:39 -08:00
0b47d6888d Merge pull request #441 from lavagetto/matrix
docs(clients-matrix.md): Introducing the library features matrix.
2014-01-05 20:27:10 -08:00
e9b85264ab docs(clients-matrix.md): Introducing the library features matrix.
As support for etcd features is very uneven between different clients,
a feature matrix can help application developers to understand what a
client library can offer them, and also help client libraries
developers to understand what they should work on. I assessed the
features of all client libraries by looking at their master branch on
github, to the best of my knowledge.
2014-01-05 11:30:11 +01:00
d397e83a05 Merge pull request #440 from philips/splitup-README
feat(README): splitup the sections into individual files
2014-01-04 17:59:17 -08:00
801b642dea fix(Documentation): fixup headers
fixup the headers on the api and tuning sections
2014-01-04 17:58:39 -08:00
e7527ebb45 fix(README): link to the configuration file too 2014-01-03 14:39:23 -08:00
bfde27a99d feat(README): splitup the sections into individual files
The README is getting rather large so split it into individual files.

The next step will be rendering these into HTML pages with a TOC so that
they are a bit more navigable.

What do people think of this?
2014-01-03 14:37:53 -08:00
c65f8fc7ad Merge pull request #439 from lavagetto/master
docs(README.md): update client libraries and projects.
2014-01-03 10:29:12 -08:00
547c05685e Merge pull request #438 from robszumski/master
feat(docs): add cluster size guide
2014-01-03 10:28:59 -08:00
5794d70881 docs(README.md): update client libraries and projects.
This commit adds information about API version support for all
clients - clearly listing which clients support API v2.

Also, a new nodejs client is added, and a new project as well.
2014-01-03 17:34:18 +01:00
009b84c5fc feat(docs): add cluster size guide 2014-01-02 16:11:25 -08:00
b5426d967e Fix TOML. 2014-01-02 16:48:50 -07:00
60827ebd5a bump(code.google.com/p/go.net): d4afe896f927+ 2014-01-02 16:41:38 -07:00
ae10b6226d bump(github.com/gorilla/mux): 9ede152210fa25c1377d33e867cb828c19316445 2014-01-02 16:41:33 -07:00
d32fd00bbb bump(github.com/coreos/go-systemd): 05a794e41e912eca8ebe1538241815f80da76d69 2014-01-02 16:41:31 -07:00
7c29d5bf5c bump(github.com/coreos/go-log/log): 2014-01-02 16:41:31 -07:00
f37d9df118 bump(github.com/coreos/go-etcd): 9de519a68a870466f217c35f476ba658f1694bbe 2014-01-02 16:41:28 -07:00
7da85d66fd bump(github.com/coreos/raft): 20e384681d014100733dd69d287fe254d685f319 2014-01-02 16:41:27 -07:00
cf656ccfdd bump(github.com/BurntSushi/toml): 2fffd0e6ca4b88558be4bcab497231c95270cd07 2014-01-02 16:41:25 -07:00
d7087ed61a Merge branch 'master' of https://github.com/coreos/etcd into logging 2014-01-02 16:30:09 -07:00
98351b9756 Merge pull request #436 from thwarted/help-version-fixups
docs(server/config.go): minor formatting changes
2014-01-02 13:50:19 -08:00
5260c7c939 Merge pull request #434 from rwindelz/master
fix (scripts/release-version.ps1): fix windows build
2014-01-02 12:39:15 -08:00
78e2fc1bc8 Merge pull request #437 from bcwaldon/README-indexes
chore(README): Expand README with more info about indexes
2014-01-02 12:33:49 -08:00
c17ad07bdb chore(README): Expand README with more info about indexes 2014-01-02 11:35:17 -08:00
5b105ed156 fix deprecated option tests 2014-01-02 11:11:27 -06:00
af3240fa18 docs(server/config.go): minor formatting changes
When -version or -help are given, don't warn about having to derive
the data directory name.
Print warnings about deprecated options on separate lines so the log
isn't screwy.
2014-01-02 04:30:38 -06:00
45b4d6d194 fix(build.ps1): not required to be admin to run build in windows
mklink /D in windows requires elevated privilege (Runas Administrator),
'/J' to create a directory junction point runs with user privilege
use an explicit fully qualified path for junction target
2014-01-01 22:23:07 -08:00
04ad7a91dd fix (scripts/release-version.ps1): fix windows build
fix reflects changes made in commit
7670c85d70
2014-01-01 21:16:40 -08:00
fd0d0813ce Merge pull request #432 from btipling/fix_trimsplit
Trimsplit Wasn't using separator, more efficient.
2014-01-01 13:46:08 -08:00
5a4c41be37 Don't copy strings. 2014-01-01 13:44:04 -08:00
57f94f65a8 Merge pull request #433 from xiangli-cmu/prevNode
feat(node_extern.go) add prevNode field
2014-01-01 12:59:41 -08:00
189b98c03f refactor(node_extern.go) remove unused prevValue field 2014-01-01 20:01:29 +08:00
f46fdbf078 feat(node_extern.go) add prevNode field 2014-01-01 19:50:07 +08:00
ed2d7d64cd Trimsplit Wasn't using separator, more efficient. 2013-12-31 09:13:41 -08:00
cc10b1084d Merge branch 'master' of https://github.com/coreos/etcd into logging
Conflicts:
	tests/functional/simple_snapshot_test.go
2013-12-30 16:19:57 -07:00
c49711ae2c Merge pull request #429 from philips/README-remove-prevValue
fix(README): remove prevValue references in the README
2013-12-30 13:53:17 -08:00
b7be38da12 Merge pull request #430 from philips/remove-old-release-version
chore(release_version): remove this unused file
2013-12-30 13:52:44 -08:00
6b8b6cda66 Merge pull request #431 from btipling/master
Weird grammar, not sure I fixed it well enough.
2013-12-30 13:06:09 -08:00
850cbf6018 Weird grammar, not sure I fixed it well enough. 2013-12-30 12:49:19 -08:00
dcabc6ae80 chore(release_version): remove this unused file
Fixes #425
2013-12-30 11:37:32 -08:00
1ab3db18bb fix(README): remove prevValue references in the README
We plan on adding a PrevNode field in the Response object but it hasn't
been needed thus far. Discussion was here:

http://thread.gmane.org/gmane.comp.distributed.etcd/56

Fixes #428
2013-12-30 10:44:35 -08:00
8edc1f30d9 Merge pull request #424 from xiangli-cmu/fix_lock_doc
docs(README.md) fix wrong index value in lock section
2013-12-29 17:26:26 -08:00
5266968b61 docs(README.md) fix wrong index value in lock section 2013-12-30 09:24:18 +08:00
9bd36f173e Merge pull request #422 from dsoprea/master
Add documentation for enumerating sorted, in-order keys.
2013-12-29 10:09:01 -08:00
a9e20aecc6 Raft fixes, integrate logging. 2013-12-29 10:40:10 -07:00
e66f6d76e6 Modified doc. 2013-12-28 11:38:59 -05:00
c62603ba73 Added documentation for sorted listings. 2013-12-28 11:37:32 -05:00
4692d6e966 Merge pull request #421 from philips/README-api-versioning
feat(README): add an API versioning section
2013-12-28 07:33:13 -08:00
9049a2afd5 feat(README): add an API versioning section
Based on a question on the mailing list. Add a section about API
versioning.
2013-12-28 07:13:41 -08:00
bbbf8fd574 fix(watcher_hub.go) decrease count when remove a watcher 2013-12-28 15:51:16 +08:00
d66dc3c1c7 refactor(watcher_hub.go) refactor notifyWatchers() 2013-12-28 15:49:05 +08:00
59ccefee0f fix(watchhub.go) add a lock to protect the hashmap 2013-12-28 14:55:50 +08:00
3b485e20bb Merge pull request #419 from kula/fix-leader-documentation
fix(README): fixup leader docs
2013-12-27 22:48:31 -08:00
44af8ea190 bump(github.com/coreos/raft): ca61124b291fe38a2ab592a8b42f1423e3c31cc4 2013-12-27 15:24:37 -07:00
2504c4ad34 bump(code.google.com/p/goprotobuf): dd4df9b5c0cf 2013-12-27 15:23:35 -07:00
d447ba52ad fix(README): fixup leader docs
The leader module uses PUT to set a leader value and DELETE to delete one. Fix
the documents to reflect that.
2013-12-27 15:15:19 -05:00
5e499456f0 init cancel watcher 2013-12-26 22:06:15 +08:00
e96234382a Merge pull request #417 from philips/fixup-readme
fix(README): Remove excress backticks
2013-12-25 23:06:25 -08:00
78e2a27ee0 fix(README): Remove excress backticks 2013-12-25 19:28:43 -08:00
715b4d7bfc Merge pull request #408 from xiangli-cmu/compareAndDelete
Compare and delete
2013-12-25 13:16:27 -08:00
c36f306a1d test(delete_handler_test.go) fix inconsistent between test case and comments 2013-12-25 19:05:40 +08:00
bfa7d54b02 refactor(store.go) handle short condition first 2013-12-25 19:01:04 +08:00
4ff773aaaf bump(github.com/coreos/raft): 0c36c972a25343e7e353257284ef6df5c8676a3d 2013-12-23 16:08:10 -07:00
0611c81e88 bump(code.google.com/p/go.net): 127da548775d 2013-12-23 16:02:02 -07:00
6b4f7cf861 bump(github.com/coreos/go-etcd): d2eb551cc057fdaf9848d6130292187bb1368208 2013-12-23 16:01:54 -07:00
51406a3582 bump(github.com/coreos/raft): 0409b22a50cb2576318f294eba5c1092316dbea1 2013-12-23 16:01:53 -07:00
9ebac0b9fd bump(github.com/BurntSushi/toml): da57f3b4c85ec56cf139d7dc05396fa98a040773 2013-12-23 16:01:51 -07:00
4acfc26c5e Add event-based debugging output. 2013-12-23 16:01:05 -07:00
5271378fc2 Merge pull request #416 from drnic/patch-1
[readme] references to BOSH releases using etcd
2013-12-23 11:14:28 -08:00
5ab2f5454c [readme] references to BOSH releases using etcd 2013-12-23 09:49:24 -08:00
4748da1e09 Merge pull request #415 from philips/fix-lock-docs
fix(README): fixup lock docs
2013-12-23 05:53:23 -08:00
c3b4d10b74 fix(README): fixup lock docs
I thought that @benbjohnson had changed the lock "value" to "name" but
that doesn't look to be the case. It is OK, just fix the docs.
2013-12-22 22:03:07 -08:00
f026d1c14e Merge pull request #414 from philips/getting-started
fix(README): we are building containers too
2013-12-22 20:43:19 -08:00
e30bf19684 fix(README): we are building containers too
We are building a docker container now too so don't get specific about
just the binary.

I thought about adding instructions to the README but lets just keep
following the pattern of putting version getting started guides on the
release page.
2013-12-22 20:13:02 -08:00
d4553714d9 Merge pull request #413 from philips/event_history
fix(event_history): fix a bug in event queue
2013-12-22 15:48:31 -08:00
e1d909eb0e test(store/event_test): add a test for a full queue 2013-12-22 15:42:51 -08:00
317b34f4a0 refactor(store/event_history): cleanup some comments 2013-12-22 15:42:10 -08:00
0937b4d266 refactor(event_history.go) remove the extra logic 2013-12-22 15:42:10 -08:00
ef988020b7 fix(event_history) fix a bug in event queue 2013-12-22 15:42:10 -08:00
70c8c09360 Merge pull request #412 from mojotech/cas/403-proper-http-statuses
Use more appropriate HTTP status codes for error cases.
2013-12-21 20:29:40 -08:00
d89fa131ab feat(v2/errors): Use more appropriate HTTP status codes for error cases.
This commits adds test coverage for all the error and non-error cases
described below, but only the behavior of the 403, 404 and 412 cases
are changing in this commit.

When setting a key results in a new resource, we asset an HTTP status
code of 201 (aka "Created").

When attempting to get a resource that doesn't exist, we assert an
HTTP status code of 404 (aka "Not Found").

When attempting to delete a directory without dir=true, or a non-empty
directory without recursive=true, but the request is otherwise valid,
we assert an HTTP status code of 403 (aka "Forbidden").

When a precondition (e.g. specified by prevIndex, or prevValue) is not
met, but the request is otherwise syntactically valid, we assert an
HTTP status code of 412 (aka "Precondition Failed").  However,
prevExist is handled slightly differently.  If prevExist=false fails,
then this is treated like a failed precondition, so it should use
PreconditionFailed.  But, if prevExist=true fails, then this is
treated like other requests that require the existence of the
resource, and uses NotFound if the resource doesn't exist.

We continue to assert an HTTP status code of 400 when the request is
syntactically invalid (e.g. when prevIndex=bad_index).
2013-12-21 21:39:19 -05:00
3f85829e87 fix(v2/tests): make comments and tests agree about what's being tested
In cases where the comments were incorrect, this changes them to agree
with the tests.  In cases where the comments were correct, this extends
the tests to cover the behavior described in the comment.
2013-12-21 21:39:19 -05:00
3cde996d21 refactor(v2/tests): don't repeat construction of full test URL 2013-12-21 21:39:19 -05:00
39fb266776 fix(error.go): fix typo in comment 2013-12-21 21:39:19 -05:00
557ffbb861 Merge pull request #411 from xiangli-cmu/bench
Bench
2013-12-21 14:16:08 -08:00
ddcf3975ed fix bench 2013-12-21 16:44:28 +08:00
cc88215b46 fix(bench): initial commit 2013-12-20 15:19:02 -08:00
3bd2d0da88 bump(code.google.com/p/goprotobuf): 8ba95f2a7335 2013-12-20 15:39:30 -07:00
b7854354ff bump(code.google.com/p/go.net): a1b606ad6242 2013-12-20 15:39:29 -07:00
80bc68eb49 bump(github.com/stretchr/testify/mock): 2013-12-20 15:39:26 -07:00
8c8ab6a4cb bump(github.com/gorilla/mux): 9ede152210fa25c1377d33e867cb828c19316445 2013-12-20 15:39:24 -07:00
985db7838c bump(github.com/gorilla/context): a08edd30ad9e104612741163dc087a613829a23c 2013-12-20 15:39:23 -07:00
04c98d0a75 bump(github.com/coreos/go-systemd): 700560af03f8e1df35839041745c9f1fccba7c72 2013-12-20 15:39:22 -07:00
53436af899 bump(github.com/coreos/go-etcd): 925b981b19b370a2fe073c2395e8f76cfc241124 2013-12-20 15:39:19 -07:00
81a73dbc80 bump(github.com/coreos/raft): ac7be58b1bec49dfcfc7216df4ae27173da1fa57 2013-12-20 15:39:17 -07:00
c4179829d6 tests(get_handler) loosen the time assumption for the un 2013-12-20 08:23:50 +08:00
9cf1fcc987 refactor(compareAndDelete) 2013-12-20 05:10:22 +08:00
e2fa89d554 merge compareAndDelete 2013-12-19 22:19:49 +08:00
75c02ed0da Merge pull request #405 from benbjohnson/tuning
Add Tuning section to README.
2013-12-18 15:42:16 -08:00
c7536ff5e1 Add Tuning section to README. 2013-12-18 16:40:29 -07:00
fd8ce5d11a Merge pull request #398 from benbjohnson/mod-leader
mod/leader
2013-12-16 14:55:11 -08:00
838645f1b7 Merge pull request #402 from philips/add-header-docs
feat(README): document the etcd request headers
2013-12-16 12:44:49 -08:00
4fb8e79237 Merge pull request #404 from philips/add-cetcd
feat(README): add cetcd
2013-12-16 10:38:01 -08:00
c352db9acd feat(README): add cetcd 2013-12-16 10:37:26 -08:00
60813103e3 Merge pull request #401 from philips/add-dir-docs
feat(README): add notes about in-order key creation
2013-12-16 10:30:32 -08:00
d816db07e3 feat(README): add directory tutorial 2013-12-16 10:30:13 -08:00
296eaf7b34 Add leader module to README. 2013-12-16 08:00:16 -07:00
2ce587ebc7 Merge branch 'master' of https://github.com/coreos/etcd into mod-leader 2013-12-16 07:47:31 -07:00
18bf886368 feat(README): document the etcd request headers 2013-12-15 21:45:10 -08:00
1de78fef4d feat(README): add notes about in-order key creation 2013-12-14 13:08:02 -08:00
54794d57fe Merge pull request #400 from philips/add-lock-docs2
fix(README): cleanup lock documentation
2013-12-13 15:07:56 -08:00
412f56f971 fix(README): cleanup lock documentation
accidently merged this without any review. Here are some more cleanups.
2013-12-13 15:07:39 -08:00
e87ee6a86b Merge pull request #399 from philips/add-lock-docs
feat(README): add a modules section to the README
2013-12-13 15:02:37 -08:00
418eccb3d7 feat(README): add a modules section to the README 2013-12-13 15:02:25 -08:00
61227d7477 mod/leader 2013-12-13 15:25:03 -07:00
931ae5fec3 Merge pull request #397 from philips/fixups-for-the-dashboard
Two dashboard fixups
2013-12-13 12:47:00 -08:00
bcf692d775 chore(mod/dashboard): rebuild to the latest version 2013-12-13 12:44:24 -08:00
7e5aa3137d fix(server/registry): use url.Value.Encode()
Instead of open coding url encoding which lead to error, make it real
and use the library.
2013-12-13 12:43:01 -08:00
e24d2fdb6c fix(mod/dashboard): fix after api changes
use node instead of kvs and value
2013-12-13 12:36:29 -08:00
fe80a868a0 Merge pull request #396 from ccding/master
gofmt for ./server ./test
2013-12-12 15:00:41 -08:00
468bfedf34 gofmt 2013-12-12 14:53:22 -08:00
5e1fdf554d Merge pull request #389 from philips/document-ttl-directories
feat(README): add directory TTL documentation
2013-12-12 11:38:49 -08:00
d204fa8438 Merge pull request #394 from xiangli-cmu/fix_error_msg
fix(store.go) report node.path
2013-12-12 10:13:01 -08:00
dba5eb57cf fix(store.go) report node.path 2013-12-12 10:12:33 -08:00
0399593589 Merge pull request #393 from xiangli-cmu/fix_index
fix(dispatch) should call e.Index()
2013-12-12 09:57:16 -08:00
36dda352d9 fix(dispatch) should call e.Index() 2013-12-12 09:56:28 -08:00
44f050f59a Merge pull request #384 from benbjohnson/refactor-mod-lock
Refactor mod/lock.
2013-12-11 19:34:26 -08:00
3caf7745b6 2013-12-11 20:24:43 -07:00
c1508becd6 Merge pull request #390 from xiangli-cmu/fix_v1_index_inconsistence
fix index inconsistence in v1 api
2013-12-11 11:24:53 -08:00
a5bca025b1 fix index inconsistence in v1 api 2013-12-11 11:12:39 -08:00
bb64e7b6e5 feat(README): add directory TTL documentation 2013-12-11 10:47:00 -08:00
f66bd1689d Merge pull request #387 from xiangli-cmu/fix_expire_notify
Fix expire notify
2013-12-11 10:23:53 -08:00
3e4f8a382e fix TestV2WatchKeyInDir test 2013-12-11 10:19:16 -08:00
44b08fea62 Merge branch 'add-expire-dir-test' of https://github.com/philips/etcd into fix_expire_notify 2013-12-11 09:57:34 -08:00
74bd0d95b8 fix(server): try and add a expire dir test
This doesn't actually work yet.
2013-12-10 16:32:37 -08:00
f83e76eb60 Merge https://github.com/coreos/etcd into fix_expire_notify 2013-12-10 15:18:00 -08:00
06473ba6fe fix(store.go) expire should also notify all the watchers under the path 2013-12-10 15:17:13 -08:00
cb9f677cf6 chore(server): cleanup some whitespace 2013-12-10 11:13:37 -08:00
9ea1ef8916 hack(travis): temporarily fix travis
try a quick workaround for https://github.com/travis-ci/travis-ci/issues/1727
2013-12-09 21:46:55 -08:00
dd354c9e22 Merge pull request #376 from xiangli-cmu/dir_flag
feat add dir_flag
2013-12-09 08:34:57 -08:00
59e98fcc62 doc fix grammar issue 2013-12-09 11:33:55 -05:00
4bec461db1 Refactor mod/lock. 2013-12-08 15:26:58 -07:00
8442e7a0dc Timeout refactor. 2013-12-07 14:35:31 -07:00
aabd0faebe Merge branch 'feature-parametric-timeout' of https://github.com/neildunbar/etcd into neildunbar-feature-parametric-timeout 2013-12-07 14:07:53 -07:00
31bc0bb670 Merge pull request #380 from bcwaldon/drop-prevValue
fix(v2): Drop prevValue from exported fields
2013-12-06 14:11:01 -08:00
0fb8fc0b8d fix(v2): Drop prevValue from exported fields 2013-12-06 11:46:23 -08:00
a06f5e74af Merge remote-tracking branch 'upstream/master' into feature-parametric-timeout
Conflicts:
	Dockerfile
	server/usage.go
	tests/server_utils.go
2013-12-06 10:13:33 +00:00
5edaee79e6 Merge pull request #363 from xiangli-cmu/fix_consistent_redirection
fix redirect url should include rawquery
2013-12-05 20:33:56 -08:00
0762c79e2e refactor remove unused const 2013-12-05 21:04:00 -05:00
d646d7c16a tests add tests for dir flag 2013-12-05 20:46:52 -05:00
1a7eb36b6f Merge pull request #372 from philips/bind-addr-ports
fix(server): override port of bind
2013-12-05 15:29:37 -08:00
9db521ca04 fix(server): override port of bind
Allow people to specify ports on the `-bind-addr` arguments so that they
can use randomly assigned port numbers in containers.
2013-12-05 15:29:25 -08:00
e00296960c test fix tests 2013-12-05 18:16:01 -05:00
c305eda344 docs(delete_command.go) document about recursive implies dir 2013-12-05 17:52:32 -05:00
636dad190e refactor(error.go) error messages 2013-12-05 17:50:20 -05:00
b556252358 tests fix all tests 2013-12-05 17:48:32 -05:00
4ba7d85d56 refactor(update) more clear dir checking 2013-12-05 17:16:44 -05:00
40d297be66 feat add dir_flag 2013-12-05 17:10:37 -05:00
d971d22849 Merge pull request #375 from philips/fix-reset
fix(etcd): Fix forced config reset
2013-12-05 13:26:57 -08:00
e7839e8c57 fix(etcd): Fix forced config reset
When a server name or a data directory were not provided, the
reset functionality would fail to clear out config files from
the appropriate place. This calcualtes the default server name
and data directory before reset is called.
2013-12-05 13:26:31 -08:00
af20be8123 Merge pull request #347 from benbjohnson/mod-lock
WIP: mod/lock
2013-12-05 10:59:32 -08:00
70e31c71f3 Merge pull request #371 from polvi/dockerfile
fix(Dockerfile): remove bogus -bind-addr, and use default -addr
2013-12-05 10:50:34 -08:00
b22c6fed4d fix(Dockerfile): remove bogus -bind-addr, and use default -addr 2013-12-05 18:07:51 +00:00
0867b33de5 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
2013-12-05 09:23:23 +00:00
b784ced517 Update mod/lock versioning. 2013-12-04 22:39:59 -07:00
5d865e321c Merge branch 'master' of https://github.com/coreos/etcd into mod-lock
Conflicts:
	server/v2/tests/delete_handler_test.go
	server/v2/tests/get_handler_test.go
	server/v2/tests/post_handler_test.go
	server/v2/tests/put_handler_test.go
	third_party/github.com/coreos/go-etcd/etcd/requests.go
2013-12-04 22:36:53 -07:00
e76b7d1e8b Add mod/lock version. 2013-12-04 22:24:04 -07:00
f3d438a93f Add mod/lock connection monitoring. 2013-12-04 16:23:27 -07:00
618def7ab0 Merge pull request #369 from philips/format-json
fix(README): prettify json
2013-12-04 13:50:05 -08:00
7ec3f861e4 fix(README): prettify json
fixed using vim and python -m json.tool
2013-12-04 13:48:38 -08:00
67f3fc349c Merge pull request #368 from philips/cleanup-responses
fix(README): use the new response format
2013-12-04 12:22:19 -08:00
0dc428b5d6 fix(README): use the new response format
update all of the examples to use the new response format.
2013-12-04 12:06:41 -08:00
faab194247 Fixed test case 2013-12-04 17:39:03 +00:00
46f8a354d1 Added the ability to specify heartbeat and election timeouts as
config parameters.
2013-12-04 16:58:44 +00:00
e4f1e22401 Merge pull request #357 from philips/add-osx-curl-note
chore(README): add note about curl on OSX
2013-12-03 22:35:55 -08:00
aa4660d780 chore(README): add note about curl on OSX
Discussion about this issue here:
https://groups.google.com/forum/#!topic/munki-dev/oX2xUnoQEi4
2013-12-03 22:35:13 -08:00
ded3cc24c0 fix redirect url should include rawquery 2013-12-02 22:53:36 -05:00
73f04d5cec Merge pull request #343 from xiangli-cmu/refactoring_event
Refactoring event
2013-12-02 19:48:23 -08:00
c6e1af8321 merge master 2013-12-02 22:36:38 -05:00
7875ba28c9 Merge pull request #360 from philips/fix-peerurl
fix(server/v2): redirect to ClientURL not PeerURL
2013-12-02 19:02:58 -08:00
d5e4aef6c2 Merge pull request #361 from philips/cleanup-peers-usage
cleanup-peers-usage
2013-12-02 19:01:18 -08:00
6729776e25 fix(server/usage): fixup the usage based on feedback
People were getting confused by the lack of explanation on which port to
use. Fix this.

/cc @polvi
2013-12-02 18:41:03 -08:00
72bf216cb4 fix(server/v2): redirect to ClientURL not PeerURL
If consistent is set you must redirect the client to the leader's
ClientURL not the PeerURL.
2013-12-02 18:20:11 -08:00
df20be775c Fix test harness. 2013-12-02 15:43:37 -07:00
cfb6eb6e50 Merge pull request #355 from xiangli-cmu/root_readonly
WIP fix root should be rdonly
2013-12-02 10:27:02 -08:00
e34d368a3e Merge pull request #354 from philips/fixup-prevExist-README
feat(README): add a prevExist example
2013-12-01 15:24:45 -08:00
b929e71948 tests add root readonly test 2013-12-01 18:16:32 -05:00
6252037376 fix root should be rdonly 2013-12-01 18:01:24 -05:00
577d08ea7d Merge pull request #352 from xiangli-cmu/fix_watch_prefix
fix(event_history.go) should not scan prefix
2013-12-01 14:40:15 -08:00
78e382cb6b test add watcher prefix test 2013-12-01 17:35:22 -05:00
fc562bd625 fix tests bump deps 2013-12-01 17:24:30 -05:00
1d02a70802 feat(README): add a prevExist example
On the mailing list Dustin Oprea suggested adding a prevExist concrete
example would make it more clear that the value must be true or false.
2013-12-01 13:28:08 -08:00
3d16633a94 update the v2 server to support recursive on CompareAndDelete events 2013-12-01 13:56:32 -07:00
d2d7e37990 implement recursive for CompareAndDelete in the store 2013-12-01 13:38:09 -07:00
f8985d731f keep the Delete tests together 2013-12-01 13:28:14 -07:00
ff081dca88 Merge pull request #353 from baruch/patch-1
Fix spelling mistakes in internal-protocol-versioning.md
2013-12-01 08:52:13 -08:00
cc9c75acbe fix(README): repair some noisy spaces 2013-11-30 22:46:12 -08:00
08dffe85d6 Fix spelling mistakes in internal-protocol-versioning.md 2013-12-01 08:35:56 +02:00
5097a2adee fix(event_history.go) should not scan prefix 2013-12-01 00:47:23 -05:00
373199fe46 support CreateAndDelete through the v2 server 2013-11-30 16:25:26 -07:00
171072c736 add the CompareAndDelete command 2013-11-30 16:24:23 -07:00
90a8f56c96 add compareAndDelete event action 2013-11-30 10:08:25 -07:00
5b739f6166 track CompareAndDelete stats 2013-11-30 10:05:48 -07:00
702cf1cc36 teach store.Store about CompareAndDelete 2013-11-30 10:02:03 -07:00
7997fdc76f Merge pull request #330 from philips/fixup-readme-remove-v1
fix(README): fix 9 instances of v1
2013-11-29 22:28:02 -08:00
2a5030b3ca fix(README): fix 9 instances of v1
remove references to the v1 API and consistently use the v2 API.
2013-11-29 22:26:52 -08:00
d5172849bc Merge pull request #342 from philips/use-machine-nomenclature
fix(README): use machine instead of node
2013-11-29 16:57:28 -08:00
03571d3cda Merge branch 'master' of https://github.com/coreos/etcd into mod-lock 2013-11-29 16:34:04 -07:00
d8e9838c38 Lock testing. 2013-11-29 16:33:49 -07:00
67b4c27d5d refactor change node_repr to node_extern 2013-11-28 21:34:38 -05:00
b7d07ea5c8 refactor event 2013-11-28 11:33:40 -05:00
08c59895b5 refactor(Node) do not expose node struct 2013-11-28 11:33:23 -05:00
22c2935ddb Initial mod_lock acquire. 2013-11-27 16:59:05 -07:00
978cb54fc7 fix(README): use machine instead of node
Internally we call every member of an etcd cluster a "machine" so stay
consistent when talking in the README.
2013-11-27 14:37:31 -08:00
d3a83805cc fix(README): link to etcdctl directly
link to the etcdctl homepage directly
2013-11-27 14:29:41 -08:00
e41b86fd68 Merge pull request #341 from philips/fixup-name-and-data-dir-guessing
fix(etcd): fixup the name and data dir guessing
2013-11-27 14:26:02 -08:00
74ad50efa6 Merge branch 'master' of https://github.com/coreos/etcd into mod-lock
Conflicts:
	mod/mod.go
2013-11-27 14:47:13 -07:00
32861246b9 mod/lock 2013-11-27 14:36:14 -07:00
0344e759d9 Merge pull request #340 from philips/add-rthomas-clj-etcd
feat(README): add clojure client rthomas/clj-etcd
2013-11-27 12:25:28 -08:00
04711ecde5 fix(etcd): fixup the name and data dir guessing
- Only generate the name from a hostname if the data dir is not
  specified and the name is not specified

- Only guess the data dir from Name if the data dir wasn't already
  specified
2013-11-27 12:20:26 -08:00
da666d9143 feat(README): add clojure client rthomas/clj-etcd 2013-11-27 09:11:00 -06:00
c93f086032 Merge pull request #329 from philips/remove-redundant-datadir-code
fix(etcd): remove duplicate DataDir setup
2013-11-26 13:20:29 -08:00
7c07810958 fix(etcd): remove duplicate DataDir setup
In the refactor of the configuration and flags I think that we
accidently placed this logic twice. The side effect is that we always
ended up with a `.etcd` directory.
2013-11-26 10:22:39 -06:00
0ed3509ec1 Merge pull request #324 from philips/redirect-mod-dashboard-trailing-slash
fix(mod): redirect dashboard to /dashboard
2013-11-26 08:15:33 -08:00
64e49726cd fix(mod): redirect dashboard to /dashboard 2013-11-23 23:31:28 -08:00
b4f3d02c1c Merge pull request #322 from xiangli-cmu/master
bump deps
2013-11-22 14:18:17 -08:00
a607c9eace fix dep issue 2013-11-22 13:27:04 -08:00
4520705bdf Merge pull request #320 from philips/add-cors-options
feat(server): introduce a cors handler
2013-11-22 11:53:45 -08:00
40a574a8ca wip commit 2013-11-22 11:32:24 -08:00
522a833ab2 bump go-etcd 2013-11-22 11:31:46 -08:00
8a0496cfae bump deps 2013-11-22 08:59:24 -08:00
b190c4250a chore(mod/dashboard/resources): use the latest version of the code 2013-11-21 17:23:40 -08:00
4c06e19cf2 fix(mod/dashboard): grab the leader URL
query etcd to find the URL of the leader before making any http requests
that can't be redirected from a browser like PUT/POST and DELETE.
2013-11-21 17:12:58 -08:00
a1ec895b91 feat(server): introduce a cors handler
Introduce a handler that lives under the gorilla mux and adds the
correct headers based on the request and always returns 200 OK when
there OPTIONS is called on a URL.

This fixes the ability to DELETE from the dashboard on peer X when peer
Y is the leader. As a side effect it reveals some bugs in the dashboard
though notably:

- Due to the RTT immediatly refreshing the dashboard doesn't work and
  deleted keys are still there

- For some reason PUTS from peer X are creating directories and not
  keys.
2013-11-21 09:25:21 -08:00
68e7455374 Merge pull request #317 from benbjohnson/fix-help-flag
Config clean up and usage messaging.
2013-11-20 10:35:55 -08:00
ea6b11bbf6 Config clean up and usage messaging. 2013-11-20 10:52:01 -07:00
228754a99c mod_lock 2013-11-19 16:12:58 -07:00
fca8506331 Merge pull request #312 from benbjohnson/clean-up-config
Renamed Configuration Parameters
2013-11-19 13:49:40 -08:00
15eee885d7 Merge branch 'master' of https://github.com/coreos/etcd into clean-up-config 2013-11-19 10:13:39 -07:00
a414b15f9a Config fixes. 2013-11-19 09:20:20 -07:00
8952c1bd42 Merge branch 'master' of https://github.com/coreos/etcd into clean-up-config
Conflicts:
	etcd.go
2013-11-19 08:28:46 -07:00
01a0f79efb Merge pull request #314 from xiangli-cmu/fix-content-type
fix set content-type to application/json
2013-11-16 20:50:36 -08:00
1d34c82643 fix set content-type to application/json 2013-11-16 20:48:44 -08:00
cba2611c68 Renamed configuration parameters. 2013-11-15 00:13:32 -05:00
48f5a47ff1 Merge pull request #310 from xiangli-cmu/master
test fix wrong assumption should be previous index + 501 + 6
2013-11-14 20:20:57 -08:00
4f45de6953 test fix wrong assumption should be previous index + 501 + 6 2013-11-14 20:22:25 -08:00
1c1d3dd708 Merge pull request #309 from xiangli-cmu/master
fix create folder before write info file
2013-11-14 20:11:22 -08:00
e90937a2b4 tests loosen the ttl checking 2013-11-14 20:09:12 -08:00
516f249403 fix create folder before write info file 2013-11-14 20:00:44 -08:00
3ce1132d5c Merge pull request #305 from philips/cherry-pick-lost-changes
feat(README): add an erlang library marshall-lee/etcd.erl
2013-11-13 20:44:31 -08:00
39e4e0c3d9 feat(README): add an erlang library marshall-lee/etcd.erl 2013-11-13 20:39:40 -08:00
5747b3b401 fix(README): cleanup a bad merge 2013-11-13 20:37:46 -08:00
f499100426 Merge branch 'master' of https://github.com/benbjohnson/etcd into benbjohnson-master
Conflicts:
	README.md
2013-11-13 22:38:06 -05:00
aa047b124d v0.2.0-rc1 2013-11-13 22:34:13 -05:00
256a0428dd CHANGELOG 2013-11-13 21:56:02 -05:00
d9c7796d56 Merge pull request #303 from philips/fixup-certificates
fix(fixtures/ca): make the certificates work
2013-11-13 11:56:36 -08:00
b3704a7119 fix(fixtures/ca): make the certificates work
Something was wrong with the old certificates. Rebuild them to get them
all working.
2013-11-13 11:45:20 -08:00
a5402435b9 Merge pull request #301 from philips/use-directory-based-on-machine-name
feat(etcd): create unique directory on no-flag case
2013-11-13 11:23:19 -08:00
6066862c34 Merge pull request #299 from benbjohnson/release
README
2013-11-13 11:22:31 -08:00
a0bfe411f8 Merge pull request #298 from benbjohnson/migration-test
Migration test
2013-11-13 10:19:33 -08:00
eecd9f7e35 feat(etcd): create unique directory on no-flag case
Tell etcd to store the log and configuration into directory in the
pattern of `${machineName}.etcd` if no directory is specified.
2013-11-13 10:16:02 -08:00
5057036563 Merge pull request #300 from philips/remove-etcd-from-mod
refactor(mod): remove the /etcd/ prefix
2013-11-13 07:13:16 -08:00
ca7e61052d refactor(mod): remove the /etcd/ prefix
Originally we were going to move all of the API endpoints to /etcd/ so
that you could move etcd traffic over a multiplexed HTTP proxy with
other service but since we don't have a strong use case for this just
remove this for now.
2013-11-13 06:15:35 -08:00
df00306a71 README 2013-11-12 21:28:51 -05:00
954217fb73 Fix v1 cluster migration test. 2013-11-12 19:27:29 -05:00
ccc27a61f5 Merge branch '0.2' of https://github.com/coreos/etcd into migration-test 2013-11-12 17:29:58 -05:00
5abbaf59e3 Merge pull request #292 from xiangli-cmu/fix-ttl
WIP: fix ttl
2013-11-11 21:30:32 -08:00
811c577fe8 test stop mockSync goroutines 2013-11-11 21:31:12 -08:00
fe5fb6cfba style naming the initialization fields for sync command 2013-11-11 21:21:50 -08:00
8b2e1025ef style remove the extra space 2013-11-11 21:19:30 -08:00
d8157472fe Merge branch '0.2' of https://github.com/coreos/etcd into migration-test 2013-11-11 18:12:24 -05:00
b988f5b323 chore(CONTRIBUTING): make the allowed types a list
The list was formatted as one long sentence. Fix that.
2013-11-11 11:57:38 -08:00
e427c85f03 refactor add debug info to remove_node test 2013-11-09 21:31:17 -08:00
27157e5e78 fix tests 2013-11-09 21:17:32 -08:00
cb4b6f1fe4 feat add modifiedIndex in kvpair 2013-11-09 20:52:06 -08:00
06f1b7f2e8 refactor change Index to modifiedIndex 2013-11-09 20:49:19 -08:00
d8e5994c35 feat attach etcd-index,raft-index,raft-term to header 2013-11-09 20:20:47 -08:00
e397e807ca Merge pull request #297 from philips/add-trello
feat(README): add link to trello
2013-11-09 19:45:51 -08:00
fcba6436e8 feat(README): add link to trello 2013-11-09 19:24:37 -08:00
d87e0e93d3 fix get return the last modified index of the node 2013-11-09 19:05:38 -08:00
eca433cee5 fix add sync_command.go 2013-11-09 18:59:43 -08:00
6156d5c790 refactor separate etcd index from raft index 2013-11-09 17:55:54 -08:00
fc25ef8383 Merge pull request #246 from philips/add-dashboard-0.2
0.2: add the dashboard
2013-11-09 13:06:04 -08:00
84be60c920 feat(dashboard): use all of the latest js/css
rebuild all of the js and css as go binaries
2013-11-08 17:48:02 -08:00
bfe33bd3c4 feat(dashboard): have stats use the v2 API 2013-11-08 17:45:55 -08:00
c91cb72ee2 feat(dashboard): have browser use the v2 api 2013-11-08 17:41:04 -08:00
d045f43cda bug(css): Reset line-height to prevent jumping 2013-11-08 16:59:58 -08:00
7ca09579c2 feat(dashboard): Sort machine list to prevent jumping 2013-11-08 16:59:52 -08:00
4fab919fcb fix(dashboard): use a more memory friendly bindata 2013-11-08 16:59:37 -08:00
5620f88635 feat(server): insert the mod path 2013-11-08 16:59:30 -08:00
0372cdea23 refactor move sync command into etcd 2013-11-08 16:00:58 -08:00
56bbab74ca bug(back button): back button now is disabled when invalid 2013-11-08 14:09:36 -08:00
59b2eb4618 feature(selection): prevent selection of non-text elements with CSS 2013-11-08 14:09:36 -08:00
98d1209ca2 chore(dashboard) update color ranges 2013-11-08 14:09:35 -08:00
d12f97c8cf chore(dashboard): Remove restangular 2013-11-08 14:09:35 -08:00
713d50951b fix(dashboard): fix bug in toggling views 2013-11-08 14:09:35 -08:00
40142cbacc feat(dashboard): Notate leader in machine list 2013-11-08 14:09:35 -08:00
478118497c A little lit bit easy to read
I have only reordered to parameters to be according to the first instance executed.
2013-11-08 14:09:35 -08:00
cc9b5fca90 feat(README): add go-discover 2013-11-08 14:08:39 -08:00
b7084fda45 docs(dashboard): improve instructions 2013-11-08 14:08:39 -08:00
8540249c4e Update README.md 2013-11-08 14:08:39 -08:00
b54a6a2ac8 Update README.md 2013-11-08 14:08:39 -08:00
f62095428f Update README.md 2013-11-08 14:08:39 -08:00
3f5c39afd9 fix(mod/dashboard): bump the resources
bump all of the resources to get the new delete_key fix.
2013-11-08 14:08:39 -08:00
4005312ee5 feat(scripts): add build-release script 2013-11-08 14:08:39 -08:00
677590feb7 docs(dashboard): add instructions to get started 2013-11-08 14:08:39 -08:00
fa1b00cf91 chore(mod/dashboard): remove fmt package
Always build before pushing to origin master! Sorry for this noise. I
deleted the debug message but not fmt.
2013-11-08 14:08:39 -08:00
b819bb1c8c chore(mod/dashboard): remove debug line
Oops, this debug line made it into the tree. Remove it.
2013-11-08 14:08:39 -08:00
26806a10fc fix(mod/dashboard): use deleteKey() not delete_key()
small bug I overlooked while refactoring all of the dashboard function
names to be more "javascripty"
2013-11-08 14:08:39 -08:00
55356465c6 feat(mod/dashboard): add cleaner urls for stats and browser
you can hit them at:

- http://localhost:4001/etcd/mod/dashboard/stats
- http://localhost:4001/etcd/mod/dashboard/browser
2013-11-08 14:08:38 -08:00
bb275e3f45 Including clojure library 2013-11-08 14:08:38 -08:00
0c676ac93a feat(mod): introduce the /etcd/mod namespace
introduce the `/etcd/mod` namespace and add the dashboard into it.
2013-11-08 14:05:38 -08:00
26c24dd889 Add confd to list of projects using etcd 2013-11-08 14:05:30 -08:00
ae05a9f003 feat(mods): add README file 2013-11-08 14:05:30 -08:00
5e604b7a18 chore(dashboard): move to the mod directory 2013-11-08 14:05:29 -08:00
13f7257dd7 fix(dashboard): add moment to bower dependencies 2013-11-08 14:05:29 -08:00
6e278294af fix(dashboard): add d3 to bower 2013-11-08 14:05:29 -08:00
8acaf71a59 feat(dashboard): introduce the in memory handler
the in memory handler gives etcd the ability to serve a dashboard
without on disk resources. This is the first time we are using the
/mod/ path too.

TODO: cleanup the mod stuff so it isn't hacked into etcd_handlers.
2013-11-08 14:05:29 -08:00
af3804d728 feat(dashboard): inital commit of resources package 2013-11-08 14:05:16 -08:00
b2d72b3e55 bump(github.com/jteeuwen/go-bindata): 79847ab3e91ae5d2e1b18796c1795c78f29565d7 2013-11-08 14:05:16 -08:00
53678ad134 feat(dashboard): Initial commit of frontend code 2013-11-08 14:04:51 -08:00
bf5f0ab3f2 feat(dashboard/README): initial commit 2013-11-08 14:04:51 -08:00
6a074d4f6f chore(*.go): add copyright notice 2013-11-08 14:04:15 -08:00
acd940a450 refactor comments on IsPermanent 2013-11-08 13:37:30 -08:00
5a4e764d7a refactor add comments for receiving expire commands 2013-11-08 13:24:23 -08:00
b4f4528ef4 feat upgrade get_handler 2013-11-07 22:29:15 -08:00
28ac516f68 fix sinceIndex 2013-11-07 20:55:26 -08:00
41695eb1c8 Merge pull request #296 from cloudaice/patch-1
Update README.md
2013-11-07 19:37:25 -08:00
64875d39b0 Update README.md
fixed mistake
2013-11-08 11:36:10 +08:00
4c1d864095 fix cleanup 2013-11-06 21:27:39 -08:00
c307b6abca fix watcher_hub 2013-11-06 21:19:37 -08:00
55058c64f5 feat wathch for expiring need to be pending 2013-11-05 23:30:48 -08:00
779195eb4f fix bug in update ttl 2013-11-05 22:18:54 -08:00
49c55477e5 refactor clean up 2013-11-05 21:56:21 -08:00
797d996535 init sync to delete expiring keys 2013-11-05 21:47:25 -08:00
8c6606ed12 Fix TTL migration issue. 2013-11-05 15:57:53 -07:00
1d49098954 feat add heap top 2013-11-04 22:13:26 -08:00
07b52ee24c fix save and recovery 2013-11-04 21:51:14 -08:00
0d8510df33 refactor use push 2013-11-04 21:36:05 -08:00
efe431ead0 refactor add push/pop function 2013-11-04 21:33:23 -08:00
c5a6f9bb6b fix iszero 2013-11-04 21:22:22 -08:00
3f6d6cf4c6 refactor use time.IsZero 2013-11-04 20:56:41 -08:00
c05df9e3f5 refactor add newTTLKeyHeap function 2013-11-04 20:31:24 -08:00
d3bfc49b7c Remove leading slash from handlers. 2013-11-04 14:36:20 -07:00
35d9719707 Add v1.solo migration fixture. 2013-11-04 13:56:02 -07:00
6b5d6ecd8b Cluster migration test. 2013-11-04 13:46:43 -07:00
bf76af8fd1 Update migration. 2013-11-04 13:16:45 -07:00
b9593b80ec feat add update heap test 2013-11-03 23:51:48 -08:00
5394c8a894 feat add ttl heap 2013-11-03 23:34:47 -08:00
51f57629f9 Merge pull request #281 from xiangli-cmu/fix-snapshot
fix snapshot
2013-11-03 21:10:53 -08:00
235ffc234d refactor change cmd argument snapCount to snapshotCount 2013-11-03 21:06:51 -08:00
52d5e05201 refactor use defer 2013-11-03 20:59:08 -08:00
3d4e604607 Merge branch '0.2' of https://github.com/coreos/etcd into migration-test 2013-11-03 16:03:20 -07:00
44356dc654 Update migration script. 2013-11-03 16:02:59 -07:00
3a29ce4d17 Update migration. 2013-11-03 15:58:16 -07:00
02abbb6a6c Migration test. 2013-11-03 15:49:00 -07:00
71a73d3904 Merge pull request #290 from xiangli-cmu/feat-use-raft-protobuf
feat use-raft-protobuf
2013-11-03 10:52:37 -08:00
e951b99bdd Merge pull request #291 from xiangli-cmu/master
feat use protobuf for 0.1.2
2013-11-03 10:51:25 -08:00
63768e3742 feat use protobuf 2013-11-03 09:15:02 -08:00
f3ce75f2b4 feat add a simple speed test 2013-11-02 22:05:44 -07:00
eb2fbcb575 feat use-raft-protobuf 2013-11-02 21:50:35 -07:00
fa0cd3ae87 Merge pull request #288 from bcwaldon/fix-readme
Fix typos in README.md
2013-11-02 14:30:00 -07:00
8aeb4121cf Merge pull request #287 from bcwaldon/vagrantfile
Add Vagrantfile
2013-11-02 14:29:17 -07:00
9f3524fd11 Fix typos in README.md 2013-11-02 14:10:51 -07:00
6f054827a3 Add Vagrantfile 2013-11-02 13:09:22 -07:00
3062aab44f Merge pull request #268 from xiangli-cmu/0.2-readme
update readme
2013-11-01 16:04:36 -07:00
ae615eda62 fix typo 2013-11-01 15:56:38 -07:00
0c4b45d4fb Merge pull request #283 from philips/use-hostname-as-machine-name
feat(etcd): use hostname as machine name
2013-11-01 06:45:01 -07:00
c10653ae0c feat(etcd): use hostname as machine name
by default I don't want etcd to require parameters so people can rapidly
try it out. Try to use the hostname as the name instead.
2013-10-31 15:16:28 -07:00
c88a556917 test add snapshot tests 2013-10-30 19:41:21 -07:00
f29ab366c3 merge with 0.2 2013-10-30 17:44:20 -07:00
9d0de611a7 feat add snapCount parameter 2013-10-30 17:36:15 -07:00
0e15962cef Merge pull request #276 from xiangli-cmu/feat-kvpair-ttl
feat kvpair include ttl
2013-10-30 15:56:28 -07:00
0cd78e210a tests more delay for passing tests on travis 2013-10-30 15:51:46 -07:00
f723651a6d fix test: should wait for watch response 2013-10-30 15:46:01 -07:00
bd651edf80 test add integration test 2013-10-30 15:27:16 -07:00
107762e82a fix snapshot 2013-10-30 15:14:34 -07:00
1a2a9d60e6 fix(README): make contacts a list 2013-10-30 15:02:28 -07:00
03c836faff Merge pull request #280 from philips/add-readme-contact
feat(README): add mailing list and IRC
2013-10-30 15:01:30 -07:00
90b49fa53c feat(README): add mailing list and IRC 2013-10-30 14:14:13 -07:00
0435284a37 Merge pull request #278 from benbjohnson/upgrade-version
Add version upgrade endpoint.
2013-10-30 06:37:07 -07:00
ddf527e092 Add version upgrade endpoint. 2013-10-29 15:49:10 -06:00
d59134a5b5 feat(README): add an erlang library marshall-lee/etcd.erl 2013-10-29 14:25:44 -07:00
576badd334 Merge pull request #277 from benbjohnson/versioning
Internal Versioning
2013-10-29 09:39:05 -07:00
ec175d4c47 test add test for ttl in kv pair 2013-10-28 09:42:54 -07:00
23dc0b9317 Merge branch '0.2' of https://github.com/coreos/etcd into versioning
Conflicts:
	server/v2/put_handler.go
2013-10-28 06:39:56 -06:00
aa9ae32998 Internal versioning. 2013-10-27 14:09:40 -06:00
bd0d2e8494 Merge pull request #275 from xiangli-cmu/fix-put-ttl
Fix put ttl
2013-10-27 10:09:26 -07:00
a70aa3e0da Merge pull request #266 from benbjohnson/config
Tiered Configuration
2013-10-27 09:52:10 -07:00
7b60f8bdc3 feat kvpair include ttl 2013-10-26 21:21:48 -07:00
1fb3799118 fix put ttl 2013-10-26 21:04:44 -07:00
3be69f09ac Merge pull request #272 from dmarti/patch-1
Add instructions for setting a value only if the key does not exist
2013-10-26 20:00:30 -07:00
e254b9cec6 Add instructions for setting a value only if the key does not exist
Use an empty prevValue to atomically test for the existence of a key before setting the value.
2013-10-25 10:09:57 -07:00
9ed2776639 Merge pull request #253 from philips/add-Access-Control-Allow-Methods
fix(handlers): add Access-Control-Allow-Methods to cors
2013-10-23 14:04:22 -07:00
e40bb2e8d8 Merge pull request #267 from xiangli-cmu/fix-wait-handler
fix wait handler should close connection if client leaves
2013-10-23 13:33:11 -07:00
378c3d1dcf Merge pull request #265 from xiangli-cmu/fix-timeout
headerTimeout should be longer and body should be shorter
2013-10-23 13:30:51 -07:00
41e7266ff7 Merge branch '0.2' into config
Conflicts:
	Documentation/external-documentation.md
	server/config.go
	server/config_test.go
	server/tls_info.go
	server/util.go
2013-10-23 13:59:28 -06:00
f99d24310f Fix conf extension and documentation. 2013-10-23 13:44:53 -06:00
53b638558b Update readme 2013-10-22 14:30:55 -07:00
65663b2dae Merge branch '0.2' of https://github.com/coreos/etcd into 0.2 2013-10-22 13:09:26 -06:00
c697767c47 Merge pull request #270 from mattcottingham/fix-systemd-journal-panic
Update go-systemd packages to fix panic
2013-10-22 09:45:47 -07:00
32c2f89fe6 Update go-systemd packages to coreos/go-systemd:80318d 2013-10-22 10:46:25 +01:00
63456b5c4b fix close connection when client leaves 2013-10-22 00:17:58 -07:00
98fad7b86a update readme 2013-10-21 21:51:15 -07:00
7d4908a6c3 Merge branch '0.2' of https://github.com/coreos/etcd into config 2013-10-21 21:38:58 -06:00
bc0e07bca2 Add tiered configuration. 2013-10-21 21:37:25 -06:00
91cad59ada refactor use transtiemout 2013-10-21 17:53:24 -07:00
a659dec00b fix headerTimeout should be longer and body should be shorter 2013-10-21 17:33:23 -07:00
48b3e7f2ab Add basic config. 2013-10-21 16:00:20 -06:00
e8a7230a1d Merge pull request #264 from xiangli-cmu/0.2
refactor remove extra print parameter
2013-10-21 12:38:01 -07:00
6803d077b9 fix store pacakge pass go vet 2013-10-21 12:37:22 -07:00
94accfcb23 refactor remove extra print parameter 2013-10-21 12:35:02 -07:00
90c5614cd4 Merge pull request #260 from benbjohnson/clean-store-tests
Clean up store tests.
2013-10-20 18:08:17 -07:00
23119d1672 Refactor store tests. 2013-10-20 16:09:45 -06:00
f19567fd3e Merge pull request #259 from xiangli-cmu/0.2
fix do not need to parse the original url
2013-10-20 11:27:47 -07:00
2cafdcd657 fix do not need to parse the original url 2013-10-20 11:27:40 -07:00
93bdce32a8 Merge pull request #258 from xiangli-cmu/0.2
use net/url pacakge
2013-10-20 11:25:44 -07:00
1119a86cc3 fix add fragment 2013-10-20 11:25:24 -07:00
5767b4e245 use net/url pacakge 2013-10-20 11:10:24 -07:00
61f238f22e Merge pull request #255 from xiangli-cmu/0.2-fix-devlist-issue
0.2 fix devlist issue
2013-10-20 10:29:29 -07:00
0cdb865b4c Merge pull request #256 from xiangli-cmu/0.2-refactor-status-code
refactor return http status 201 Created when creating a new node
2013-10-20 10:25:01 -07:00
b852a746ce refactor move http status logic to server.go 2013-10-20 10:21:54 -07:00
8e12e4e480 Merge pull request #251 from benbjohnson/v2-handler-tests
v2 Handler Unit Tests
2013-10-20 10:12:44 -07:00
acbc0c8846 refactor return http status 201 Created when creating a new node 2013-10-19 19:57:36 -07:00
6684186033 fix append rawqurey to the redirect location. 2013-10-19 15:06:35 -07:00
e931ff23d8 Merge branch '0.2' of https://github.com/coreos/etcd into 0.2-fix-devlist-issue 2013-10-19 11:52:47 -07:00
7b6e305d40 fix update also return newValue 2013-10-19 11:51:41 -07:00
55f9045561 fix(handlers): add Access-Control-Allow-Methods to cors
This is needed to have CORs work properly. Fixes #252
2013-10-18 11:44:29 -07:00
62b890839a Merge branch '0.2' of https://github.com/coreos/etcd into v2-handler-tests
Conflicts:
	test.sh
2013-10-18 08:54:51 -06:00
97987e72a7 Merge pull request #250 from xiangli-cmu/0.2-fix-test
fix use right gopath
2013-10-17 21:12:38 -07:00
a6f7069264 fix use right gopath 2013-10-17 20:57:00 -07:00
58495d1dcf Merge pull request #249 from xiangli-cmu/0.2-fix-path
fix bad cert path
2013-10-17 20:54:15 -07:00
4135f425d3 fix bad cert path 2013-10-17 20:53:30 -07:00
dcef04b796 Add v2 unit tests. 2013-10-17 21:52:15 -06:00
2eff77ea92 Merge pull request #247 from xiangli-cmu/0.2-handlers
fix v1 handler: use create command when test against prevexistence
2013-10-17 20:37:16 -07:00
d5f0642524 Merge pull request #244 from robszumski/sort-machine-list
Sort Machine List on Dashboard
2013-10-17 17:07:33 -07:00
87b2a0d9c5 fix remove unused package 2013-10-17 10:50:00 -07:00
a0d3488d94 Merge branch '0.2' of https://github.com/coreos/etcd into 0.2-handlers 2013-10-17 10:46:01 -07:00
4479d72e93 fix hmm... another stupid mistake 2013-10-17 00:12:39 -07:00
28722e2127 fix v1 handler: use create command when test against prevexistence 2013-10-16 23:57:42 -07:00
4774466a75 bug(css): Reset line-height to prevent jumping 2013-10-16 14:48:26 -07:00
3fa0d21049 feat(dashboard): Sort machine list to prevent jumping 2013-10-16 14:47:10 -07:00
5305b802b2 Merge pull request #241 from robszumski/fix-highlight
Fix highlight
2013-10-15 23:34:49 -07:00
4c3509ac09 bug(back button): back button now is disabled when invalid 2013-10-15 23:11:34 -07:00
45b0b35a0f feature(selection): prevent selection of non-text elements with CSS 2013-10-15 22:01:45 -07:00
36ae9e9437 Merge pull request #240 from robszumski/color-ranges
chore(dashboard) update color ranges
2013-10-15 16:13:06 -07:00
53e9e1966f chore(dashboard) update color ranges 2013-10-15 15:58:56 -07:00
9838cae49d chore(dashboard): Remove restangular 2013-10-15 10:58:31 -07:00
aa49d5c1bd fix(dashboard): fix bug in toggling views 2013-10-15 10:58:18 -07:00
1c401a05b1 feat(dashboard): Notate leader in machine list 2013-10-15 10:57:58 -07:00
ad5cfab5ba Merge pull request #232 from adrianlzt/patch-1
A little lit bit easy to read
2013-10-14 10:59:39 -07:00
12636ce89c A little lit bit easy to read
I have only reordered to parameters to be according to the first instance executed.
2013-10-14 19:14:14 +02:00
c434f2cae7 Merge pull request #229 from amirhhz/patch-1
Correct index number to match description in 'watch' example
2013-10-14 09:10:29 -07:00
a0007dbeab Correct index number to match description in 'watch' example 2013-10-14 13:48:20 +01:00
c7d3d3371b feat(README): add go-discover 2013-10-12 21:27:20 -07:00
ba0c104cc8 Merge pull request #215 from robszumski/update-dashboard-readme
docs(dashboard): add instructions to get started
2013-10-12 12:01:02 -07:00
e1186bbead docs(dashboard): improve instructions 2013-10-11 15:37:30 -07:00
0dfbb3f921 Merge pull request #217 from xiangli-cmu/master
Add F&Q about creating a valid client auth cert
2013-10-10 23:45:12 -07:00
beac6d8589 Update README.md 2013-10-10 23:44:59 -07:00
188a903e97 Update README.md 2013-10-10 23:43:47 -07:00
d65c2451c4 Update README.md 2013-10-10 23:15:48 -07:00
e77b9aa020 fix(mod/dashboard): bump the resources
bump all of the resources to get the new delete_key fix.
2013-10-10 15:28:19 -07:00
45f0ff5679 feat(scripts): add build-release script 2013-10-10 14:39:12 -07:00
52c34a2323 docs(dashboard): add instructions to get started 2013-10-10 13:32:37 -07:00
8ebbb96611 chore(mod/dashboard): remove fmt package
Always build before pushing to origin master! Sorry for this noise. I
deleted the debug message but not fmt.
2013-10-10 12:41:20 -07:00
3d5087d488 chore(mod/dashboard): remove debug line
Oops, this debug line made it into the tree. Remove it.
2013-10-10 12:34:08 -07:00
777e03491f fix(mod/dashboard): use deleteKey() not delete_key()
small bug I overlooked while refactoring all of the dashboard function
names to be more "javascripty"
2013-10-10 12:19:01 -07:00
bc077b66b0 Merge pull request #207 from philips/integrate-dashboard
New dashboard as module
2013-10-10 11:42:49 -07:00
05202c9ce9 feat(mod/dashboard): add cleaner urls for stats and browser
you can hit them at:

- http://localhost:4001/etcd/mod/dashboard/stats
- http://localhost:4001/etcd/mod/dashboard/browser
2013-10-10 11:32:39 -07:00
4246d3a400 Merge pull request #213 from aterreno/master
Including clojure library
2013-10-10 08:48:10 -07:00
cb323e95ff Including clojure library 2013-10-10 13:43:51 +01:00
302347426e Merge pull request #210 from philips/add-version-flag
feat(etcd): add version flag
2013-10-09 14:48:49 -07:00
af30cb8725 feat(etcd): add version flag
print the version and exit, very simple :)
2013-10-09 14:26:49 -07:00
1d6a6d20d1 feat(mod): introduce the /etcd/mod namespace
introduce the `/etcd/mod` namespace and add the dashboard into it.
2013-10-09 13:54:44 -07:00
f8b0c876f7 Merge pull request #208 from kelseyhightower/master
Add confd to list of projects using etcd
2013-10-08 15:31:39 -07:00
52d5773cc6 Add confd to list of projects using etcd 2013-10-08 14:41:39 -07:00
32f562a013 feat(mods): add README file 2013-10-08 11:22:48 -07:00
8ee0845631 chore(dashboard): move to the mod directory 2013-10-08 11:17:12 -07:00
bed3980e9c fix(dashboard): add moment to bower dependencies 2013-10-08 11:15:03 -07:00
d2904ae36e fix(dashboard): add d3 to bower 2013-10-08 11:15:03 -07:00
431eebf754 feat(dashboard): introduce the in memory handler
the in memory handler gives etcd the ability to serve a dashboard
without on disk resources. This is the first time we are using the
/mod/ path too.

TODO: cleanup the mod stuff so it isn't hacked into etcd_handlers.
2013-10-08 11:15:03 -07:00
637650e2a9 feat(dashboard): inital commit of resources package 2013-10-08 11:15:03 -07:00
65948d531c bump(github.com/jteeuwen/go-bindata): 79847ab3e91ae5d2e1b18796c1795c78f29565d7 2013-10-08 11:15:03 -07:00
52da2acffd feat(dashboard): Initial commit of frontend code 2013-10-08 11:15:03 -07:00
84ea824b96 feat(dashboard/README): initial commit 2013-10-07 16:50:29 -07:00
5a4f096647 feat(etcd_handlers): add the dashboard URL
/dashboard serves a dashboard now
2013-10-07 16:50:29 -07:00
44c16dd30d Merge pull request #206 from philips/fixup-copyright
chore(*.go): add copyright notice
2013-10-07 09:49:23 -07:00
41b9051686 chore(*.go): add copyright notice 2013-10-07 09:48:28 -07:00
1582 changed files with 323222 additions and 89871 deletions

1
.dockerignore Normal file
View File

@ -0,0 +1 @@
.git

14
.gitignore vendored
View File

@ -1,5 +1,11 @@
src/
pkg/
/etcd
/server/release_version.go
/coverage
/gopath
/go-bindata
/machine*
/bin
.vagrant
*.etcd
/etcd
*.swp
/hack/insta-discovery/.env
*.test

1
.godir Normal file
View File

@ -0,0 +1 @@
github.com/coreos/etcd

13
.header Normal file
View File

@ -0,0 +1,13 @@
// Copyright 2014 CoreOS, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

View File

@ -1,8 +1,11 @@
language: go
go: 1.1
sudo: false
go:
- 1.4
- 1.5
install:
- echo "Skip install"
- go get github.com/barakmich/go-nyet
script:
- ./test.sh
- INTEGRATION=y ./test

View File

@ -1,75 +1,70 @@
# How to contribute
etcd is open source, Apache 2.0 licensed and accepts contributions via Github pull requests.
This document outlines some of the conventions on commit message formatting, contact points for developers and other resources to make getting your contribution into etcd easier.
etcd is Apache 2.0 licensed and accepts contributions via GitHub pull requests. This document outlines some of the conventions on commit message formatting, contact points for developers and other resources to make getting your contribution into etcd easier.
# Email and chat
For simplicity etcd discussions happen on coreos-dev and in #coreos-dev.
As the community grows we will move to a dedicated mailing list and IRC channel.
- Email: [coreos-dev](https://groups.google.com/forum/#!forum/coreos-dev)
- Email: [etcd-dev](https://groups.google.com/forum/?hl=en#!forum/etcd-dev)
- IRC: #[coreos](irc://irc.freenode.org:6667/#coreos) IRC channel on freenode.org
## Getting Started
## Getting started
- Fork the repository on GitHub
- Read the README.md for build instructions
## Reporting Bugs and Creating Issues
Reporting bugs is one of the best ways to contribute. However, a good bug report
has some very specific qualities, so please read over our short document on
[reporting bugs](https://github.com/coreos/etcd/blob/master/Documentation/reporting_bugs.md)
before you submit your bug report. This document might contain links known
issues, another good reason to take a look there, before reporting your bug.
## Contribution flow
This is a rough outline of what a contributor's workflow looks like:
- Create a topic branch from where you want to base your work. This is usually master.
- Make commits of logical units.
- Make sure your commit messages are in the proper format, see below
- Make sure your commit messages are in the proper format (see below).
- Push your changes to a topic branch in your fork of the repository.
- Submit a pull request to coreos/etcd
- Submit a pull request to coreos/etcd.
- Your PR must receive a LGTM from two maintainers found in the MAINTAINERS file.
Thanks for you contributions!
Thanks for your contributions!
### Format of the commit message
### Code style
etcd follow a rough convention for commit messages borrowed from Angularjs.
This is an example of a commit:
The coding style suggested by the Golang community is used in etcd. See the [style doc](https://code.google.com/p/go-wiki/wiki/CodeReviewComments) for details.
Please follow this style to make etcd easy to review, maintain and develop.
### Format of the Commit Message
We follow a rough convention for commit messages that is designed to answer two
questions: what changed and why. The subject line should feature the what and
the body of the commit should describe the why.
```
feat(scripts/test-cluster): add a cluster test command
scripts: add the test-cluster command
this uses tmux to setup a test cluster that you can easily kill and
start for debugging.
this uses tmux to setup a test cluster that you can easily kill and
start for debugging.
Fixes #38
```
To make it more formal it looks something like this:
The format can be described more formally as follows:
```
<type>(<scope>): <subject>
<subsystem>: <what changed>
<BLANK LINE>
<body>
<why this change was made>
<BLANK LINE>
<footer>
```
The first line is the subject and should not be longer than 70 characters, the second line is always blank and other lines should be wrapped at 80 characters.
This allows the message to be easier to read on github as well as in various git tools.
### Subject line
The subject line contains succinct description of the change.
### Allowed <type>
feat (feature)
fix (bug fix)
docs (documentation)
style (formatting, missing semi colons, …)
refactor
test (when adding missing tests)
chore (maintain)
### Allowed <scope>
Scopes could be anything specifying place of the commit change. For example store, api, etc.
### More details on commits
For more details see the [angularjs commit style guide](https://docs.google.com/a/coreos.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#).
The first line is the subject and should be no longer than 70 characters, the
second line is always blank, and other lines should be wrapped at 80 characters.
This allows the message to be easier to read on GitHub as well as in various
git tools.

36
DCO Normal file
View File

@ -0,0 +1,36 @@
Developer Certificate of Origin
Version 1.1
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
660 York Street, Suite 102,
San Francisco, CA 94110 USA
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.

View File

@ -1,10 +1,2 @@
FROM ubuntu:12.04
RUN apt-get update
RUN apt-get install -y python-software-properties git
RUN add-apt-repository -y ppa:duh/golang
RUN apt-get update
RUN apt-get install -y golang
ADD . /opt/etcd
RUN cd /opt/etcd && ./build
EXPOSE 4001 7001
ENTRYPOINT ["/opt/etcd/etcd", "-c", "0.0.0.0:4001", "-s", "0.0.0.0:7001"]
FROM golang:onbuild
EXPOSE 4001 7001 2379 2380

View File

@ -0,0 +1,31 @@
## Snapshot Migration
You can migrate a snapshot of your data from a v0.4.9+ cluster into a new etcd 2.2 cluster using a snapshot migration. After snapshot migration, the etcd indexes of your data will change. Many etcd applications rely on these indexes to behave correctly. This operation should only be done while all etcd applications are stopped.
To get started get the newest data snapshot from the 0.4.9+ cluster:
```
curl http://cluster.example.com:4001/v2/migration/snapshot > backup.snap
```
Now, import the snapshot into your new cluster:
```
etcdctl --endpoint new_cluster.example.com import --snap backup.snap
```
If you have a large amount of data, you can specify more concurrent works to copy data in parallel by using `-c` flag.
If you have hidden keys to copy, you can use `--hidden` flag to specify.
And the data will quickly copy into the new cluster:
```
entering dir: /
entering dir: /foo
entering dir: /foo/bar
copying key: /foo/bar/1 1
entering dir: /
entering dir: /foo2
entering dir: /foo2/bar2
copying key: /foo2/bar2/2 2
```

View File

@ -0,0 +1,298 @@
## Administration
### Data Directory
#### Lifecycle
When first started, etcd stores its configuration into a data directory specified by the data-dir configuration parameter.
Configuration is stored in the write ahead log and includes: the local member ID, cluster ID, and initial cluster configuration.
The write ahead log and snapshot files are used during member operation and to recover after a restart.
Having a dedicated disk to store wal files can improve the throughput and stabilize the cluster.
It is highly recommended to dedicate a wal disk and set `--wal-dir` to point to a directory on that device for a production cluster deployment.
If a members data directory is ever lost or corrupted then the user should [remove][remove-a-member] the etcd member from the cluster using `etcdctl` tool.
A user should avoid restarting an etcd member with a data directory from an out-of-date backup.
Using an out-of-date data directory can lead to inconsistency as the member had agreed to store information via raft then re-joins saying it needs that information again.
For maximum safety, if an etcd member suffers any sort of data corruption or loss, it must be removed from the cluster.
Once removed the member can be re-added with an empty data directory.
[remove-a-member]: runtime-configuration.md#remove-a-member
#### Contents
The data directory has two sub-directories in it:
1. wal: write ahead log files are stored here. For details see the [wal package documentation][wal-pkg]
2. snap: log snapshots are stored here. For details see the [snap package documentation][snap-pkg]
If `--wal-dir` flag is set, etcd will write the write ahead log files to the specified directory instead of data directory.
[wal-pkg]: http://godoc.org/github.com/coreos/etcd/wal
[snap-pkg]: http://godoc.org/github.com/coreos/etcd/snap
### Cluster Management
#### Lifecycle
If you are spinning up multiple clusters for testing it is recommended that you specify a unique initial-cluster-token for the different clusters.
This can protect you from cluster corruption in case of mis-configuration because two members started with different cluster tokens will refuse members from each other.
#### Monitoring
It is important to monitor your production etcd cluster for healthy information and runtime metrics.
##### Health Monitoring
At lowest level, etcd exposes health information via HTTP at `/health` in JSON format. If it returns `{"health": "true"}`, then the cluster is healthy. Please note the `/health` endpoint is still an experimental one as in etcd 2.2.
```
$ curl -L http://127.0.0.1:2379/health
{"health": "true"}
```
You can also use etcdctl to check the cluster-wide health information. It will contact all the members of the cluster and collect the health information for you.
```
$./etcdctl cluster-health
member 8211f1d0f64f3269 is healthy: got healthy result from http://127.0.0.1:12379
member 91bc3c398fb3c146 is healthy: got healthy result from http://127.0.0.1:22379
member fd422379fda50e48 is healthy: got healthy result from http://127.0.0.1:32379
cluster is healthy
```
##### Runtime Metrics
etcd uses [Prometheus](http://prometheus.io/) for metrics reporting in the server. You can read more through the runtime metrics [doc](metrics.md).
#### Debugging
Debugging a distributed system can be difficult. etcd provides several ways to make debug
easier.
##### Enabling Debug Logging
When you want to debug etcd without stopping it, you can enable debug logging at runtime.
etcd exposes logging configuration at `/config/local/log`.
```
$ curl http://127.0.0.1:2379/config/local/log -XPUT -d '{"Level":"DEBUG"}'
$ # debug logging enabled
$
$ curl http://127.0.0.1:2379/config/local/log -XPUT -d '{"Level":"INFO"}'
$ # debug logging disabled
```
##### Debugging Variables
Debug variables are exposed for real-time debugging purposes. Developers who are familiar with etcd can utilize these variables to debug unexpected behavior. etcd exposes debug variables via HTTP at `/debug/vars` in JSON format. The debug variables contains
`cmdline`, `file_descriptor_limit`, `memstats` and `raft.status`.
`cmdline` is the command line arguments passed into etcd.
`file_descriptor_limit` is the max number of file descriptors etcd can utilize.
`memstats` is well explained [here](http://golang.org/pkg/runtime/#MemStats).
`raft.status` is useful when you want to debug low level raft issues if you are familiar with raft internals. In most cases, you do not need to check `raft.status`.
```json
{
"cmdline": ["./etcd"],
"file_descriptor_limit": 0,
"memstats": {"Alloc":4105744,"TotalAlloc":42337320,"Sys":12560632,"...":"..."},
"raft.status": {"id":"ce2a822cea30bfca","term":5,"vote":"ce2a822cea30bfca","commit":23509,"lead":"ce2a822cea30bfca","raftState":"StateLeader","progress":{"ce2a822cea30bfca":{"match":23509,"next":23510,"state":"ProgressStateProbe"}}}
}
```
#### Optimal Cluster Size
The recommended etcd cluster size is 3, 5 or 7, which is decided by the fault tolerance requirement. A 7-member cluster can provide enough fault tolerance in most cases. While larger cluster provides better fault tolerance the write performance reduces since data needs to be replicated to more machines.
#### Fault Tolerance Table
It is recommended to have an odd number of members in a cluster. Having an odd cluster size doesn't change the number needed for majority, but you gain a higher tolerance for failure by adding the extra member. You can see this in practice when comparing even and odd sized clusters:
| Cluster Size | Majority | Failure Tolerance |
|--------------|------------|-------------------|
| 1 | 1 | 0 |
| 3 | 2 | 1 |
| 4 | 3 | 1 |
| 5 | 3 | **2** |
| 6 | 4 | 2 |
| 7 | 4 | **3** |
| 8 | 5 | 3 |
| 9 | 5 | **4** |
As you can see, adding another member to bring the size of cluster up to an odd size is always worth it. During a network partition, an odd number of members also guarantees that there will almost always be a majority of the cluster that can continue to operate and be the source of truth when the partition ends.
#### Changing Cluster Size
After your cluster is up and running, adding or removing members is done via [runtime reconfiguration](runtime-configuration.md#cluster-reconfiguration-operations), which allows the cluster to be modified without downtime. The `etcdctl` tool has a `member list`, `member add` and `member remove` commands to complete this process.
### Member Migration
When there is a scheduled machine maintenance or retirement, you might want to migrate an etcd member to another machine without losing the data and changing the member ID.
The data directory contains all the data to recover a member to its point-in-time state. To migrate a member:
* Stop the member process
* Copy the data directory of the now-idle member to the new machine
* Update the peer URLs for that member to reflect the new machine according to the [runtime configuration] [change peer url]
* Start etcd on the new machine, using the same configuration and the copy of the data directory
This example will walk you through the process of migrating the infra1 member to a new machine:
|Name|Peer URL|
|------|--------------|
|infra0|10.0.1.10:2380|
|infra1|10.0.1.11:2380|
|infra2|10.0.1.12:2380|
```sh
$ export ETCDCTL_PEERS=http://10.0.1.10:2379,http://10.0.1.11:2379,http://10.0.1.12:2379
```
```sh
$ etcdctl member list
84194f7c5edd8b37: name=infra0 peerURLs=http://10.0.1.10:2380 clientURLs=http://127.0.0.1:2379,http://10.0.1.10:2379
b4db3bf5e495e255: name=infra1 peerURLs=http://10.0.1.11:2380 clientURLs=http://127.0.0.1:2379,http://10.0.1.11:2379
bc1083c870280d44: name=infra2 peerURLs=http://10.0.1.12:2380 clientURLs=http://127.0.0.1:2379,http://10.0.1.12:2379
```
#### Stop the member etcd process
```sh
$ ssh 10.0.1.11
```
```sh
$ kill `pgrep etcd`
```
#### Copy the data directory of the now-idle member to the new machine
```
$ tar -cvzf infra1.etcd.tar.gz %data_dir%
```
```sh
$ scp infra1.etcd.tar.gz 10.0.1.13:~/
```
#### Update the peer URLs for that member to reflect the new machine
```sh
$ curl http://10.0.1.10:2379/v2/members/b4db3bf5e495e255 -XPUT \
-H "Content-Type: application/json" -d '{"peerURLs":["http://10.0.1.13:2380"]}'
```
Or use `etcdctl member update` command
```sh
$ etcdctl member update b4db3bf5e495e255 http://10.0.1.13:2380
```
#### Start etcd on the new machine, using the same configuration and the copy of the data directory
```sh
$ ssh 10.0.1.13
```
```sh
$ tar -xzvf infra1.etcd.tar.gz -C %data_dir%
```
```
etcd -name infra1 \
-listen-peer-urls http://10.0.1.13:2380 \
-listen-client-urls http://10.0.1.13:2379,http://127.0.0.1:2379 \
-advertise-client-urls http://10.0.1.13:2379,http://127.0.0.1:2379
```
[change peer url]: runtime-configuration.md#update-a-member
### Disaster Recovery
etcd is designed to be resilient to machine failures. An etcd cluster can automatically recover from any number of temporary failures (for example, machine reboots), and a cluster of N members can tolerate up to _(N-1)/2_ permanent failures (where a member can no longer access the cluster, due to hardware failure or disk corruption). However, in extreme circumstances, a cluster might permanently lose enough members such that quorum is irrevocably lost. For example, if a three-node cluster suffered two simultaneous and unrecoverable machine failures, it would be normally impossible for the cluster to restore quorum and continue functioning.
To recover from such scenarios, etcd provides functionality to backup and restore the datastore and recreate the cluster without data loss.
#### Backing up the datastore
**NB:** Windows users must stop etcd before running the backup command.
The first step of the recovery is to backup the data directory on a functioning etcd node. To do this, use the `etcdctl backup` command, passing in the original data directory used by etcd. For example:
```sh
etcdctl backup \
--data-dir %data_dir% \
--backup-dir %backup_data_dir%
```
This command will rewrite some of the metadata contained in the backup (specifically, the node ID and cluster ID), which means that the node will lose its former identity. In order to recreate a cluster from the backup, you will need to start a new, single-node cluster. The metadata is rewritten to prevent the new node from inadvertently being joined onto an existing cluster.
#### Restoring a backup
To restore a backup using the procedure created above, start etcd with the `-force-new-cluster` option and pointing to the backup directory. This will initialize a new, single-member cluster with the default advertised peer URLs, but preserve the entire contents of the etcd data store. Continuing from the previous example:
```sh
etcd \
-data-dir=%backup_data_dir% \
-force-new-cluster \
...
```
Now etcd should be available on this node and serving the original datastore.
Once you have verified that etcd has started successfully, shut it down and move the data back to the previous location (you may wish to make another copy as well to be safe):
```sh
pkill etcd
rm -fr %data_dir%
mv %backup_data_dir% %data_dir%
etcd \
-data-dir=%data_dir% \
...
```
#### Restoring the cluster
Now that if the node is running successfully, you should [change its advertised peer URLs](runtime-configuration.md#update-a-member), as the `--force-new-cluster` has set the peer URL to the default (listening on localhost).
You can then add more nodes to the cluster and restore resiliency. See the [add a new member](runtime-configuration.md#add-a-new-member) guide for more details. **NB:** If you are trying to restore your cluster using old failed etcd nodes, please make sure you have stopped old etcd instances and removed their old data directories specified by the data-dir configuration parameter.
### Client Request Timeout
etcd sets different timeouts for various types of client requests. The timeout value is not tunable now, which will be improved soon (https://github.com/coreos/etcd/issues/2038).
#### Get requests
Timeout is not set for get requests, because etcd serves the result locally in a non-blocking way.
**Note**: QuorumGet request is a different type, which is mentioned in the following sections.
#### Watch requests
Timeout is not set for watch requests. etcd will not stop a watch request until client cancels it, or the connection is broken.
#### Delete, Put, Post, QuorumGet requests
The default timeout is 5 seconds. It should be large enough to allow all key modifications if the majority of cluster is functioning.
If the request times out, it indicates two possibilities:
1. the server the request sent to was not functioning at that time.
2. the majority of the cluster is not functioning.
If timeout happens several times continuously, administrators should check status of cluster and resolve it as soon as possible.
### Best Practices
#### Maximum OS threads
By default, etcd uses the default configuration of the Go 1.4 runtime, which means that at most one operating system thread will be used to execute code simultaneously. (Note that this default behavior [may change in Go 1.5](https://docs.google.com/document/d/1At2Ls5_fhJQ59kDK2DFVhFu3g5mATSXqqV5QrxinasI/edit)).
When using etcd in heavy-load scenarios on machines with multiple cores it will usually be desirable to increase the number of threads that etcd can utilize. To do this, simply set the environment variable `GOMAXPROCS` to the desired number when starting etcd. For more information on this variable, see the Go [runtime](https://golang.org/pkg/runtime) documentation.

1082
Documentation/api.md Normal file

File diff suppressed because it is too large Load Diff

434
Documentation/auth_api.md Normal file
View File

@ -0,0 +1,434 @@
# v2 Auth and Security
## etcd Resources
There are three types of resources in etcd
1. permission resources: users and roles in the user store
2. key-value resources: key-value pairs in the key-value store
3. settings resources: security settings, auth settings, and dynamic etcd cluster settings (election/heartbeat)
### Permission Resources
#### Users
A user is an identity to be authenticated. Each user can have multiple roles. The user has a capability (such as reading or writing) on the resource if one of the roles has that capability.
A user named `root` is required before authentication can be enabled, and it always has the ROOT role. The ROOT role can be granted to multiple users, but `root` is required for recovery purposes.
#### Roles
Each role has exact one associated Permission List. An permission list exists for each permission on key-value resources.
The special static ROOT (named `root`) role has a full permissions on all key-value resources, the permission to manage user resources and settings resources. Only the ROOT role has the permission to manage user resources and modify settings resources. The ROOT role is built-in and does not need to be created.
There is also a special GUEST role, named 'guest'. These are the permissions given to unauthenticated requests to etcd. This role will be created automatically, and by default allows access to the full keyspace due to backward compatability. (etcd did not previously authenticate any actions.). This role can be modified by a ROOT role holder at any time, to reduce the capabilities of unauthenticated users.
#### Permissions
There are two types of permissions, `read` and `write`. All management and settings require the ROOT role.
A Permission List is a list of allowed patterns for that particular permission (read or write). Only ALLOW prefixes are supported. DENY becomes more complicated and is TBD.
### Key-Value Resources
A key-value resource is a key-value pairs in the store. Given a list of matching patterns, permission for any given key in a request is granted if any of the patterns in the list match.
Only prefixes or exact keys are supported. A prefix permission string ends in `*`.
A permission on `/foo` is for that exact key or directory, not its children or recursively. `/foo*` is a prefix that matches `/foo` recursively, and all keys thereunder, and keys with that prefix (eg. `/foobar`. Contrast to the prefix `/foo/*`). `*` alone is permission on the full keyspace.
### Settings Resources
Specific settings for the cluster as a whole. This can include adding and removing cluster members, enabling or disabling authentication, replacing certificates, and any other dynamic configuration by the administrator (holder of the ROOT role).
## v2 Auth
### Basic Auth
We only support [Basic Auth](http://en.wikipedia.org/wiki/Basic_access_authentication) for the first version. Client needs to attach the basic auth to the HTTP Authorization Header.
### Authorization field for operations
Added to requests to /v2/keys, /v2/auth
Add code 401 Unauthorized to the set of responses from the v2 API
Authorization: Basic {encoded string}
### Future Work
Other types of auth can be considered for the future (eg, signed certs, public keys) but the `Authorization:` header allows for other such types
### Things out of Scope for etcd Permissions
* Pluggable AUTH backends like LDAP (other Authorization tokens generated by LDAP et al may be a possibility)
* Very fine-grained access controls (eg: users modifying keys outside work hours)
## API endpoints
An Error JSON corresponds to:
{
"name": "ErrErrorName",
"description" : "The longer helpful description of the error."
}
#### Enable and Disable Authentication
**Get auth status**
GET /v2/auth/enable
Sent Headers:
Possible Status Codes:
200 OK
200 Body:
{
"enabled": true
}
**Enable auth**
PUT /v2/auth/enable
Sent Headers:
Put Body: (empty)
Possible Status Codes:
200 OK
400 Bad Request (if root user has not been created)
409 Conflict (already enabled)
200 Body: (empty)
**Disable auth**
DELETE /v2/auth/enable
Sent Headers:
Authorization: Basic <RootAuthString>
Possible Status Codes:
200 OK
401 Unauthorized (if not a root user)
409 Conflict (already disabled)
200 Body: (empty)
#### Users
The User JSON object is formed as follows:
```
{
"user": "userName",
"password": "password",
"roles": [
"role1",
"role2"
],
"grant": [],
"revoke": []
}
```
Password is only passed when necessary.
**Get a list of users**
GET/HEAD /v2/auth/users
Sent Headers:
Authorization: Basic <BasicAuthString>
Possible Status Codes:
200 OK
401 Unauthorized
200 Headers:
Content-type: application/json
200 Body:
{
"users": ["alice", "bob", "eve"]
}
**Get User Details**
GET/HEAD /v2/auth/users/alice
Sent Headers:
Authorization: Basic <BasicAuthString>
Possible Status Codes:
200 OK
401 Unauthorized
404 Not Found
200 Headers:
Content-type: application/json
200 Body:
{
"user" : "alice",
"roles" : ["fleet", "etcd"]
}
**Create Or Update A User**
A user can be created with initial roles, if filled in. However, no roles are required; only the username and password fields
PUT /v2/auth/users/charlie
Sent Headers:
Authorization: Basic <BasicAuthString>
Put Body:
JSON struct, above, matching the appropriate name
* Starting password and roles when creating.
* Grant/Revoke/Password filled in when updating (to grant roles, revoke roles, or change the password).
Possible Status Codes:
200 OK
201 Created
400 Bad Request
401 Unauthorized
404 Not Found (update non-existent users)
409 Conflict (when granting duplicated roles or revoking non-existent roles)
200 Headers:
Content-type: application/json
200 Body:
JSON state of the user
**Remove A User**
DELETE /v2/auth/users/charlie
Sent Headers:
Authorization: Basic <BasicAuthString>
Possible Status Codes:
200 OK
401 Unauthorized
403 Forbidden (remove root user when auth is enabled)
404 Not Found
200 Headers:
200 Body: (empty)
#### Roles
A full role structure may look like this. A Permission List structure is used for the "permissions", "grant", and "revoke" keys.
```
{
"role" : "fleet",
"permissions" : {
"kv" : {
"read" : [ "/fleet/" ],
"write": [ "/fleet/" ]
}
},
"grant" : {"kv": {...}},
"revoke": {"kv": {...}}
}
```
**Get a list of Roles**
GET/HEAD /v2/auth/roles
Sent Headers:
Authorization: Basic <BasicAuthString>
Possible Status Codes:
200 OK
401 Unauthorized
200 Headers:
Content-type: application/json
200 Body:
{
"roles": ["fleet", "etcd", "quay"]
}
**Get Role Details**
GET/HEAD /v2/auth/roles/fleet
Sent Headers:
Authorization: Basic <BasicAuthString>
Possible Status Codes:
200 OK
401 Unauthorized
404 Not Found
200 Headers:
Content-type: application/json
200 Body:
{
"role" : "fleet",
"permissions" : {
"kv" : {
"read": [ "/fleet/" ],
"write": [ "/fleet/" ]
}
}
}
**Create Or Update A Role**
PUT /v2/auth/roles/rkt
Sent Headers:
Authorization: Basic <BasicAuthString>
Put Body:
Initial desired JSON state, including the role name for verification and:
* Starting permission set if creating
* Granted/Revoked permission set if updating
Possible Status Codes:
200 OK
201 Created
400 Bad Request
401 Unauthorized
404 Not Found (update non-existent roles)
409 Conflict (when granting duplicated permission or revoking non-existent permission)
200 Body:
JSON state of the role
**Remove A Role**
DELETE /v2/auth/roles/rkt
Sent Headers:
Authorization: Basic <BasicAuthString>
Possible Status Codes:
200 OK
401 Unauthorized
403 Forbidden (remove root)
404 Not Found
200 Headers:
200 Body: (empty)
## Example Workflow
Let's walk through an example to show two tenants (applications, in our case) using etcd permissions.
### Create root role
```
PUT /v2/auth/users/root
Put Body:
{"user" : "root", "password": "betterRootPW!"}
```
### Enable auth
```
PUT /v2/auth/enable
```
### Modify guest role (revoke write permission)
```
PUT /v2/auth/roles/guest
Headers:
Authorization: Basic <root:betterRootPW!>
Put Body:
{
"role" : "guest",
"revoke" : {
"kv" : {
"write": [
"*"
]
}
}
}
```
### Create Roles for the Applications
Create the rkt role fully specified:
```
PUT /v2/auth/roles/rkt
Headers:
Authorization: Basic <root:betterRootPW!>
Body:
{
"role" : "rkt",
"permissions" : {
"kv": {
"read": [
"/rkt/*"
],
"write": [
"/rkt/*"
]
}
}
}
```
But let's make fleet just a basic role for now:
```
PUT /v2/auth/roles/fleet
Headers:
Authorization: Basic <root:betterRootPW!>
Body:
{
"role" : "fleet"
}
```
### Optional: Grant some permissions to the roles
Well, we finally figured out where we want fleet to live. Let's fix it.
(Note that we avoided this in the rkt case. So this step is optional.)
```
PUT /v2/auth/roles/fleet
Headers:
Authorization: Basic <root:betterRootPW!>
Put Body:
{
"role" : "fleet",
"grant" : {
"kv" : {
"read": [
"/rkt/fleet",
"/fleet/*"
]
}
}
}
```
### Create Users
Same as before, let's use rocket all at once and fleet separately
```
PUT /v2/auth/users/rktuser
Headers:
Authorization: Basic <root:betterRootPW!>
Body:
{"user" : "rktuser", "password" : "rktpw", "roles" : ["rkt"]}
```
```
PUT /v2/auth/users/fleetuser
Headers:
Authorization: Basic <root:betterRootPW!>
Body:
{"user" : "fleetuser", "password" : "fleetpw"}
```
### Optional: Grant Roles to Users
Likewise, let's explicitly grant fleetuser access.
```
PUT /v2/auth/users/fleetuser
Headers:
Authorization: Basic <root:betterRootPW!>
Body:
{"user": "fleetuser", "grant": ["fleet"]}
```
#### Start to use fleetuser and rktuser
For example:
```
PUT /v2/keys/rkt/RktData
Headers:
Authorization: Basic <rktuser:rktpw>
Body:
value=launch
```
Reads and writes outside the prefixes granted will fail with a 401 Unauthorized.

View File

@ -0,0 +1,179 @@
# Authentication Guide
**NOTE: The authentication feature is considered experimental. We may change workflow without warning in future releases.**
## Overview
Authentication -- having users and roles in etcd -- was added in etcd 2.1. This guide will help you set up basic authentication in etcd.
etcd before 2.1 was a completely open system; anyone with access to the API could change keys. In order to preserve backward compatibility and upgradability, this feature is off by default.
For a full discussion of the RESTful API, see [the authentication API documentation](auth_api.md)
## Special Users and Roles
There is one special user, `root`, and there are two special roles, `root` and `guest`.
### User `root`
User `root` must be created before security can be activated. It has the `root` role and allows for the changing of anything inside etcd. The idea behind the `root` user is for recovery purposes -- a password is generated and stored somewhere -- and the root role is granted to the administrator accounts on the system. In the future, for troubleshooting and recovery, we will need to assume some access to the system, and future documentation will assume this root user (though anyone with the role will suffice).
### Role `root`
Role `root` cannot be modified, but it may be granted to any user. Having access via the root role not only allows global read-write access (as was the case before 2.1) but allows modification of the authentication policy and all administrative things, like modifying the cluster membership.
### Role `guest`
The `guest` role defines the permissions granted to any request that does not provide an authentication. This will be created on security activation (if it doesn't already exist) to have full access to all keys, as was true in etcd 2.0. It may be modified at any time, and cannot be removed.
## Working with users
The `user` subcommand for `etcdctl` handles all things having to do with user accounts.
A listing of users can be found with
```
$ etcdctl user list
```
Creating a user is as easy as
```
$ etcdctl user add myusername
```
And there will be prompt for a new password.
Roles can be granted and revoked for a user with
```
$ etcdctl user grant myusername -roles foo,bar,baz
$ etcdctl user revoke myusername -roles bar,baz
```
We can look at this user with
```
$ etcdctl user get myusername
```
And the password for a user can be changed with
```
$ etcdctl user passwd myusername
```
Which will prompt again for a new password.
To delete an account, there's always
```
$ etcdctl user remove myusername
```
## Working with roles
The `role` subcommand for `etcdctl` handles all things having to do with access controls for particular roles, as were granted to individual users.
A listing of roles can be found with
```
$ etcdctl role list
```
A new role can be created with
```
$ etcdctl role add myrolename
```
A role has no password; we are merely defining a new set of access rights.
Roles are granted access to various parts of the keyspace, a single path at a time.
Reading a path is simple; if the path ends in `*`, that key **and all keys prefixed with it**, are granted to holders of this role. If it does not end in `*`, only that key and that key alone is granted.
Access can be granted as either read, write, or both, as in the following examples:
```
# Give read access to keys under the /foo directory
$ etcdctl role grant myrolename -path '/foo/*' -read
# Give write-only access to the key at /foo/bar
$ etcdctl role grant myrolename -path '/foo/bar' -write
# Give full access to keys under /pub
$ etcdctl role grant myrolename -path '/pub/*' -readwrite
```
Beware that
```
# Give full access to keys under /pub??
$ etcdctl role grant myrolename -path '/pub*' -readwrite
```
Without the slash may include keys under `/publishing`, for example. To do both, grant `/pub` and `/pub/*`
To see what's granted, we can look at the role at any time:
```
$ etcdctl role get myrolename
```
Revocation of permissions is done the same logical way:
```
$ etcdctl role revoke myrolename -path '/foo/bar' -write
```
As is removing a role entirely
```
$ etcdctl role remove myrolename
```
## Enabling authentication
The minimal steps to enabling auth follow. The administrator can set up users and roles before or after enabling authentication, as a matter of preference.
Make sure the root user is created:
```
$ etcdctl user add root
New password:
```
And enable authentication
```
$ etcdctl auth enable
```
After this, etcd is running with authentication enabled. To disable it for any reason, use the reciprocal command:
```
$ etcdctl -u root:rootpw auth disable
```
It would also be good to check what guests (unauthenticated users) are allowed to do:
```
$ etcdctl -u root:rootpw role get guest
```
And modify this role appropriately, depending on your policies.
## Using `etcdctl` to authenticate
`etcdctl` supports a similar flag as `curl` for authentication.
```
$ etcdctl -u user:password get foo
```
or if you prefer to be prompted:
```
$ etcdctl -u user get foo
```
Otherwise, all `etcdctl` commands remain the same. Users and roles can still be created and modified, but require authentication by a user with the root role.

View File

@ -0,0 +1,71 @@
# Backward Compatibility
The main goal of etcd 2.0 release is to improve cluster safety around bootstrapping and dynamic reconfiguration. To do this, we deprecated the old error-prone APIs and provide a new set of APIs.
The other main focus of this release was a more reliable Raft implementation, but as this change is internal it should not have any notable effects to users.
## Command Line Flags Changes
The major flag changes are to mostly related to bootstrapping. The `initial-*` flags provide an improved way to specify the required criteria to start the cluster. The advertised URLs now support a list of values instead of a single value, which allows etcd users to gracefully migrate to the new set of IANA-assigned ports (2379/client and 2380/peers) while maintaining backward compatibility with the old ports.
- `-addr` is replaced by `-advertise-client-urls`.
- `-bind-addr` is replaced by `-listen-client-urls`.
- `-peer-addr` is replaced by `-initial-advertise-peer-urls`.
- `-peer-bind-addr` is replaced by `-listen-peer-urls`.
- `-peers` is replaced by `-initial-cluster`.
- `-peers-file` is replaced by `-initial-cluster`.
- `-peer-heartbeat-interval` is replaced by `-heartbeat-interval`.
- `-peer-election-timeout` is replaced by `-election-timeout`.
The documentation of new command line flags can be found at
https://github.com/coreos/etcd/blob/master/Documentation/configuration.md.
## Data Directory Naming
The default data dir location has changed from {$hostname}.etcd to {name}.etcd.
## Key-Value API
### Read consistency flag
The consistent flag for read operations is removed in etcd 2.0.0. The normal read operations provides the same consistency guarantees with the 0.4.6 read operations with consistent flag set.
The read consistency guarantees are:
The consistent read guarantees the sequential consistency within one client that talks to one etcd server. Read/Write from one client to one etcd member should be observed in order. If one client write a value to a etcd server successfully, it should be able to get the value out of the server immediately.
Each etcd member will proxy the request to leader and only return the result to user after the result is applied on the local member. Thus after the write succeed, the user is guaranteed to see the value on the member it sent the request to.
Reads do not provide linearizability. If you want linearizable read, you need to set quorum option to true.
**Previous behavior**
We added an option for a consistent read in the old version of etcd since etcd 0.x redirects the write request to the leader. When the user get back the result from the leader, the member it sent the request to originally might not apply the write request yet. With the consistent flag set to true, the client will always send read request to the leader. So one client should be able to see its last write when consistent=true is enabled. There is no order guarantees among different clients.
## Standby
etcd 0.4s standby mode has been deprecated. [Proxy mode][proxymode] is introduced to solve a subset of problems standby was solving.
Standby mode was intended for large clusters that had a subset of the members acting in the consensus process. Overall this process was too magical and allowed for operators to back themselves into a corner.
Proxy mode in 2.0 will provide similar functionality, and with improved control over which machines act as proxies due to the operator specifically configuring them. Proxies also support read only or read/write modes for increased security and durability.
[proxymode]: proxy.md
## Discovery Service
A size key needs to be provided inside a [discovery token][discoverytoken].
[discoverytoken]: clustering.md#custom-etcd-discovery-service
## HTTP Admin API
`v2/admin` on peer url and `v2/keys/_etcd` are unified under the new [v2/member API][memberapi] to better explain which machines are part of an etcd cluster, and to simplify the keyspace for all your use cases.
[memberapi]: other_apis.md
## HTTP Key Value API
- The follower can now transparently proxy write requests to the leader. Clients will no longer see 307 redirections to the leader from etcd.
- Expiration time is in UTC instead of local time.

View File

@ -0,0 +1,13 @@
# Benchmarks
etcd benchmarks will be published regularly and tracked for each release below:
- [etcd v2.1.0-alpha](./etcd-2-1-0-alpha-benchmarks.md)
- [etcd v2.2.0-rc](./etcd-2-2-0-rc-benchmarks.md)
- [etcd v3 demo](./etcd-3-demo-benchmarks.md)
# Memory Usage Benchmarks
It records expected memory usage in different scenarios.
- [etcd v2.2.0-rc](./etcd-2-2-0-rc-memory-benchmarks.md)

View File

@ -0,0 +1,49 @@
## Physical machines
GCE n1-highcpu-2 machine type
- 1x dedicated local SSD mounted under /var/lib/etcd
- 1x dedicated slow disk for the OS
- 1.8 GB memory
- 2x CPUs
- etcd version 2.1.0 alpha
## etcd Cluster
3 etcd members, each runs on a single machine
## Testing
Bootstrap another machine and use benchmark tool [boom](https://github.com/rakyll/boom) to send requests to each etcd member.
## Performance
### reading one single key
| key size in bytes | number of clients | target etcd server | read QPS | 90th Percentile Latency (ms) |
|-------------------|-------------------|--------------------|----------|---------------|
| 64 | 1 | leader only | 1534 | 0.7 |
| 64 | 64 | leader only | 10125 | 9.1 |
| 64 | 256 | leader only | 13892 | 27.1 |
| 256 | 1 | leader only | 1530 | 0.8 |
| 256 | 64 | leader only | 10106 | 10.1 |
| 256 | 256 | leader only | 14667 | 27.0 |
| 64 | 64 | all servers | 24200 | 3.9 |
| 64 | 256 | all servers | 33300 | 11.8 |
| 256 | 64 | all servers | 24800 | 3.9 |
| 256 | 256 | all servers | 33000 | 11.5 |
### writing one single key
| key size in bytes | number of clients | target etcd server | write QPS | 90th Percentile Latency (ms) |
|-------------------|-------------------|--------------------|-----------|---------------|
| 64 | 1 | leader only | 60 | 21.4 |
| 64 | 64 | leader only | 1742 | 46.8 |
| 64 | 256 | leader only | 3982 | 90.5 |
| 256 | 1 | leader only | 58 | 20.3 |
| 256 | 64 | leader only | 1770 | 47.8 |
| 256 | 256 | leader only | 4157 | 105.3 |
| 64 | 64 | all servers | 1028 | 123.4 |
| 64 | 256 | all servers | 3260 | 123.8 |
| 256 | 64 | all servers | 1033 | 121.5 |
| 256 | 256 | all servers | 3061 | 119.3 |

View File

@ -0,0 +1,67 @@
## Physical machines
GCE n1-highcpu-2 machine type
- 1x dedicated local SSD mounted under /var/lib/etcd
- 1x dedicated slow disk for the OS
- 1.8 GB memory
- 2x CPUs
## etcd Cluster
3 etcd 2.2.0-rc members, each runs on a single machine.
Detailed versions:
```
etcd Version: 2.2.0-alpha.1+git
Git SHA: 59a5a7e
Go Version: go1.4.2
Go OS/Arch: linux/amd64
```
Also, we use 3 etcd 2.1.0 alpha-stage members to form cluster to get base performance. etcd's commit head is at [c7146bd5](https://github.com/coreos/etcd/commits/c7146bd5f2c73716091262edc638401bb8229144), which is the same as the one that we use in [etcd 2.1 benchmark](./etcd-2-1-0-benchmarks.md).
## Testing
Bootstrap another machine and use benchmark tool [boom](https://github.com/rakyll/boom) to send requests to each etcd member. Check [here](../../hack/benchmark/) for instructions.
## Performance
### reading one single key
| key size in bytes | number of clients | target etcd server | read QPS | 90th Percentile Latency (ms) |
|-------------------|-------------------|--------------------|----------|---------------|
| 64 | 1 | leader only | 2804 (-5%) | 0.4 (+0%) |
| 64 | 64 | leader only | 17816 (+0%) | 5.7 (-6%) |
| 64 | 256 | leader only | 18667 (-6%) | 20.4 (+2%) |
| 256 | 1 | leader only | 2181 (-15%) | 0.5 (+25%) |
| 256 | 64 | leader only | 17435 (-7%) | 6.0 (+9%) |
| 256 | 256 | leader only | 18180 (-8%) | 21.3 (+3%) |
| 64 | 64 | all servers | 46965 (-4%) | 2.1 (+0%) |
| 64 | 256 | all servers | 55286 (-6%) | 7.4 (+6%) |
| 256 | 64 | all servers | 46603 (-6%) | 2.1 (+5%) |
| 256 | 256 | all servers | 55291 (-6%) | 7.3 (+4%) |
### writing one single key
| key size in bytes | number of clients | target etcd server | write QPS | 90th Percentile Latency (ms) |
|-------------------|-------------------|--------------------|-----------|---------------|
| 64 | 1 | leader only | 76 (+22%) | 19.4 (-15%) |
| 64 | 64 | leader only | 2461 (+45%) | 31.8 (-32%) |
| 64 | 256 | leader only | 4275 (+1%) | 69.6 (-10%) |
| 256 | 1 | leader only | 64 (+20%) | 16.7 (-30%) |
| 256 | 64 | leader only | 2385 (+30%) | 31.5 (-19%) |
| 256 | 256 | leader only | 4353 (-3%) | 74.0 (+9%) |
| 64 | 64 | all servers | 2005 (+81%) | 49.8 (-55%) |
| 64 | 256 | all servers | 4868 (+35%) | 81.5 (-40%) |
| 256 | 64 | all servers | 1925 (+72%) | 47.7 (-59%) |
| 256 | 256 | all servers | 4975 (+36%) | 70.3 (-36%) |
### performance changes explanation
- read QPS in most scenarios is decreased by 5~8%. The reason is that etcd records store metrics for each store operation. The metrics is important for monitoring and debugging, so this is acceptable.
- write QPS to leader is increased by 20~30%. This is because we decouple raft main loop and entry apply loop, which avoids them blocking each other.
- write QPS to all servers is increased by 30~80% because follower could receive latest commit index earlier and commit proposals faster.

View File

@ -0,0 +1,47 @@
## Physical machine
GCE n1-standard-2 machine type
- 1x dedicated local SSD mounted under /var/lib/etcd
- 1x dedicated slow disk for the OS
- 7.5 GB memory
- 2x CPUs
## etcd
```
etcd Version: 2.2.0-rc.0+git
Git SHA: 103cb5c
Go Version: go1.5
Go OS/Arch: linux/amd64
```
## Testing
Start 3-member etcd cluster, each of which uses 2 cores.
The length of key name is always 64 bytes, which is a reasonable length of average key bytes.
## Memory Maximal Usage
- etcd may use maximal memory if one follower is dead and the leader keeps sending snapshots.
- `max RSS` is the maximal memory usage recorded in 3 runs.
| value bytes | key number | data size(MB) | max RSS(MB) | max RSS/data rate on leader |
|-------------|-------------|---------------|-------------|-----------------------------|
| 128 | 50000 | 6 | 433 | 72x |
| 128 | 100000 | 12 | 659 | 54x |
| 128 | 200000 | 24 | 1466 | 61x |
| 1024 | 50000 | 48 | 1253 | 26x |
| 1024 | 100000 | 96 | 2344 | 24x |
| 1024 | 200000 | 192 | 4361 | 22x |
## Data Size Threshold
- When etcd reaches data size threshold, it may trigger leader election easily and drop part of proposals.
- At most cases, etcd cluster should work smoothly if it doesn't hit the threshold. If it doesn't work well due to insufficient resources, you need to decrease its data size.
| value bytes | key number limitation | suggested data size threshold(MB) | consumed RSS(MB) |
|-------------|-----------------------|-----------------------------------|------------------|
| 128 | 400K | 48 | 2400 |
| 1024 | 300K | 292 | 6500 |

View File

@ -0,0 +1,40 @@
## Physical machines
GCE n1-highcpu-2 machine type
- 1x dedicated local SSD mounted under /var/lib/etcd
- 1x dedicated slow disk for the OS
- 1.8 GB memory
- 2x CPUs
- etcd version 2.2.0
## etcd Cluster
1 etcd member running in v3 demo mode
## Testing
Use [etcd v3 benchmark tool](../../hack/v3benchmark/).
## Performance
### reading one single key
| key size in bytes | number of clients | read QPS | 90th Percentile Latency (ms) |
|-------------------|-------------------|----------|---------------|
| 256 | 1 | 2716 | 0.4 |
| 256 | 64 | 16623 | 6.1 |
| 256 | 256 | 16622 | 21.7 |
The performance is nearly the same as the one with empty server handler.
### reading one single key after putting
| key size in bytes | number of clients | read QPS | 90th Percentile Latency (ms) |
|-------------------|-------------------|----------|---------------|
| 256 | 1 | 2269 | 0.5 |
| 256 | 64 | 13582 | 8.6 |
| 256 | 256 | 13262 | 47.5 |
The performance with empty server handler is not affected by one put. So the
performance downgrade should be caused by storage package.

View File

@ -0,0 +1,24 @@
## Branch Management
### Guide
- New development occurs on the [master branch](https://github.com/coreos/etcd/tree/master)
- Master branch should always have a green build!
- Backwards-compatible bug fixes should target the master branch and subsequently be ported to stable branches
- Once the master branch is ready for release, it will be tagged and become the new stable branch.
The etcd team has adopted a _rolling release model_ and supports one stable version of etcd.
### Master branch
The `master` branch is our development branch. All new features land here first.
If you want to try new features, pull `master` and play with it. Note that `master` may not be stable because new features may introduce bugs.
Before the release of the next stable version, feature PRs will be frozen. We will focus on the testing, bug-fix and documentation for one to two weeks.
### Stable branches
All branches with prefix `release-` are considered _stable_ branches.
After every minor release (http://semver.org/), we will have a new stable branch for that release. We will keep fixing the backwards-compatible bugs for the latest stable release, but not previous releases. The _patch_ release, incorporating any bug fixes, will be once every two weeks, given any patches.

402
Documentation/clustering.md Normal file
View File

@ -0,0 +1,402 @@
# Clustering Guide
## Overview
Starting an etcd cluster statically requires that each member knows another in the cluster. In a number of cases, you might not know the IPs of your cluster members ahead of time. In these cases, you can bootstrap an etcd cluster with the help of a discovery service.
Once an etcd cluster is up and running, adding or removing members is done via [runtime reconfiguration](runtime-configuration.md). To better understand the design behind runtime reconfiguration, we suggest you read [this](runtime-reconf-design.md).
This guide will cover the following mechanisms for bootstrapping an etcd cluster:
* [Static](#static)
* [etcd Discovery](#etcd-discovery)
* [DNS Discovery](#dns-discovery)
Each of the bootstrapping mechanisms will be used to create a three machine etcd cluster with the following details:
|Name|Address|Hostname|
|------|---------|------------------|
|infra0|10.0.1.10|infra0.example.com|
|infra1|10.0.1.11|infra1.example.com|
|infra2|10.0.1.12|infra2.example.com|
## Static
As we know the cluster members, their addresses and the size of the cluster before starting, we can use an offline bootstrap configuration by setting the `initial-cluster` flag. Each machine will get either the following command line or environment variables:
```
ETCD_INITIAL_CLUSTER="infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380"
ETCD_INITIAL_CLUSTER_STATE=new
```
```
-initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380 \
-initial-cluster-state new
```
Note that the URLs specified in `initial-cluster` are the _advertised peer URLs_, i.e. they should match the value of `initial-advertise-peer-urls` on the respective nodes.
If you are spinning up multiple clusters (or creating and destroying a single cluster) with same configuration for testing purpose, it is highly recommended that you specify a unique `initial-cluster-token` for the different clusters. By doing this, etcd can generate unique cluster IDs and member IDs for the clusters even if they otherwise have the exact same configuration. This can protect you from cross-cluster-interaction, which might corrupt your clusters.
etcd listens on [`listen-client-urls`](configuration.md#-listen-client-urls) to accept client traffic. etcd member advertises the URLs specified in [`advertise-client-urls`](configuration.md#-advertise-client-urls) to other members, proxies, clients. Please make sure the `advertise-client-urls` are reachable from intended clients. A common mistake is setting `advertise-client-urls` to localhost or leave it as default when you want the remote clients to reach etcd.
On each machine you would start etcd with these flags:
```
$ etcd -name infra0 -initial-advertise-peer-urls http://10.0.1.10:2380 \
-listen-peer-urls http://10.0.1.10:2380 \
-listen-client-urls http://10.0.1.10:2379,http://127.0.0.1:2379 \
-advertise-client-urls http://10.0.1.10:2379 \
-initial-cluster-token etcd-cluster-1 \
-initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380 \
-initial-cluster-state new
```
```
$ etcd -name infra1 -initial-advertise-peer-urls http://10.0.1.11:2380 \
-listen-peer-urls http://10.0.1.11:2380 \
-listen-client-urls http://10.0.1.11:2379,http://127.0.0.1:2379 \
-advertise-client-urls http://10.0.1.11:2379 \
-initial-cluster-token etcd-cluster-1 \
-initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380 \
-initial-cluster-state new
```
```
$ etcd -name infra2 -initial-advertise-peer-urls http://10.0.1.12:2380 \
-listen-peer-urls http://10.0.1.12:2380 \
-listen-client-urls http://10.0.1.12:2379,http://127.0.0.1:2379 \
-advertise-client-urls http://10.0.1.12:2379 \
-initial-cluster-token etcd-cluster-1 \
-initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380 \
-initial-cluster-state new
```
The command line parameters starting with `-initial-cluster` will be ignored on subsequent runs of etcd. You are free to remove the environment variables or command line flags after the initial bootstrap process. If you need to make changes to the configuration later (for example, adding or removing members to/from the cluster), see the [runtime configuration](runtime-configuration.md) guide.
### Error Cases
In the following example, we have not included our new host in the list of enumerated nodes. If this is a new cluster, the node _must_ be added to the list of initial cluster members.
```
$ etcd -name infra1 -initial-advertise-peer-urls http://10.0.1.11:2380 \
-listen-peer-urls https://10.0.1.11:2380 \
-listen-client-urls http://10.0.1.11:2379,http://127.0.0.1:2379 \
-advertise-client-urls http://10.0.1.11:2379 \
-initial-cluster infra0=http://10.0.1.10:2380 \
-initial-cluster-state new
etcd: infra1 not listed in the initial cluster config
exit 1
```
In this example, we are attempting to map a node (infra0) on a different address (127.0.0.1:2380) than its enumerated address in the cluster list (10.0.1.10:2380). If this node is to listen on multiple addresses, all addresses _must_ be reflected in the "initial-cluster" configuration directive.
```
$ etcd -name infra0 -initial-advertise-peer-urls http://127.0.0.1:2380 \
-listen-peer-urls http://10.0.1.10:2380 \
-listen-client-urls http://10.0.1.10:2379,http://127.0.0.1:2379 \
-advertise-client-urls http://10.0.1.10:2379 \
-initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380 \
-initial-cluster-state=new
etcd: error setting up initial cluster: infra0 has different advertised URLs in the cluster and advertised peer URLs list
exit 1
```
If you configure a peer with a different set of configuration and attempt to join this cluster you will get a cluster ID mismatch and etcd will exit.
```
$ etcd -name infra3 -initial-advertise-peer-urls http://10.0.1.13:2380 \
-listen-peer-urls http://10.0.1.13:2380 \
-listen-client-urls http://10.0.1.13:2379,http://127.0.0.1:2379 \
-advertise-client-urls http://10.0.1.13:2379 \
-initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra3=http://10.0.1.13:2380 \
-initial-cluster-state=new
etcd: conflicting cluster ID to the target cluster (c6ab534d07e8fcc4 != bc25ea2a74fb18b0). Exiting.
exit 1
```
## Discovery
In a number of cases, you might not know the IPs of your cluster peers ahead of time. This is common when utilizing cloud providers or when your network uses DHCP. In these cases, rather than specifying a static configuration, you can use an existing etcd cluster to bootstrap a new one. We call this process "discovery".
There two methods that can be used for discovery:
* etcd discovery service
* DNS SRV records
### etcd Discovery
To better understand the design about discovery service protocol, we suggest you read [this](./discovery_protocol.md).
#### Lifetime of a Discovery URL
A discovery URL identifies a unique etcd cluster. Instead of reusing a discovery URL, you should always create discovery URLs for new clusters.
Moreover, discovery URLs should ONLY be used for the initial bootstrapping of a cluster. To change cluster membership after the cluster is already running, see the [runtime reconfiguration][runtime] guide.
[runtime]: runtime-configuration.md
#### Custom etcd Discovery Service
Discovery uses an existing cluster to bootstrap itself. If you are using your own etcd cluster you can create a URL like so:
```
$ curl -X PUT https://myetcd.local/v2/keys/discovery/6c007a14875d53d9bf0ef5a6fc0257c817f0fb83/_config/size -d value=3
```
By setting the size key to the URL, you create a discovery URL with an expected cluster size of 3.
If you bootstrap an etcd cluster using discovery service with more than the expected number of etcd members, the extra etcd processes will [fall back][fall-back] to being [proxies][proxy] by default.
The URL you will use in this case will be `https://myetcd.local/v2/keys/discovery/6c007a14875d53d9bf0ef5a6fc0257c817f0fb83` and the etcd members will use the `https://myetcd.local/v2/keys/discovery/6c007a14875d53d9bf0ef5a6fc0257c817f0fb83` directory for registration as they start.
Each member must have a different name flag specified. Or discovery will fail due to duplicated name.
Now we start etcd with those relevant flags for each member:
```
$ etcd -name infra0 -initial-advertise-peer-urls http://10.0.1.10:2380 \
-listen-peer-urls http://10.0.1.10:2380 \
-listen-client-urls http://10.0.1.10:2379,http://127.0.0.1:2379 \
-advertise-client-urls http://10.0.1.10:2379 \
-discovery https://myetcd.local/v2/keys/discovery/6c007a14875d53d9bf0ef5a6fc0257c817f0fb83
```
```
$ etcd -name infra1 -initial-advertise-peer-urls http://10.0.1.11:2380 \
-listen-peer-urls http://10.0.1.11:2380 \
-listen-client-urls http://10.0.1.11:2379,http://127.0.0.1:2379 \
-advertise-client-urls http://10.0.1.11:2379 \
-discovery https://myetcd.local/v2/keys/discovery/6c007a14875d53d9bf0ef5a6fc0257c817f0fb83
```
```
$ etcd -name infra2 -initial-advertise-peer-urls http://10.0.1.12:2380 \
-listen-peer-urls http://10.0.1.12:2380 \
-listen-client-urls http://10.0.1.12:2379,http://127.0.0.1:2379 \
-advertise-client-urls http://10.0.1.12:2379 \
-discovery https://myetcd.local/v2/keys/discovery/6c007a14875d53d9bf0ef5a6fc0257c817f0fb83
```
This will cause each member to register itself with the custom etcd discovery service and begin the cluster once all machines have been registered.
#### Public etcd Discovery Service
If you do not have access to an existing cluster, you can use the public discovery service hosted at `discovery.etcd.io`. You can create a private discovery URL using the "new" endpoint like so:
```
$ curl https://discovery.etcd.io/new?size=3
https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de
```
This will create the cluster with an initial expected size of 3 members. If you do not specify a size, a default of 3 will be used.
If you bootstrap an etcd cluster using discovery service with more than the expected number of etcd members, the extra etcd processes will [fall back][fall-back] to being [proxies][proxy] by default.
[fall-back]: proxy.md#fallback-to-proxy-mode-with-discovery-service
[proxy]: proxy.md
```
ETCD_DISCOVERY=https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de
```
```
-discovery https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de
```
Each member must have a different name flag specified. Or discovery will fail due to duplicated name.
Now we start etcd with those relevant flags for each member:
```
$ etcd -name infra0 -initial-advertise-peer-urls http://10.0.1.10:2380 \
-listen-peer-urls http://10.0.1.10:2380 \
-listen-client-urls http://10.0.1.10:2379,http://127.0.0.1:2379 \
-advertise-client-urls http://10.0.1.10:2379 \
-discovery https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de
```
```
$ etcd -name infra1 -initial-advertise-peer-urls http://10.0.1.11:2380 \
-listen-peer-urls http://10.0.1.11:2380 \
-listen-client-urls http://10.0.1.11:2379,http://127.0.0.1:2379 \
-advertise-client-urls http://10.0.1.11:2379 \
-discovery https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de
```
```
$ etcd -name infra2 -initial-advertise-peer-urls http://10.0.1.12:2380 \
-listen-peer-urls http://10.0.1.12:2380 \
-listen-client-urls http://10.0.1.12:2379,http://127.0.0.1:2379 \
-advertise-client-urls http://10.0.1.12:2379 \
-discovery https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de
```
This will cause each member to register itself with the discovery service and begin the cluster once all members have been registered.
You can use the environment variable `ETCD_DISCOVERY_PROXY` to cause etcd to use an HTTP proxy to connect to the discovery service.
#### Error and Warning Cases
##### Discovery Server Errors
```
$ etcd -name infra0 -initial-advertise-peer-urls http://10.0.1.10:2380 \
-listen-peer-urls http://10.0.1.10:2380 \
-listen-client-urls http://10.0.1.10:2379,http://127.0.0.1:2379 \
-advertise-client-urls http://10.0.1.10:2379 \
-discovery https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de
etcd: error: the cluster doesnt have a size configuration value in https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de/_config
exit 1
```
##### User Errors
This error will occur if the discovery cluster already has the configured number of members, and `discovery-fallback` is explicitly disabled
```
$ etcd -name infra0 -initial-advertise-peer-urls http://10.0.1.10:2380 \
-listen-peer-urls http://10.0.1.10:2380 \
-listen-client-urls http://10.0.1.10:2379,http://127.0.0.1:2379 \
-advertise-client-urls http://10.0.1.10:2379 \
-discovery https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de \
-discovery-fallback exit
etcd: discovery: cluster is full
exit 1
```
##### Warnings
This is a harmless warning notifying you that the discovery URL will be
ignored on this machine.
```
$ etcd -name infra0 -initial-advertise-peer-urls http://10.0.1.10:2380 \
-listen-peer-urls http://10.0.1.10:2380 \
-listen-client-urls http://10.0.1.10:2379,http://127.0.0.1:2379 \
-advertise-client-urls http://10.0.1.10:2379 \
-discovery https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de
etcdserver: discovery token ignored since a cluster has already been initialized. Valid log found at /var/lib/etcd
```
### DNS Discovery
DNS [SRV records](http://www.ietf.org/rfc/rfc2052.txt) can be used as a discovery mechanism.
The `-discovery-srv` flag can be used to set the DNS domain name where the discovery SRV records can be found.
The following DNS SRV records are looked up in the listed order:
* _etcd-server-ssl._tcp.example.com
* _etcd-server._tcp.example.com
If `_etcd-server-ssl._tcp.example.com` is found then etcd will attempt the bootstrapping process over SSL.
#### Create DNS SRV records
```
$ dig +noall +answer SRV _etcd-server._tcp.example.com
_etcd-server._tcp.example.com. 300 IN SRV 0 0 2380 infra0.example.com.
_etcd-server._tcp.example.com. 300 IN SRV 0 0 2380 infra1.example.com.
_etcd-server._tcp.example.com. 300 IN SRV 0 0 2380 infra2.example.com.
```
```
$ dig +noall +answer infra0.example.com infra1.example.com infra2.example.com
infra0.example.com. 300 IN A 10.0.1.10
infra1.example.com. 300 IN A 10.0.1.11
infra2.example.com. 300 IN A 10.0.1.12
```
#### Bootstrap the etcd cluster using DNS
etcd cluster members can listen on domain names or IP address, the bootstrap process will resolve DNS A records.
The resolved address in `-initial-advertise-peer-urls` *must match* one of the resolved addresses in the SRV targets. The etcd member reads the resolved address to find out if it belongs to the cluster defined in the SRV records.
```
$ etcd -name infra0 \
-discovery-srv example.com \
-initial-advertise-peer-urls http://infra0.example.com:2380 \
-initial-cluster-token etcd-cluster-1 \
-initial-cluster-state new \
-advertise-client-urls http://infra0.example.com:2379 \
-listen-client-urls http://infra0.example.com:2379 \
-listen-peer-urls http://infra0.example.com:2380
```
```
$ etcd -name infra1 \
-discovery-srv example.com \
-initial-advertise-peer-urls http://infra1.example.com:2380 \
-initial-cluster-token etcd-cluster-1 \
-initial-cluster-state new \
-advertise-client-urls http://infra1.example.com:2379 \
-listen-client-urls http://infra1.example.com:2379 \
-listen-peer-urls http://infra1.example.com:2380
```
```
$ etcd -name infra2 \
-discovery-srv example.com \
-initial-advertise-peer-urls http://infra2.example.com:2380 \
-initial-cluster-token etcd-cluster-1 \
-initial-cluster-state new \
-advertise-client-urls http://infra2.example.com:2379 \
-listen-client-urls http://infra2.example.com:2379 \
-listen-peer-urls http://infra2.example.com:2380
```
You can also bootstrap the cluster using IP addresses instead of domain names:
```
$ etcd -name infra0 \
-discovery-srv example.com \
-initial-advertise-peer-urls http://10.0.1.10:2380 \
-initial-cluster-token etcd-cluster-1 \
-initial-cluster-state new \
-advertise-client-urls http://10.0.1.10:2379 \
-listen-client-urls http://10.0.1.10:2379 \
-listen-peer-urls http://10.0.1.10:2380
```
```
$ etcd -name infra1 \
-discovery-srv example.com \
-initial-advertise-peer-urls http://10.0.1.11:2380 \
-initial-cluster-token etcd-cluster-1 \
-initial-cluster-state new \
-advertise-client-urls http://10.0.1.11:2379 \
-listen-client-urls http://10.0.1.11:2379 \
-listen-peer-urls http://10.0.1.11:2380
```
```
$ etcd -name infra2 \
-discovery-srv example.com \
-initial-advertise-peer-urls http://10.0.1.12:2380 \
-initial-cluster-token etcd-cluster-1 \
-initial-cluster-state new \
-advertise-client-urls http://10.0.1.12:2379 \
-listen-client-urls http://10.0.1.12:2379 \
-listen-peer-urls http://10.0.1.12:2380
```
#### etcd proxy configuration
DNS SRV records can also be used to configure the list of peers for an etcd server running in proxy mode:
```
$ etcd --proxy on -discovery-srv example.com
```
#### Error Cases
You might see the an error like `cannot find local etcd $name from SRV records.`. That means the etcd member fails to find itself from the cluster defined in SRV records. The resolved address in `-initial-advertise-peer-urls` *must match* one of the resolved addresses in the SRV targets.
# 0.4 to 2.0+ Migration Guide
In etcd 2.0 we introduced the ability to listen on more than one address and to advertise multiple addresses. This makes using etcd easier when you have complex networking, such as private and public networks on various cloud providers.
To make understanding this feature easier, we changed the naming of some flags, but we support the old flags to make the migration from the old to new version easier.
|Old Flag |New Flag |Migration Behavior |
|-----------------------|-----------------------|---------------------------------------------------------------------------------------|
|-peer-addr |-initial-advertise-peer-urls |If specified, peer-addr will be used as the only peer URL. Error if both flags specified.|
|-addr |-advertise-client-urls |If specified, addr will be used as the only client URL. Error if both flags specified.|
|-peer-bind-addr |-listen-peer-urls |If specified, peer-bind-addr will be used as the only peer bind URL. Error if both flags specified.|
|-bind-addr |-listen-client-urls |If specified, bind-addr will be used as the only client bind URL. Error if both flags specified.|
|-peers |none |Deprecated. The -initial-cluster flag provides a similar concept with different semantics. Please read this guide on cluster startup.|
|-peers-file |none |Deprecated. The -initial-cluster flag provides a similar concept with different semantics. Please read this guide on cluster startup.|

View File

@ -0,0 +1,264 @@
## Configuration Flags
etcd is configurable through command-line flags and environment variables. Options set on the command line take precedence over those from the environment.
The format of environment variable for flag `-my-flag` is `ETCD_MY_FLAG`. It applies to all flags.
To start etcd automatically using custom settings at startup in Linux, using a [systemd][systemd-intro] unit is highly recommended.
[systemd-intro]: http://freedesktop.org/wiki/Software/systemd/
### Member Flags
##### -name
+ Human-readable name for this member.
+ default: "default"
+ env variable: ETCD_NAME
+ This value is referenced as this node's own entries listed in the `-initial-cluster` flag (Ex: `default=http://localhost:2380` or `default=http://localhost:2380,default=http://localhost:7001`). This needs to match the key used in the flag if you're using [static boostrapping](clustering.md#static).
##### -data-dir
+ Path to the data directory.
+ default: "${name}.etcd"
+ env variable: ETCD_DATA_DIR
##### -wal-dir
+ Path to the dedicated wal directory. If this flag is set, etcd will write the WAL files to the walDir rather than the dataDir. This allows a dedicated disk to be used, and helps avoid io competition between logging and other IO operations.
+ default: ""
+ env variable: ETCD_WAL_DIR
##### -snapshot-count
+ Number of committed transactions to trigger a snapshot to disk.
+ default: "10000"
+ env variable: ETCD_SNAPSHOT_COUNT
##### -heartbeat-interval
+ Time (in milliseconds) of a heartbeat interval.
+ default: "100"
+ env variable: ETCD_HEARTBEAT_INTERVAL
##### -election-timeout
+ Time (in milliseconds) for an election to timeout. See [Documentation/tuning.md](tuning.md#time-parameters) for details.
+ default: "1000"
+ env variable: ETCD_ELECTION_TIMEOUT
##### -listen-peer-urls
+ List of URLs to listen on for peer traffic. This flag tells the etcd to accept incoming requests from its peers on the specified scheme://IP:port combinations. Scheme can be either http or https.If 0.0.0.0 is specified as the IP, etcd listens to the given port on all interfaces. If an IP address is given as well as a port, etcd will listen on the given port and interface. Multiple URLs may be used to specify a number of addresses and ports to listen on. The etcd will respond to requests from any of the listed addresses and ports.
+ default: "http://localhost:2380,http://localhost:7001"
+ env variable: ETCD_LISTEN_PEER_URLS
+ example: "http://10.0.0.1:2380"
+ invalid example: "http://example.com:2380" (domain name is invalid for binding)
##### -listen-client-urls
+ List of URLs to listen on for client traffic. This flag tells the etcd to accept incoming requests from the clients on the specified scheme://IP:port combinations. Scheme can be either http or https. If 0.0.0.0 is specified as the IP, etcd listens to the given port on all interfaces. If an IP address is given as well as a port, etcd will listen on the given port and interface. Multiple URLs may be used to specify a number of addresses and ports to listen on. The etcd will respond to requests from any of the listed addresses and ports.
+ default: "http://localhost:2379,http://localhost:4001"
+ env variable: ETCD_LISTEN_CLIENT_URLS
+ example: "http://10.0.0.1:2379"
+ invalid example: "http://example.com:2379" (domain name is invalid for binding)
##### -max-snapshots
+ Maximum number of snapshot files to retain (0 is unlimited)
+ default: 5
+ env variable: ETCD_MAX_SNAPSHOTS
+ The default for users on Windows is unlimited, and manual purging down to 5 (or your preference for safety) is recommended.
##### -max-wals
+ Maximum number of wal files to retain (0 is unlimited)
+ default: 5
+ env variable: ETCD_MAX_WALS
+ The default for users on Windows is unlimited, and manual purging down to 5 (or your preference for safety) is recommended.
##### -cors
+ Comma-separated white list of origins for CORS (cross-origin resource sharing).
+ default: none
+ env variable: ETCD_CORS
### Clustering Flags
`-initial` prefix flags are used in bootstrapping ([static bootstrap][build-cluster], [discovery-service bootstrap][discovery] or [runtime reconfiguration][reconfig]) a new member, and ignored when restarting an existing member.
`-discovery` prefix flags need to be set when using [discovery service][discovery].
##### -initial-advertise-peer-urls
+ List of this member's peer URLs to advertise to the rest of the cluster. These addresses are used for communicating etcd data around the cluster. At least one must be routable to all cluster members. These URLs can contain domain names.
+ default: "http://localhost:2380,http://localhost:7001"
+ env variable: ETCD_INITIAL_ADVERTISE_PEER_URLS
+ example: "http://example.com:2380, http://10.0.0.1:2380"
##### -initial-cluster
+ Initial cluster configuration for bootstrapping.
+ default: "default=http://localhost:2380,default=http://localhost:7001"
+ env variable: ETCD_INITIAL_CLUSTER
+ The key is the value of the `-name` flag for each node provided. The default uses `default` for the key because this is the default for the `-name` flag.
##### -initial-cluster-state
+ Initial cluster state ("new" or "existing"). Set to `new` for all members present during initial static or DNS bootstrapping. If this option is set to `existing`, etcd will attempt to join the existing cluster. If the wrong value is set, etcd will attempt to start but fail safely.
+ default: "new"
+ env variable: ETCD_INITIAL_CLUSTER_STATE
[static bootstrap]: clustering.md#static
##### -initial-cluster-token
+ Initial cluster token for the etcd cluster during bootstrap.
+ default: "etcd-cluster"
+ env variable: ETCD_INITIAL_CLUSTER_TOKEN
##### -advertise-client-urls
+ List of this member's client URLs to advertise to the rest of the cluster. These URLs can contain domain names.
+ default: "http://localhost:2379,http://localhost:4001"
+ env variable: ETCD_ADVERTISE_CLIENT_URLS
+ example: "http://example.com:2379, http://10.0.0.1:2379"
+ Be careful if you are advertising URLs such as http://localhost:2379 from a cluster member and are using the proxy feature of etcd. This will cause loops, because the proxy will be forwarding requests to itself until its resources (memory, file descriptors) are eventually depleted.
##### -discovery
+ Discovery URL used to bootstrap the cluster.
+ default: none
+ env variable: ETCD_DISCOVERY
##### -discovery-srv
+ DNS srv domain used to bootstrap the cluster.
+ default: none
+ env variable: ETCD_DISCOVERY_SRV
##### -discovery-fallback
+ Expected behavior ("exit" or "proxy") when discovery services fails.
+ default: "proxy"
+ env variable: ETCD_DISCOVERY_FALLBACK
##### -discovery-proxy
+ HTTP proxy to use for traffic to discovery service.
+ default: none
+ env variable: ETCD_DISCOVERY_PROXY
### Proxy Flags
`-proxy` prefix flags configures etcd to run in [proxy mode][proxy].
##### -proxy
+ Proxy mode setting ("off", "readonly" or "on").
+ default: "off"
+ env variable: ETCD_PROXY
##### -proxy-failure-wait
+ Time (in milliseconds) an endpoint will be held in a failed state before being reconsidered for proxied requests.
+ default: 5000
+ env variable: ETCD_PROXY_FAILURE_WAIT
##### -proxy-refresh-interval
+ Time (in milliseconds) of the endpoints refresh interval.
+ default: 30000
+ env variable: ETCD_PROXY_REFRESH_INTERVAL
##### -proxy-dial-timeout
+ Time (in milliseconds) for a dial to timeout or 0 to disable the timeout
+ default: 1000
+ env variable: ETCD_PROXY_DIAL_TIMEOUT
##### -proxy-write-timeout
+ Time (in milliseconds) for a write to timeout or 0 to disable the timeout.
+ default: 5000
+ env variable: ETCD_PROXY_WRITE_TIMEOUT
##### -proxy-read-timeout
+ Time (in milliseconds) for a read to timeout or 0 to disable the timeout.
+ Don't change this value if you use watches because they are using long polling requests.
+ default: 0
+ env variable: ETCD_PROXY_READ_TIMEOUT
### Security Flags
The security flags help to [build a secure etcd cluster][security].
##### -ca-file [DEPRECATED]
+ Path to the client server TLS CA file. `-ca-file ca.crt` could be replaced by `-trusted-ca-file ca.crt -client-cert-auth` and etcd will perform the same.
+ default: none
+ env variable: ETCD_CA_FILE
##### -cert-file
+ Path to the client server TLS cert file.
+ default: none
+ env variable: ETCD_CERT_FILE
##### -key-file
+ Path to the client server TLS key file.
+ default: none
+ env variable: ETCD_KEY_FILE
##### -client-cert-auth
+ Enable client cert authentication.
+ default: false
+ env variable: ETCD_CLIENT_CERT_AUTH
##### -trusted-ca-file
+ Path to the client server TLS trusted CA key file.
+ default: none
+ env variable: ETCD_TRUSTED_CA_FILE
##### -peer-ca-file [DEPRECATED]
+ Path to the peer server TLS CA file. `-peer-ca-file ca.crt` could be replaced by `-peer-trusted-ca-file ca.crt -peer-client-cert-auth` and etcd will perform the same.
+ default: none
+ env variable: ETCD_PEER_CA_FILE
##### -peer-cert-file
+ Path to the peer server TLS cert file.
+ default: none
+ env variable: ETCD_PEER_CERT_FILE
##### -peer-key-file
+ Path to the peer server TLS key file.
+ default: none
+ env variable: ETCD_PEER_KEY_FILE
##### -peer-client-cert-auth
+ Enable peer client cert authentication.
+ default: false
+ env variable: ETCD_PEER_CLIENT_CERT_AUTH
##### -peer-trusted-ca-file
+ Path to the peer server TLS trusted CA file.
+ default: none
+ env variable: ETCD_PEER_TRUSTED_CA_FILE
### Logging Flags
##### -debug
+ Drop the default log level to DEBUG for all subpackages.
+ default: false (INFO for all packages)
+ env variable: ETCD_DEBUG
##### -log-package-levels
+ Set individual etcd subpackages to specific log levels. An example being `etcdserver=WARNING,security=DEBUG`
+ default: none (INFO for all packages)
+ env variable: ETCD_LOG_PACKAGE_LEVELS
### Unsafe Flags
Please be CAUTIOUS when using unsafe flags because it will break the guarantees given by the consensus protocol.
For example, it may panic if other members in the cluster are still alive.
Follow the instructions when using these flags.
##### -force-new-cluster
+ Force to create a new one-member cluster. It commits configuration changes in force to remove all existing members in the cluster and add itself. It needs to be set to [restore a backup][restore].
+ default: false
+ env variable: ETCD_FORCE_NEW_CLUSTER
### Experimental Flags
##### -experimental-v3demo
+ Enable experimental [v3 demo API](rfc/v3api.proto).
+ default: false
+ env variable: ETCD_EXPERIMENTAL_V3DEMO
### Miscellaneous Flags
##### -version
+ Print the version and exit.
+ default: false
[build-cluster]: clustering.md#static
[reconfig]: runtime-configuration.md
[discovery]: clustering.md#discovery
[proxy]: proxy.md
[security]: security.md
[restore]: admin_guide.md#restoring-a-backup

View File

@ -0,0 +1,109 @@
# etcd release guide
The guide talks about how to release a new version of etcd.
The procedure includes some manual steps for sanity checking but it can probably be further scripted. Please keep this document up-to-date if you want to make changes to the release process.
## Prepare Release
Set desired version as environment variable for following steps. Here is an example to release 2.1.3:
```
export VERSION=v2.1.3
export PREV_VERSION=v2.1.2
```
All releases version numbers follow the format of [semantic versioning 2.0.0](http://semver.org/).
### Major, Minor Version Release, or its Pre-release
- Ensure the relevant milestone on GitHub is complete. All referenced issues should be closed, or moved elsewhere.
- Remove this release from [roadmap](https://github.com/coreos/etcd/blob/master/ROADMAP.md), if necessary.
- Ensure the latest upgrade documentation is available.
- Bump [hardcoded MinClusterVerion in the repository](https://github.com/coreos/etcd/blob/master/version/version.go#L29), if necessary.
- Add feature capability maps for the new version, if necessary.
### Patch Version Release
- Discuss about commits that are backported to the patch release. The commits should not include merge commits.
- Cherry-pick these commits starting from the oldest one into stable branch.
## Write Release Note
- Write introduction for the new release. For example, what major bug we fix, what new features we introduce or what performance improvement we make.
- Write changelog for the last release. ChangeLog should be straightforward and easy to understand for the end-user.
- Put `[GH XXXX]` at the head of change line to reference Pull Request that introduces the change. Moreover, add a link on it to jump to the Pull Request.
## Tag Version
- Bump [hardcoded Version in the repository](https://github.com/coreos/etcd/blob/master/version/version.go#L30) to the latest version `${VERSION}`.
- Ensure all tests on CI system are passed.
- Manually check etcd is buildable in Linux, Darwin and Windows.
- Manually check upgrade etcd cluster of previous minor version works well.
- Manually check new features work well.
- Add a signed tag through `git tag -s ${VERSION}`.
- Sanity check tag correctness through `git show tags/$VERSION`.
- Push the tag to GitHub through `git push origin tags/$VERSION`. This assumes `origin` corresponds to "https://github.com/coreos/etcd".
## Build Release Binaries and Images
- Ensure `actool` is available, or installing it through `go get github.com/appc/spec/actool`.
- Ensure `docker` is available.
Run release script in root directory:
```
./scripts/release.sh ${VERSION}
```
It generates all release binaries and images under directory ./release.
## Sign Binaries and Images
Choose appropriate private key to sign the generated binaries and images.
The following commands are used for public release sign:
```
cd release
# personal GPG is okay for now
for i in etcd-*{.zip,.tar.gz}; do gpg --sign ${i}; done
# use `CoreOS ACI Builder <release@coreos.com>` secret key
gpg -u 88182190 -a --output etcd-${VERSION}-linux-amd64.aci.asc --detach-sig etcd-${VERSION}-linux-amd64.aci
```
## Publish Release Page in GitHub
- Set release title as the version name.
- Follow the format of previous release pages.
- Attach the generated binaries, aci image and signatures.
- Select whether it is a pre-release.
- Publish the release!
## Publish Docker Image in Quay.io
- Push docker image:
```
docker login quay.io
docker push quay.io/coreos/etcd:${VERSION}
```
- Add `latest` tag to the new image on [quay.io](https://quay.io/repository/coreos/etcd?tag=latest&tab=tags) if this is a stable release.
## Announce to etcd-dev Googlegroup
- Follow the format of [previous release emails](https://groups.google.com/forum/#!forum/etcd-dev).
- Make sure to include a list of authors that contributed since the previous release - something like the following might be handy:
```
git log ...${PREV_VERSION} --pretty=format:"%an" | sort | uniq | tr '\n' ',' | sed -e 's#,#, #g' -e 's#, $##'
```
- Send email to etcd-dev@googlegroups.com
## Post Release
- Create new stable branch through `git push origin ${VERSION_MAJOR}.${VERSION_MINOR}` if this is a major stable release. This assumes `origin` corresponds to "https://github.com/coreos/etcd".
- Bump [hardcoded Version in the repository](https://github.com/coreos/etcd/blob/master/version/version.go#L30) to the version `${VERSION}+git`.

View File

@ -0,0 +1,109 @@
# Discovery Service Protocol
Discovery service protocol helps new etcd member to discover all other members in cluster bootstrap phase using a shared discovery URL.
Discovery service protocol is _only_ used in cluster bootstrap phase, and cannot be used for runtime reconfiguration or cluster monitoring.
The protocol uses a new discovery token to bootstrap one _unique_ etcd cluster. Remember that one discovery token can represent only one etcd cluster. As long as discovery protocol on this token starts, even if fails halfway, it must not be used to bootstrap another etcd cluster.
The rest of this article will walk through the discovery process with examples that correspond to a self-hosted discovery cluster. The public discovery service, discovery.etcd.io, functions the same way, but with a layer of polish to abstract away ugly URLs, generate UUIDs automatically, and provide some protections against excessive requests. At its core, the public discovery service still uses an etcd cluster as the data store as described in this document.
## The Protocol Workflow
The idea of discovery protocol is to use an internal etcd cluster to coordinate bootstrap of a new cluster. First, all new members interact with discovery service and help to generate the expected member list. Then each new member bootstraps its server using this list, which performs the same functionality as -initial-cluster flag.
In the following example workflow, we will list each step of protocol in curl format for ease of understanding.
By convention the etcd discovery protocol uses the key prefix `_etcd/registry`. If `http://example.com` hosts a etcd cluster for discovery service, a full URL to discovery keyspace will be `http://example.com/v2/keys/_etcd/registry`. We will use this as the URL prefix in the example.
### Creating a New Discovery Token
Generate a unique token that will identify the new cluster. This will be used as a unique prefix in discovery keyspace in the following steps. An easy way to do this is to use `uuidgen`:
```
UUID=$(uuidgen)
```
### Specifying the Expected Cluster Size
You need to specify the expected cluster size for this discovery token. The size is used by the discovery service to know when it has found all members that will initially form the cluster.
```
curl -X PUT http://example.com/v2/keys/_etcd/registry/${UUID}/_config/size -d value=${cluster_size}
```
Usually the cluster size is 3, 5 or 7. Check [optimal cluster size](admin_guide.md#optimal-cluster-size) for more details.
### Bringing up etcd Processes
Now that you have your discovery URL, you can use it as `-discovery` flag and bring up etcd processes. Every etcd process will follow this next few steps internally if given a `-discovery` flag.
### Registering itself
The first thing for etcd process is to register itself into the discovery URL as a member. This is done by creating member ID as a key in the discovery URL.
```
curl -X PUT http://example.com/v2/keys/_etcd/registry/${UUID}/${member_id}?prevExist=false -d value="${member_name}=${member_peer_url_1}&${member_name}=${member_peer_url_2}"
```
### Checking the Status
It checks the expected cluster size and registration status in discovery URL, and decides what the next action is.
```
curl -X GET http://example.com/v2/keys/_etcd/registry/${UUID}/_config/size
curl -X GET http://example.com/v2/keys/_etcd/registry/${UUID}
```
If registered members are still not enough, it will wait for left members to appear.
If the number of registered members is bigger than the expected size N, it treats the first N registered members as the member list for the cluster. If the member itself is in the member list, the discovery procedure succeeds and it fetches all peers through the member list. If it is not in the member list, the discovery procedure finishes with the failure that the cluster has been full.
In etcd implementation, the member may check the cluster status even before registering itself. So it could fail quickly if the cluster has been full.
### Waiting for All Members
The wait process is described in details [here](https://github.com/coreos/etcd/blob/master/Documentation/api.md#waiting-for-a-change).
```
curl -X GET http://example.com/v2/keys/_etcd/registry/${UUID}?wait=true&waitIndex=${current_etcd_index}
```
It keeps waiting until finding all members.
## Public Discovery Service
CoreOS Inc. hosts a public discovery service at https://discovery.etcd.io/ , which provides some nice features for ease of use.
### Mask Key Prefix
Public discovery service will redirect `https://discovery.etcd.io/${UUID}` to etcd cluster behind for the key at `/v2/keys/_etcd/registry`. It masks register key prefix for short and readable discovery url.
### Get new token
```
GET /new
Sent query:
size=${cluster_size}
Possible status codes:
200 OK
400 Bad Request
200 Body:
generated discovery url
```
The generation process in the service follows the step from [Creating a New Discovery Token](#creating-a-new-discovery-token) to [Specifying the Expected Cluster Size](#specifying-the-expected-cluster-size).
### Check Discovery Status
```
GET /${UUID}
```
You can check the status for this discovery token, including the machines that have been registered, by requesting the value of the UUID.
### Open-source repository
The repository is located at https://github.com/coreos/discovery.etcd.io. You could use it to build your own public discovery service.

View File

@ -0,0 +1,92 @@
# Running etcd under Docker
The following guide will show you how to run etcd under Docker using the [static bootstrap process](clustering.md#static).
## Running etcd in standalone mode
In order to expose the etcd API to clients outside of the Docker host you'll need use the host IP address when configuring etcd.
```
export HostIP="192.168.12.50"
```
The following `docker run` command will expose the etcd client API over ports 4001 and 2379, and expose the peer port over 2380.
```
docker run -d -v /usr/share/ca-certificates/:/etc/ssl/certs -p 4001:4001 -p 2380:2380 -p 2379:2379 \
--name etcd quay.io/coreos/etcd:v2.0.8 \
-name etcd0 \
-advertise-client-urls http://${HostIP}:2379,http://${HostIP}:4001 \
-listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 \
-initial-advertise-peer-urls http://${HostIP}:2380 \
-listen-peer-urls http://0.0.0.0:2380 \
-initial-cluster-token etcd-cluster-1 \
-initial-cluster etcd0=http://${HostIP}:2380 \
-initial-cluster-state new
```
Configure etcd clients to use the Docker host IP and one of the listening ports from above.
```
etcdctl -C http://192.168.12.50:2379 member list
```
```
etcdctl -C http://192.168.12.50:4001 member list
```
## Running a 3 node etcd cluster
Using Docker to setup a multi-node cluster is very similar to the standalone mode configuration.
The main difference being the value used for the `-initial-cluster` flag, which must contain the peer urls for each etcd member in the cluster.
### etcd0
```
docker run -d -v /usr/share/ca-certificates/:/etc/ssl/certs -p 4001:4001 -p 2380:2380 -p 2379:2379 \
--name etcd quay.io/coreos/etcd:v2.0.8 \
-name etcd0 \
-advertise-client-urls http://192.168.12.50:2379,http://192.168.12.50:4001 \
-listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 \
-initial-advertise-peer-urls http://192.168.12.50:2380 \
-listen-peer-urls http://0.0.0.0:2380 \
-initial-cluster-token etcd-cluster-1 \
-initial-cluster etcd0=http://192.168.12.50:2380,etcd1=http://192.168.12.51:2380,etcd2=http://192.168.12.52:2380 \
-initial-cluster-state new
```
### etcd1
```
docker run -d -v /usr/share/ca-certificates/:/etc/ssl/certs -p 4001:4001 -p 2380:2380 -p 2379:2379 \
--name etcd quay.io/coreos/etcd:v2.0.8 \
-name etcd1 \
-advertise-client-urls http://192.168.12.51:2379,http://192.168.12.51:4001 \
-listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 \
-initial-advertise-peer-urls http://192.168.12.51:2380 \
-listen-peer-urls http://0.0.0.0:2380 \
-initial-cluster-token etcd-cluster-1 \
-initial-cluster etcd0=http://192.168.12.50:2380,etcd1=http://192.168.12.51:2380,etcd2=http://192.168.12.52:2380 \
-initial-cluster-state new
```
### etcd2
```
docker run -d -v /usr/share/ca-certificates/:/etc/ssl/certs -p 4001:4001 -p 2380:2380 -p 2379:2379 \
--name etcd quay.io/coreos/etcd:v2.0.8 \
-name etcd2 \
-advertise-client-urls http://192.168.12.52:2379,http://192.168.12.52:4001 \
-listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 \
-initial-advertise-peer-urls http://192.168.12.52:2380 \
-listen-peer-urls http://0.0.0.0:2380 \
-initial-cluster-token etcd-cluster-1 \
-initial-cluster etcd0=http://192.168.12.50:2380,etcd1=http://192.168.12.51:2380,etcd2=http://192.168.12.52:2380 \
-initial-cluster-state new
```
Once the cluster has been bootstrapped etcd clients can be configured with a list of etcd members:
```
etcdctl -C http://192.168.12.50:2379,http://192.168.12.51:2379,http://192.168.12.52:2379 member list
```

View File

@ -1,58 +1,42 @@
Error Code
======
This document describes the error code in **Etcd** project.
This document describes the error code used in key space '/v2/keys'. Feel free to import 'github.com/coreos/etcd/error' to use.
It's categorized into four groups:
- Command Related Error
| name | code | strerror |
|----------------------|------|-----------------------|
| EcodeKeyNotFound | 100 | "Key not found" |
| EcodeTestFailed | 101 | "Compare failed" |
| EcodeNotFile | 102 | "Not a file" |
| EcodeNotDir | 104 | "Not a directory" |
| EcodeNodeExist | 105 | "Key already exists" |
| EcodeRootROnly | 107 | "Root is read only" |
| EcodeDirNotEmpty | 108 | "Directory not empty" |
- Post Form Related Error
| name | code | strerror |
|--------------------------|------|------------------------------------------------|
| EcodePrevValueRequired | 201 | "PrevValue is Required in POST form" |
| EcodeTTLNaN | 202 | "The given TTL in POST form is not a number" |
| EcodeIndexNaN | 203 | "The given index in POST form is not a number" |
| EcodeInvalidField | 209 | "Invalid field" |
| EcodeInvalidForm | 210 | "Invalid POST form" |
- Raft Related Error
| name | code | strerror |
|-------------------|------|--------------------------|
| EcodeRaftInternal | 300 | "Raft Internal Error" |
| EcodeLeaderElect | 301 | "During Leader Election" |
- Etcd Related Error
Error code corresponding strerror
------
const (
EcodeKeyNotFound = 100
EcodeTestFailed = 101
EcodeNotFile = 102
EcodeNoMoreMachine = 103
EcodeNotDir = 104
EcodeNodeExist = 105
EcodeKeyIsPreserved = 106
EcodeValueRequired = 200
EcodePrevValueRequired = 201
EcodeTTLNaN = 202
EcodeIndexNaN = 203
EcodeRaftInternal = 300
EcodeLeaderElect = 301
EcodeWatcherCleared = 400
EcodeEventIndexCleared = 401
)
// command related errors
errors[100] = "Key Not Found"
errors[101] = "Test Failed" //test and set
errors[102] = "Not A File"
errors[103] = "Reached the max number of machines in the cluster"
errors[104] = "Not A Directory"
errors[105] = "Already exists" // create
errors[106] = "The prefix of given key is a keyword in etcd"
// Post form related errors
errors[200] = "Value is Required in POST form"
errors[201] = "PrevValue is Required in POST form"
errors[202] = "The given TTL in POST form is not a number"
errors[203] = "The given index in POST form is not a number"
// raft related errors
errors[300] = "Raft Internal Error"
errors[301] = "During Leader Election"
// etcd related errors
errors[400] = "watcher is cleared due to etcd recovery"
errors[401] = "The event in requested index is outdated and cleared"
| name | code | strerror |
|-------------------------|------|--------------------------------------------------------|
| EcodeWatcherCleared | 400 | "watcher is cleared due to etcd recovery" |
| EcodeEventIndexCleared | 401 | "The event in requested index is outdated and cleared" |

View File

@ -1,101 +0,0 @@
#Etcd File System
## Structure
[TODO]
![alt text](./img/etcd_fs_structure.jpg "etcd file system structure")
## Node
In **Etcd**, the **Node** is the rudimentary element constructing the whole.
Currently **Etcd** file system is comprised in a Unix-like way of files and directories, and they are two kinds of nodes different in:
- **File Node** has data associated with it.
- **Directory Node** has children nodes associated with it.
Besides the file and directory difference, all nodes have common attributes and operations as follows:
### Attributes:
- **Expiration Time** [optional]
The node will be deleted when it expires.
- **ACL**
The path of access control list of the node.
### Operation:
- **Get** (path, recursive, sorted)
Get the content of the node
- If the node is a file, the data of the file will be returned.
- If the node is a directory, the child nodes of the directory will be returned.
- If recursive is true, it will recursively get the nodes of the directory.
- If sorted is true, the result will be sorted based on the path.
- **Create** (path, value[optional], ttl [optional])
Create a file. Create operation will help to create intermediate directories with no expiration time.
- If the file already exists, create will fail.
- If the value is given, set will create a file.
- If the value is not given, set will crate a directory.
- If ttl is given, the node will be deleted when it expires.
- **Update** (path, value[optional], ttl [optional])
Update the content of the node.
- If the value is given, the value of the key will be updated.
- If ttl is given, the expiration time of the node will be updated.
- **Delete** (path, recursive)
Delete the node of given path.
- If the node is a directory:
- If recursive is true, the operation will delete all nodes under the directory.
- If recursive is false, error will be returned.
- **TestAndSet** (path, prevValue [prevIndex], value, ttl)
Atomic *test and set* value to a file. If test succeeds, this operation will change the previous value of the file to the given value.
- If the prevValue is given, it will test against previous value of
the node.
- If the prevValue is empty, it will test if the node is not existing.
- If the prevValue is not empty, it will test if the prevValue is equal to the current value of the file.
- If the prevIndex is given, it will test if the create/last modified index of the node is equal to prevIndex.
- **Renew** (path, ttl)
Set the node's expiration time to (current time + ttl)
## ACL
### Theory
Etcd exports a Unix-like file system interface consisting of files and directories, collectively called nodes.
Each node has various meta-data, including three names of access control lists used to control reading, writing and changing (change ACL names for the node).
We are storing the ACL names for nodes under a special *ACL* directory.
Each node has ACL name corresponding to one file within *ACL* dir.
Unless overridden, a node naturally inherits the ACL names of its parent directory on creation.
For each ACL name, it has three children: *R (Reading)*, *W (Writing)*, *C (Changing)*
Each permission is also a node. Under the node it contains the users who have this permission for the file refering to this ACL name.
### Example
[TODO]
### Diagram
[TODO]
### Interface
Testing permissions:
- (node *Node) get_perm()
- (node *Node) has_perm(perm string, user string)
Setting/Changing permissions:
- (node *Node) set_perm(perm string)
- (node *Node) change_ACLname(aclname string)
## User Group
[TODO]

80
Documentation/faq.md Normal file
View File

@ -0,0 +1,80 @@
# FAQ
## 1) How come I can read an old version of the data when a majority of the members are down?
In situations where a client connects to a minority, etcd
favors by default availability over consistency. This means that even though
data might be “out of date”, it is still better to return something versus
nothing.
In order to confirm that a read is up to date with a majority of the cluster,
the client can use the `quorum=true` parameter on reads of keys. This means
that a majority of the cluster is checked on reads before returning the data,
otherwise the read will timeout and fail.
## 2) With quorum=false, doesnt this mean that if my client switched the member it was connected to, that it could experience a logical ordering where the cluster goes backwards in time?
Yes, but this could be handled at the etcd client implementation via
remembering the last seen index. The “index” is the cluster's single
irrevocable sequence of the entire modification history. The client could
remember the last seen index, and determine via comparing the index returned on
the GET whether or not the state of the key-value pair is before or after its
last seen state.
## 3) What happens if a watch is registered on a minority member?
The watch will stay untriggered, even as modifications are occurring in the
majority quorum. This is an open issue, and is being addressed in v3. There are
multiple ways to work around the watch trigger not firing.
1) build a signaling mechanism independent of etcd. This could be as simple as
a “pulse” to the client to reissue a GET with quorum=true for the most recent
version of the data.
2) poll on the `/v2/keys` endpoint and check that the raft-index is increasing every
timeout.
## 4) What is a proxy used for?
A proxy is a redirection server to the etcd cluster. The proxy handles the
redirection of a client to the current configuration of the etcd cluster. A
typical usecase is to start a proxy on a machine, and on first boot up of the
proxy specify both the `--proxy` flag and the `--initial-cluster` flag.
From there, any etcdctl client that starts up automatically speaks to the local
proxy and the proxy redirects operations to the current configuration of the
cluster it was originally paired with.
In the v2 spec of etcd, proxies cannot be promoted to members of the cluster.
They also cannot be promoted to followers or at any point become part of the
replication of the etcd cluster itself.
## 5) How is cluster membership and health handled in etcd v2?
The design goal of etcd is that reconfiguration is simply an API, and health
monitoring and addition/removal of members is up to the individual application
and their integration with the reconfiguration API.
Thus, a member that is down, even infinitely, will never be automatically
removed from the etcd cluster member list.
This makes sense because its usually an application level / administrative
action to determine whether a reconfiguration should happen based on health.
For more information, refer to [Documentation/runtime-reconfiguration.md].
## 6) how does --peers work with etcdctl?
The `--peers` flag can specify any number of etcd cluster members in a comma
separated list. This list might be a subset, equal to, or more than the actual
etcd cluster member list itself.
If only one peer is specified via the `--peers` flag, the etcdctl discovers the
rest of the cluster via the member list of that one peer, and then it randomly
chooses a member to use. Again, the client can use the `quorum=true` flag on
reads, which will always fail when using a member in the minority.
If peers from multiple clusters are specified via the `--peers` flag, etcdctl
will randomly choose a peer, and the request will simply get routed to one of
the clusters. This is probably not what you want.

35
Documentation/glossary.md Normal file
View File

@ -0,0 +1,35 @@
## Glossary
This document defines the various terms used in etcd documentation, command line and source code.
### Node
Node is an instance of raft state machine.
It has a unique identification, and records other nodes' progress internally when it is the leader.
### Member
Member is an instance of etcd. It hosts a node, and provides service to clients.
### Cluster
Cluster consists of several members.
The node in each member follows raft consensus protocol to replicate logs. Cluster receives proposals from members, commits them and apply to local store.
### Peer
Peer is another member of the same cluster.
### Proposal
A proposal is a request (for example a write request, a configuration change request) that needs to go through raft protocol.
### Client
Client is a caller of the cluster's HTTP API.
### Machine (deprecated)
The alternative of Member in etcd before 2.0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

View File

@ -0,0 +1,65 @@
# FAQ
## Initial Bootstrapping UX
etcd initial bootstrapping is done via command line flags such as
`--initial-cluster` or `--discovery`. These flags can safely be left on the
command line after your cluster is running but they will be ignored if you have
a non-empty data dir. So, why did we decide to have this sort of odd UX?
One of the design goals of etcd is easy bringup of clusters using a one-shot
static configuration like AWS Cloud Formation, PXE booting, etc. Essentially we
want to describe several virtual machines and bring them all up at once into an
etcd cluster.
To achieve this sort of hands-free cluster bootstrap we had two other options:
**API to bootstrap**
This is problematic because it cannot be coordinated from a single service file
and we didn't want to have the etcd socket listening but unresponsive to
clients for an unbound period of time.
It would look something like this:
```
ExecStart=/usr/bin/etcd
ExecStartPost/usr/bin/etcd init localhost:2379 --cluster=
```
**etcd init subcommand**
```
etcd init --cluster='default=http://localhost:2380,default=http://localhost:7001'...
etcd init --discovery https://discovery-example.etcd.io/193e4
```
Then after running an init step you would execute `etcd`. This however
introduced problems: we now have to define a hand-off protocol between the etcd
init process and the etcd binary itself. This is hard to coordinate in a single
service file such as:
```
ExecStartPre=/usr/bin/etcd init --cluster=....
ExecStart=/usr/bin/etcd
```
There are several error cases:
0) Init has already ran and the data directory is already configured
1) Discovery fails because of network timeout, etc
2) Discovery fails because the cluster is already full and etcd needs to fall back to proxy
3) Static cluster configuration fails because of conflict, misconfiguration or timeout
In hindsight we could have made this work by doing:
```
rc status
0 Init already ran
1 Discovery fails on network timeout, etc
0 Discovery fails for cluster full, coordinate via proxy state file
1 Static cluster configuration failed
```
Perhaps we can add the init command in a future version and deprecate if the UX
continues to confuse people.

View File

@ -1,12 +1,12 @@
# Versioning
Goal: We want to be able to upgrade an individual machine in an etcd cluster to a newer version of etcd.
Goal: We want to be able to upgrade an individual peer in an etcd cluster to a newer version of etcd.
The process will take the form of individual followers upgrading to the latest version until the entire cluster is on the new version.
Immediate need: etcd is moving too fast to version the internal API right now.
But, we need to keep mixed version clusters from being started by a rollowing upgrade process (e.g. the CoreOS developer alpha).
But, we need to keep mixed version clusters from being started by a rolling upgrade process (e.g. the CoreOS developer alpha).
Longer term need: Having a mixed version cluster where all machines are not be running the exact same version of etcd itself but are able to speak one version of the internal protocol.
Longer term need: Having a mixed version cluster where all peers are not running the exact same version of etcd itself but are able to speak one version of the internal protocol.
Solution: The internal protocol needs to be versioned just as the client protocol is.
Initially during the 0.\*.\* series of etcd releases we won't allow mixed versions at all.
@ -26,7 +26,7 @@ Advantages
Disadvantages
- Follower knows better what versions of the interal protocol it can talk than the leader
- Follower knows better what versions of the internal protocol it can talk than the leader
### Follower Controlled
@ -58,4 +58,4 @@ https://issues.apache.org/jira/browse/ZOOKEEPER-1633
## doozerd
doozerd stores the version number of the machine in the datastore for other clients to check, no decisions are made off of this number currently.
doozerd stores the version number of the peers in the datastore for other clients to check, no decisions are made off of this number currently.

View File

@ -0,0 +1,121 @@
## Libraries and Tools
**Tools**
- [etcdctl](https://github.com/coreos/etcdctl) - A command line client for etcd
- [etcd-backup](https://github.com/fanhattan/etcd-backup) - A powerful command line utility for dumping/restoring etcd - Supports v2
- [etcd-dump](https://npmjs.org/package/etcd-dump) - Command line utility for dumping/restoring etcd.
- [etcd-fs](https://github.com/xetorthio/etcd-fs) - FUSE filesystem for etcd
- [etcd-browser](https://github.com/henszey/etcd-browser) - A web-based key/value editor for etcd using AngularJS
- [etcd-lock](https://github.com/datawisesystems/etcd-lock) - Master election & distributed r/w lock implementation using etcd - Supports v2
- [etcd-console](https://github.com/matishsiao/etcd-console) - A web-base key/value editor for etcd using PHP
- [etcd-viewer](https://github.com/nikfoundas/etcd-viewer) - An etcd key-value store editor/viewer written in Java
**Go libraries**
- [go-etcd](https://github.com/coreos/go-etcd) - Supports v2
**Java libraries**
- [boonproject/etcd](https://github.com/boonproject/boon/blob/master/etcd/README.md) - Supports v2, Async/Sync and waits
- [justinsb/jetcd](https://github.com/justinsb/jetcd)
- [diwakergupta/jetcd](https://github.com/diwakergupta/jetcd) - Supports v2
- [jurmous/etcd4j](https://github.com/jurmous/etcd4j) - Supports v2, Async/Sync, waits and SSL
- [AdoHe/etcd4j](http://github.com/AdoHe/etcd4j) - Supports v2 (enhance for real production cluster)
**Python libraries**
- [jplana/python-etcd](https://github.com/jplana/python-etcd) - Supports v2
- [russellhaering/txetcd](https://github.com/russellhaering/txetcd) - a Twisted Python library
- [cholcombe973/autodock](https://github.com/cholcombe973/autodock) - A docker deployment automation tool
- [lisael/aioetcd](https://github.com/lisael/aioetcd) - (Python 3.4+) Asyncio coroutines client (Supports v2)
**Node libraries**
- [stianeikeland/node-etcd](https://github.com/stianeikeland/node-etcd) - Supports v2 (w Coffeescript)
- [lavagetto/nodejs-etcd](https://github.com/lavagetto/nodejs-etcd) - Supports v2
- [deedubs/node-etcd-config](https://github.com/deedubs/node-etcd-config) - Supports v2
**Ruby libraries**
- [iconara/etcd-rb](https://github.com/iconara/etcd-rb)
- [jpfuentes2/etcd-ruby](https://github.com/jpfuentes2/etcd-ruby)
- [ranjib/etcd-ruby](https://github.com/ranjib/etcd-ruby) - Supports v2
**C libraries**
- [jdarcy/etcd-api](https://github.com/jdarcy/etcd-api) - Supports v2
- [shafreeck/cetcd](https://github.com/shafreeck/cetcd) - Supports v2
**C++ libraries**
- [edwardcapriolo/etcdcpp](https://github.com/edwardcapriolo/etcdcpp) - Supports v2
**Clojure libraries**
- [aterreno/etcd-clojure](https://github.com/aterreno/etcd-clojure)
- [dwwoelfel/cetcd](https://github.com/dwwoelfel/cetcd) - Supports v2
- [rthomas/clj-etcd](https://github.com/rthomas/clj-etcd) - Supports v2
**Erlang libraries**
- [marshall-lee/etcd.erl](https://github.com/marshall-lee/etcd.erl)
**.Net Libraries**
- [drusellers/etcetera](https://github.com/drusellers/etcetera)
**PHP Libraries**
- [linkorb/etcd-php](https://github.com/linkorb/etcd-php)
**Haskell libraries**
- [wereHamster/etcd-hs](https://github.com/wereHamster/etcd-hs)
**R libraries**
- [ropensci/etseed](https://github.com/ropensci/etseed)
**Tcl libraries**
- [efrecon/etcd-tcl](https://github.com/efrecon/etcd-tcl) - Supports v2, except wait.
A detailed recap of client functionalities can be found in the [clients compatibility matrix][clients-matrix.md].
[clients-matrix.md]: https://github.com/coreos/etcd/blob/master/Documentation/clients-matrix.md
**Chef Integration**
- [coderanger/etcd-chef](https://github.com/coderanger/etcd-chef)
**Chef Cookbook**
- [spheromak/etcd-cookbook](https://github.com/spheromak/etcd-cookbook)
**BOSH Releases**
- [cloudfoundry-community/etcd-boshrelease](https://github.com/cloudfoundry-community/etcd-boshrelease)
- [cloudfoundry/cf-release](https://github.com/cloudfoundry/cf-release/tree/master/jobs/etcd)
**Projects using etcd**
- [binocarlos/yoda](https://github.com/binocarlos/yoda) - etcd + ZeroMQ
- [calavera/active-proxy](https://github.com/calavera/active-proxy) - HTTP Proxy configured with etcd
- [derekchiang/etcdplus](https://github.com/derekchiang/etcdplus) - A set of distributed synchronization primitives built upon etcd
- [go-discover](https://github.com/flynn/go-discover) - service discovery in Go
- [gleicon/goreman](https://github.com/gleicon/goreman/tree/etcd) - Branch of the Go Foreman clone with etcd support
- [garethr/hiera-etcd](https://github.com/garethr/hiera-etcd) - Puppet hiera backend using etcd
- [mattn/etcd-vim](https://github.com/mattn/etcd-vim) - SET and GET keys from inside vim
- [mattn/etcdenv](https://github.com/mattn/etcdenv) - "env" shebang with etcd integration
- [kelseyhightower/confd](https://github.com/kelseyhightower/confd) - Manage local app config files using templates and data from etcd
- [configdb](https://git.autistici.org/ai/configdb/tree/master) - A REST relational abstraction on top of arbitrary database backends, aimed at storing configs and inventories.
- [scrz](https://github.com/scrz/scrz) - Container manager, stores configuration in etcd.
- [fleet](https://github.com/coreos/fleet) - Distributed init system
- [GoogleCloudPlatform/kubernetes](https://github.com/GoogleCloudPlatform/kubernetes) - Container cluster manager.
- [mailgun/vulcand](https://github.com/mailgun/vulcand) - HTTP proxy that uses etcd as a configuration backend.
- [duedil-ltd/discodns](https://github.com/duedil-ltd/discodns) - Simple DNS nameserver using etcd as a database for names and records.
- [skynetservices/skydns](https://github.com/skynetservices/skydns) - RFC compliant DNS server
- [xordataexchange/crypt](https://github.com/xordataexchange/crypt) - Securely store values in etcd using GPG encryption
- [spf13/viper](https://github.com/spf13/viper) - Go configuration library, reads values from ENV, pflags, files, and etcd with optional encryption
- [lytics/metafora](https://github.com/lytics/metafora) - Go distributed task library
- [ryandoyle/nss-etcd](https://github.com/ryandoyle/nss-etcd) - A GNU libc NSS module for resolving names from etcd.

137
Documentation/metrics.md Normal file
View File

@ -0,0 +1,137 @@
## Metrics
**NOTE: The metrics feature is considered as an experimental. We might add/change/remove metrics without warning in the future releases.**
etcd uses [Prometheus](http://prometheus.io/) for metrics reporting in the server. The metrics can be used for real-time monitoring and debugging.
The simplest way to see the available metrics is to cURL the metrics endpoint `/metrics` of etcd. The format is described [here](http://prometheus.io/docs/instrumenting/exposition_formats/).
You can also follow the doc [here](http://prometheus.io/docs/introduction/getting_started/) to start a Promethus server and monitor etcd metrics.
The naming of metrics follows the suggested [best practice of Promethus](http://prometheus.io/docs/practices/naming/). A metric name has an `etcd` prefix as its namespace and a subsystem prefix (for example `wal` and `etcdserver`).
etcd now exposes the following metrics:
### etcdserver
| Name | Description | Type |
|-----------------------------------------|--------------------------------------------------|---------|
| file_descriptors_used_total | The total number of file descriptors used | Gauge |
| proposal_durations_milliseconds | The latency distributions of committing proposal | Summary |
| pending_proposal_total | The total number of pending proposals | Gauge |
| proposal_failed_total | The total number of failed proposals | Counter |
High file descriptors (`file_descriptors_used_total`) usage (near the file descriptors limitation of the process) indicates a potential out of file descriptors issue. That might cause etcd fails to create new WAL files and panics.
[Proposal](glossary.md#proposal) durations (`proposal_durations_milliseconds`) give you an summary about the proposal commit latency. Latency can be introduced into this process by network and disk IO.
Pending proposal (`pending_proposal_total`) gives you an idea about how many proposal are in the queue and waiting for commit. An increasing pending number indicates a high client load or an unstable cluster.
Failed proposals (`proposal_failed_total`) are normally related to two issues: temporary failures related to a leader election or longer duration downtime caused by a loss of quorum in the cluster.
### store
These metrics describe the accesses into the data store of etcd members that exist in the cluster. They
are useful to count what kind of actions are taken by users. It is also useful to see and whether all etcd members
"see" the same set of data mutations, and whether reads and watches (which are local) are equally distributed.
All these metrics are prefixed with `etcd_store_`.
| Name | Description | Type |
|---------------------------|------------------------------------------------------------------------------------------|--------------------|
| reads_total | Total number of reads from store, should differ among etcd members (local reads). | Counter(action) |
| writes_total | Total number of writes to store, should be same among all etcd members. | Counter(action) |
| reads_failed_total | Number of failed reads from store (e.g. key missing) on local reads. | Counter(action) |
| writes_failed_total | Number of failed writes to store (e.g. failed compare and swap). | Counter(action) |
| expires_total | Total number of expired keys (due to TTL).   | Counter |
| watch_requests_totals | Total number of incoming watch requests to this etcd member (local watches). | Counter |
| watchers | Current count of active watchers on this etcd member. | Gauge |
Both `reads_total` and `writes_total` count both successful and failed requests. `reads_failed_total` and
`writes_failed_total` count failed requests. A lot of failed writes indicate possible contentions on keys (e.g. when
doing `compareAndSet`), and read failures indicate that some clients try to access keys that don't exist.
Example Prometheus queries that may be useful from these metrics (across all etcd members):
* `sum(rate(etcd_store_reads_total{job="etcd"}[1m])) by (action)`
`max(rate(etcd_store_writes_total{job="etcd"}[1m])) by (action)`
Rate of reads and writes by action, across all servers across a time window of `1m`. The reason why `max` is used
for writes as opposed to `sum` for reads is because all of etcd nodes in the cluster apply all writes to their stores.
Shows the rate of successfull readonly/write queries across all servers, across a time window of `1m`.
* `sum(rate(etcd_store_watch_requests_total{job="etcd"}[1m]))`
Shows rate of new watch requests per second. Likely driven by how often watched keys change.
* `sum(etcd_store_watchers{job="etcd"})`
Number of active watchers across all etcd servers.
### wal
| Name | Description | Type |
|------------------------------------|--------------------------------------------------|---------|
| fsync_durations_microseconds | The latency distributions of fsync called by wal | Summary |
| last_index_saved | The index of the last entry saved by wal | Gauge |
Abnormally high fsync duration (`fsync_durations_microseconds`) indicates disk issues and might cause the cluster to be unstable.
### snapshot
| Name | Description | Type |
|--------------------------------------------|------------------------------------------------------------|---------|
| snapshot_save_total_durations_microseconds | The total latency distributions of save called by snapshot | Summary |
Abnormally high snapshot duration (`snapshot_save_total_durations_microseconds`) indicates disk issues and might cause the cluster to be unstable.
### rafthttp
| Name | Description | Type | Labels |
|-----------------------------------|--------------------------------------------|---------|--------------------------------|
| message_sent_latency_microseconds | The latency distributions of messages sent | Summary | sendingType, msgType, remoteID |
| message_sent_failed_total | The total number of failed messages sent | Summary | sendingType, msgType, remoteID |
Abnormally high message duration (`message_sent_latency_microseconds`) indicates network issues and might cause the cluster to be unstable.
An increase in message failures (`message_sent_failed_total`) indicates more severe network issues and might cause the cluster to be unstable.
Label `sendingType` is the connection type to send messages. `message`, `msgapp` and `msgappv2` use HTTP streaming, while `pipeline` does HTTP request for each message.
Label `msgType` is the type of raft message. `MsgApp` is log replication message; `MsgSnap` is snapshot install message; `MsgProp` is proposal forward message; the others are used to maintain raft internal status. If you have a large snapshot, you would expect a long msgSnap sending latency. For other types of messages, you would expect low latency, which is comparable to your ping latency if you have enough network bandwidth.
Label `remoteID` is the member ID of the message destination.
### proxy
etcd members operating in proxy mode do not do store operations. They forward all requests
to cluster instances.
Tracking the rate of requests coming from a proxy allows one to pin down which machine is performing most reads/writes.
All these metrics are prefixed with `etcd_proxy_`
| Name | Description | Type |
|---------------------------|-----------------------------------------------------------------------------------------|--------------------|
| requests_total | Total number of requests by this proxy instance. . | Counter(method) |
| handled_total | Total number of fully handled requests, with responses from etcd members. | Counter(method) |
| dropped_total | Total number of dropped requests due to forwarding errors to etcd members.  | Counter(method,error) |
| handling_duration_seconds | Bucketed handling times by HTTP method, including round trip to member instances. | Histogram(method) |
Example Prometheus queries that may be useful from these metrics (across all etcd servers):
* `sum(rate(etcd_proxy_handled_total{job="etcd"}[1m])) by (method)`
Rate of requests (by HTTP method) handled by all proxies, across a window of `1m`.
* `histogram_quantile(0.9, sum(increase(etcd_proxy_events_handling_time_seconds_bucket{job="etcd",method="GET"}[5m])) by (le))`
`histogram_quantile(0.9, sum(increase(etcd_proxy_events_handling_time_seconds_bucket{job="etcd",method!="GET"}[5m])) by (le))`
Show the 0.90-tile latency (in seconds) of handling of user requestsacross all proxy machines, with a window of `5m`.
* `sum(rate(etcd_proxy_dropped_total{job="etcd"}[1m])) by (proxying_error)`
Number of failed request on the proxy. This should be 0, spikes here indicate connectivity issues to etcd cluster.

119
Documentation/other_apis.md Normal file
View File

@ -0,0 +1,119 @@
## Members API
* [List members](#list-members)
* [Add a member](#add-a-member)
* [Delete a member](#delete-a-member)
* [Change the peer urls of a member](#change-the-peer-urls-of-a-member)
## List members
Return an HTTP 200 OK response code and a representation of all members in the etcd cluster.
### Request
```
GET /v2/members HTTP/1.1
```
### Example
```sh
curl http://10.0.0.10:2379/v2/members
```
```json
{
"members": [
{
"id": "272e204152",
"name": "infra1",
"peerURLs": [
"http://10.0.0.10:2380"
],
"clientURLs": [
"http://10.0.0.10:2379"
]
},
{
"id": "2225373f43",
"name": "infra2",
"peerURLs": [
"http://10.0.0.11:2380"
],
"clientURLs": [
"http://10.0.0.11:2379"
]
},
]
}
```
## Add a member
Returns an HTTP 201 response code and the representation of added member with a newly generated a memberID when successful. Returns a string describing the failure condition when unsuccessful.
If the POST body is malformed an HTTP 400 will be returned. If the member exists in the cluster or existed in the cluster at some point in the past an HTTP 409 will be returned. If any of the given peerURLs exists in the cluster an HTTP 409 will be returned. If the cluster fails to process the request within timeout an HTTP 500 will be returned, though the request may be processed later.
### Request
```
POST /v2/members HTTP/1.1
{"peerURLs": ["http://10.0.0.10:2380"]}
```
### Example
```sh
curl http://10.0.0.10:2379/v2/members -XPOST \
-H "Content-Type: application/json" -d '{"peerURLs":["http://10.0.0.10:2380"]}'
```
```json
{
"id": "3777296169",
"peerURLs": [
"http://10.0.0.10:2380"
]
}
```
## Delete a member
Remove a member from the cluster. The member ID must be a hex-encoded uint64.
Returns 204 with empty content when successful. Returns a string describing the failure condition when unsuccessful.
If the member does not exist in the cluster an HTTP 500(TODO: fix this) will be returned. If the cluster fails to process the request within timeout an HTTP 500 will be returned, though the request may be processed later.
### Request
```
DELETE /v2/members/<id> HTTP/1.1
```
### Example
```sh
curl http://10.0.0.10:2379/v2/members/272e204152 -XDELETE
```
## Change the peer urls of a member
Change the peer urls of a given member. The member ID must be a hex-encoded uint64. Returns 204 with empty content when successful. Returns a string describing the failure condition when unsuccessful.
If the POST body is malformed an HTTP 400 will be returned. If the member does not exist in the cluster an HTTP 404 will be returned. If any of the given peerURLs exists in the cluster an HTTP 409 will be returned. If the cluster fails to process the request within timeout an HTTP 500 will be returned, though the request may be processed later.
#### Request
```
PUT /v2/members/<id> HTTP/1.1
{"peerURLs": ["http://10.0.0.10:2380"]}
```
#### Example
```sh
curl http://10.0.0.10:2379/v2/members/272e204152 -XPUT \
-H "Content-Type: application/json" -d '{"peerURLs":["http://10.0.0.10:2380"]}'
```

View File

@ -0,0 +1,62 @@
# FreeBSD
Starting with version 0.1.2 both etcd and etcdctl have been ported to FreeBSD and can
be installed either via packages or ports system. Their versions have been recently
updated to 0.2.0 so now you can enjoy using etcd and etcdctl on FreeBSD 10.0 (RC4 as
of now) and 9.x where they have been tested. They might also work when installed from
ports on earlier versions of FreeBSD, but your mileage may vary.
## Installation
### Using pkgng package system
1. If you do not have pkg­ng installed, install it with command `pkg` and answering 'Y'
when asked
2. Update your repository data with `pkg update`
3. Install etcd with `pkg install coreos­etcd coreos­etcdctl`
4. Verify successful installation with `pkg info | grep etcd` and you should get:
```
r@fbsd­10:/ # pkg info | grep etcd
coreos­etcd­0.2.0              Highly­available key value store and service discovery
coreos­etcdctl­0.2.0           Simple commandline client for etcd
r@fbsd­10:/ #
```
5. Youre ready to use etcd and etcdctl! For more information about using pkgng, please
see: http://www.freebsd.org/doc/handbook/pkgng­intro.html
 
### Using ports system
1. If you do not have ports installed, install with with `portsnap fetch extract` (it
may take some time depending on your hardware and network connection)
2. Build etcd with `cd /usr/ports/devel/etcd && make install clean`, you
will get an option to build and install documentation and etcdctl with it.
3. If you haven't installed it with etcdctl, and you would like to install it later, you can build it
with `cd /usr/ports/devel/etcdctl && make install clean`
4. Verify successful installation with `pkg info | grep etcd` and you should get:
 
```
r@fbsd­10:/ # pkg info | grep etcd
coreos­etcd­0.2.0              Highly­available key value store and service discovery
coreos­etcdctl­0.2.0           Simple commandline client for etcd
r@fbsd­10:/ #
```
5. Youre ready to use etcd and etcdctl! For more information about using ports system,
please see: https://www.freebsd.org/doc/handbook/ports­using.html
## Issues
If you find any issues with the build/install procedure or you've found a problem that
you've verified is local to FreeBSD version only (for example, by not being able to
reproduce it on any other platform, like OSX or Linux), please sent a
problem report using this page for more
information: http://www.freebsd.org/send­pr.html

View File

@ -0,0 +1,4 @@
etcd is being used successfully by many companies in production. It is,
however, under active development and systems like etcd are difficult to get
correct. If you are comfortable with bleeding-edge software please use etcd and
provide us with the feedback and testing young software needs.

37
Documentation/proxy.md Normal file
View File

@ -0,0 +1,37 @@
## Proxy
etcd can now run as a transparent proxy. Running etcd as a proxy allows for easily discovery of etcd within your infrastructure, since it can run on each machine as a local service. In this mode, etcd acts as a reverse proxy and forwards client requests to an active etcd cluster. The etcd proxy does not participate in the consensus replication of the etcd cluster, thus it neither increases the resilience nor decreases the write performance of the etcd cluster.
etcd currently supports two proxy modes: `readwrite` and `readonly`. The default mode is `readwrite`, which forwards both read and write requests to the etcd cluster. A `readonly` etcd proxy only forwards read requests to the etcd cluster, and returns `HTTP 501` to all write requests.
The proxy will shuffle the list of cluster members periodically to avoid sending all connections to a single member.
The member list used by proxy consists of all client URLs advertised within the cluster, as specified in each members' `-advertise-client-urls` flag. If this flag is set incorrectly, requests sent to the proxy are forwarded to wrong addresses and then fail. Including URLs in the `-advertise-client-urls` flag that point to the proxy itself, e.g. http://localhost:2379, is even more problematic as it will cause loops, because the proxy keeps trying to forward requests to itself until its resources (memory, file descriptors) are eventually depleted. The fix for this problem is to restart etcd member with correct `-advertise-client-urls` flag. After client URLs list in proxy is recalculated, which happens every 30 seconds, requests will be forwarded correctly.
### Using an etcd proxy
To start etcd in proxy mode, you need to provide three flags: `proxy`, `listen-client-urls`, and `initial-cluster` (or `discovery`).
To start a readwrite proxy, set `-proxy on`; To start a readonly proxy, set `-proxy readonly`.
The proxy will be listening on `listen-client-urls` and forward requests to the etcd cluster discovered from in `initial-cluster` or `discovery` url.
#### Start an etcd proxy with a static configuration
To start a proxy that will connect to a statically defined etcd cluster, specify the `initial-cluster` flag:
```
etcd -proxy on -listen-client-urls http://127.0.0.1:8080 -initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380
```
#### Start an etcd proxy with the discovery service
If you bootstrap an etcd cluster using the [discovery service][discovery-service], you can also start the proxy with the same `discovery`.
To start a proxy using the discovery service, specify the `discovery` flag. The proxy will wait until the etcd cluster defined at the `discovery` url finishes bootstrapping, and then start to forward the requests.
```
etcd -proxy on -listen-client-urls http://127.0.0.1:8080 -discovery https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de
```
#### Fallback to proxy mode with discovery service
If you bootstrap a etcd cluster using [discovery service][discovery-service] with more than the expected number of etcd members, the extra etcd processes will fall back to being `readwrite` proxies by default. They will forward the requests to the cluster as described above. For example, if you create a discovery url with `size=5`, and start ten etcd processes using that same discovery url, the result will be a cluster with five etcd members and five proxies. Note that this behaviour can be disabled with the `proxy-fallback` flag.
[discovery-service]: clustering.md#discovery

View File

@ -0,0 +1,43 @@
## Reporting Bugs
If you find bugs or documentation mistakes in etcd project, please let us know by [opening an issue](https://github.com/coreos/etcd/issues/new). We treat bugs and mistakes very seriously and believe no issue is too small. Before creating a bug report, please check there that one does not already exist.
To make your bug report accurate and easy to understand, please try to create bug reports that are:
- Specific. Include as much details as possible: which version, what environment, what configuration, etc. You can also attach etcd log (the starting log with etcd configuration is especially important).
- Reproducible. Include the steps to reproduce the problem. We understand some issues might be hard to reproduce, please includes the steps that might lead to the problem. You can also attach the affected etcd data dir and stack strace to the bug report.
- Isolated. Please try to isolate and reproduce the bug with minimum dependencies. It would significantly slow down the speed to fix a bug if too many dependencies are involved in a bug report. Debugging external systems that rely on etcd is out of scope, but we are happy to point you in the right direction or help you interact with etcd in the correct manner.
- Unique. Do not duplicate existing bug report.
- Scoped. One bug per report. Do not follow up with another bug inside one report.
You might also want to read [Elika Etemads article on filing good bug reports](http://fantasai.inkedblade.net/style/talks/filing-good-bugs/) before creating a bug report.
We might ask you for further information to locate a bug. A duplicated bug report will be closed.
## Frequently Asked Questions
### How to get stack trace
``` bash
$ kill -QUIT $PID
```
### How to get etcd version
``` bash
$ etcd --version
```
### How to get etcd configuration and log when it runs as systemd service etcd2.service
``` bash
$ sudo systemctl cat etcd2
$ sudo journalctl -u etcd2
```
Due to an upstream systemd bug, journald may miss the last few log lines when its process exit. If journalctl tells you that etcd stops without fatal or panic message, you could try `sudo journalctl -f -t etcd2` to get full log.

191
Documentation/rfc/v3api.md Normal file
View File

@ -0,0 +1,191 @@
## Design
1. Flatten binary key-value space
2. Keep the event history until compaction
- access to old version of keys
- user controlled history compaction
3. Support range query
- Pagination support with limit argument
- Support consistency guarantee across multiple range queries
4. Replace TTL key with Lease
- more efficient/ low cost keep alive
- a logical group of TTL keys
5. Replace CAS/CAD with multi-object Txn
- MUCH MORE powerful and flexible
6. Support efficient watching with multiple ranges
7. RPC API supports the completed set of APIs.
- more efficient than JSON/HTTP
- additional txn/lease support
8. HTTP API supports a subset of APIs.
- easy for people to try out etcd
- easy for people to write simple etcd application
## Protobuf Defined API
[protobuf](./v3api.proto)
### Examples
#### Put a key (foo=bar)
```
// A put is always successful
Put( PutRequest { key = foo, value = bar } )
PutResponse {
cluster_id = 0x1000,
member_id = 0x1,
revision = 1,
raft_term = 0x1,
}
```
#### Get a key (assume we have foo=bar)
```
Get ( RangeRequest { key = foo } )
RangeResponse {
cluster_id = 0x1000,
member_id = 0x1,
revision = 1,
raft_term = 0x1,
kvs = {
{
key = foo,
value = bar,
create_revision = 1,
mod_revision = 1,
version = 1;
},
},
}
```
#### Range over a key space (assume we have foo0=bar0… foo100=bar100)
```
Range ( RangeRequest { key = foo, end_key = foo80, limit = 30 } )
RangeResponse {
cluster_id = 0x1000,
member_id = 0x1,
revision = 100,
raft_term = 0x1,
kvs = {
{
key = foo0,
value = bar0,
create_revision = 1,
mod_revision = 1,
version = 1;
},
...,
{
key = foo30,
value = bar30,
create_revision = 30,
mod_revision = 30,
version = 1;
},
},
}
```
#### Finish a txn (assume we have foo0=bar0, foo1=bar1)
```
Txn(TxnRequest {
// mod_revision of foo0 is equal to 1, mod_revision of foo1 is greater than 1
compare = {
{compareType = equal, key = foo0, mod_revision = 1},
{compareType = greater, key = foo1, mod_revision = 1}}
},
// if the comparison succeeds, put foo2 = bar2
success = {PutRequest { key = foo2, value = success }},
// if the comparison fails, put foo2=fail
failure = {PutRequest { key = foo2, value = failure }},
)
TxnResponse {
cluster_id = 0x1000,
member_id = 0x1,
revision = 3,
raft_term = 0x1,
succeeded = true,
responses = {
// response of PUT foo2=success
{
cluster_id = 0x1000,
member_id = 0x1,
revision = 3,
raft_term = 0x1,
}
}
}
```
#### Watch on a key/range
```
Watch( WatchRequest{
key = foo,
end_key = fop, // prefix foo
start_revision = 20,
end_revision = 10000,
// server decided notification frequency
progress_notification = true,
}
… // this can be a watch request stream
)
// put (foo0=bar0) event at 3
WatchResponse {
cluster_id = 0x1000,
member_id = 0x1,
revision = 3,
raft_term = 0x1,
event_type = put,
kv = {
key = foo0,
value = bar0,
create_revision = 1,
mod_revision = 1,
version = 1;
},
}
// a notification at 2000
WatchResponse {
cluster_id = 0x1000,
member_id = 0x1,
revision = 2000,
raft_term = 0x1,
// nil event as notification
}
// put (foo0=bar3000) event at 3000
WatchResponse {
cluster_id = 0x1000,
member_id = 0x1,
revision = 3000,
raft_term = 0x1,
event_type = put,
kv = {
key = foo0,
value = bar3000,
create_revision = 1,
mod_revision = 3000,
version = 2;
},
}
```

View File

@ -0,0 +1,285 @@
syntax = "proto3";
// Interface exported by the server.
service etcd {
// Range gets the keys in the range from the store.
rpc Range(RangeRequest) returns (RangeResponse) {}
// Put puts the given key into the store.
// A put request increases the revision of the store,
// and generates one event in the event history.
rpc Put(PutRequest) returns (PutResponse) {}
// Delete deletes the given range from the store.
// A delete request increase the revision of the store,
// and generates one event in the event history.
rpc DeleteRange(DeleteRangeRequest) returns (DeleteRangeResponse) {}
// Txn processes all the requests in one transaction.
// A txn request increases the revision of the store,
// and generates events with the same revision in the event history.
rpc Txn(TxnRequest) returns (TxnResponse) {}
// Watch watches the events happening or happened in etcd. Both input and output
// are stream. One watch rpc can watch for multiple ranges and get a stream of
// events. The whole events history can be watched unless compacted.
rpc WatchRange(stream WatchRangeRequest) returns (stream WatchRangeResponse) {}
// Compact compacts the event history in etcd. User should compact the
// event history periodically, or it will grow infinitely.
rpc Compact(CompactionRequest) returns (CompactionResponse) {}
// LeaseCreate creates a lease. A lease has a TTL. The lease will expire if the
// server does not receive a keepAlive within TTL from the lease holder.
// All keys attached to the lease will be expired and deleted if the lease expires.
// The key expiration generates an event in event history.
rpc LeaseCreate(LeaseCreateRequest) returns (LeaseCreateResponse) {}
// LeaseRevoke revokes a lease. All the key attached to the lease will be expired and deleted.
rpc LeaseRevoke(LeaseRevokeRequest) returns (LeaseRevokeResponse) {}
// LeaseAttach attaches keys with a lease.
rpc LeaseAttach(LeaseAttachRequest) returns (LeaseAttachResponse) {}
// LeaseTxn likes Txn. It has two addition success and failure LeaseAttachRequest list.
// If the Txn is successful, then the success list will be executed. Or the failure list
// will be executed.
rpc LeaseTxn(LeaseTxnRequest) returns (LeaseTxnResponse) {}
// KeepAlive keeps the lease alive.
rpc LeaseKeepAlive(stream LeaseKeepAliveRequest) returns (stream LeaseKeepAliveResponse) {}
}
message ResponseHeader {
// an error type message?
string error = 1;
uint64 cluster_id = 2;
uint64 member_id = 3;
// revision of the store when the request was applied.
int64 revision = 4;
// term of raft when the request was applied.
uint64 raft_term = 5;
}
message RangeRequest {
// if the range_end is not given, the request returns the key.
bytes key = 1;
// if the range_end is given, it gets the keys in range [key, range_end).
bytes range_end = 2;
// limit the number of keys returned.
int64 limit = 3;
// range over the store at the given revision.
// if revision is less or equal to zero, range over the newest store.
// if the revision has been compacted, ErrCompaction will be returned in
// response.
int64 revision = 4;
}
message RangeResponse {
ResponseHeader header = 1;
repeated storagepb.KeyValue kvs = 2;
// more indicates if there are more keys to return in the requested range.
bool more = 3;
}
message PutRequest {
bytes key = 1;
bytes value = 2;
}
message PutResponse {
ResponseHeader header = 1;
}
message DeleteRangeRequest {
// if the range_end is not given, the request deletes the key.
bytes key = 1;
// if the range_end is given, it deletes the keys in range [key, range_end).
bytes range_end = 2;
}
message DeleteRangeResponse {
ResponseHeader header = 1;
}
message RequestUnion {
oneof request {
RangeRequest request_range = 1;
PutRequest request_put = 2;
DeleteRangeRequest request_delete_range = 3;
}
}
message ResponseUnion {
oneof response {
RangeResponse response_range = 1;
PutResponse response_put = 2;
DeleteRangeResponse response_delete_range = 3;
}
}
message Compare {
enum CompareResult {
EQUAL = 0;
GREATER = 1;
LESS = 2;
}
enum CompareTarget {
VERSION = 0;
CREATE = 1;
MOD = 2;
VALUE= 3;
}
CompareResult result = 1;
CompareTarget target = 2;
// key path
bytes key = 3;
oneof target_union {
// version of the given key
int64 version = 4;
// create revision of the given key
int64 create_revision = 5;
// last modified revision of the given key
int64 mod_revision = 6;
// value of the given key
bytes value = 7;
}
}
// If the comparisons succeed, then the success requests will be processed in order,
// and the response will contain their respective responses in order.
// If the comparisons fail, then the failure requests will be processed in order,
// and the response will contain their respective responses in order.
// From google paxosdb paper:
// Our implementation hinges around a powerful primitive which we call MultiOp. All other database
// operations except for iteration are implemented as a single call to MultiOp. A MultiOp is applied atomically
// and consists of three components:
// 1. A list of tests called guard. Each test in guard checks a single entry in the database. It may check
// for the absence or presence of a value, or compare with a given value. Two different tests in the guard
// may apply to the same or different entries in the database. All tests in the guard are applied and
// MultiOp returns the results. If all tests are true, MultiOp executes t op (see item 2 below), otherwise
// it executes f op (see item 3 below).
// 2. A list of database operations called t op. Each operation in the list is either an insert, delete, or
// lookup operation, and applies to a single database entry. Two different operations in the list may apply
// to the same or different entries in the database. These operations are executed
// if guard evaluates to
// true.
// 3. A list of database operations called f op. Like t op, but executed if guard evaluates to false.
message TxnRequest {
repeated Compare compare = 1;
repeated RequestUnion success = 2;
repeated RequestUnion failure = 3;
}
message TxnResponse {
ResponseHeader header = 1;
bool succeeded = 2;
repeated ResponseUnion responses = 3;
}
message KeyValue {
bytes key = 1;
int64 create_revision = 2;
// mod_revision is the last modified revision of the key.
int64 mod_revision = 3;
// version is the version of the key. A deletion resets
// the version to zero and any modification of the key
// increases its version.
int64 version = 4;
bytes value = 5;
}
message WatchRangeRequest {
// if the range_end is not given, the request returns the key.
bytes key = 1;
// if the range_end is given, it gets the keys in range [key, range_end).
bytes range_end = 2;
// start_revision is an optional revision (including) to watch from. No start_revision is "now".
int64 start_revision = 3;
// end_revision is an optional revision (excluding) to end watch. No end_revision is "forever".
int64 end_revision = 4;
bool progress_notification = 5;
}
message WatchRangeResponse {
ResponseHeader header = 1;
repeated Event events = 2;
}
message Event {
enum EventType {
PUT = 0;
DELETE = 1;
EXPIRE = 2;
}
EventType event_type = 1;
// a put event contains the current key-value
// a delete/expire event contains the previous
// key-value
KeyValue kv = 2;
}
// Compaction compacts the kv store upto the given revision (including).
// It removes the old versions of a key. It keeps the newest version of
// the key even if its latest modification revision is smaller than the given
// revision.
message CompactionRequest {
int64 revision = 1;
}
message CompactionResponse {
ResponseHeader header = 1;
}
message LeaseCreateRequest {
// advisory ttl in seconds
int64 ttl = 1;
}
message LeaseCreateResponse {
ResponseHeader header = 1;
int64 lease_id = 2;
// server decided ttl in second
int64 ttl = 3;
string error = 4;
}
message LeaseRevokeRequest {
int64 lease_id = 1;
}
message LeaseRevokeResponse {
ResponseHeader header = 1;
}
message LeaseTxnRequest {
TxnRequest request = 1;
repeated LeaseAttachRequest success = 2;
repeated LeaseAttachRequest failure = 3;
}
message LeaseTxnResponse {
ResponseHeader header = 1;
TxnResponse response = 2;
repeated LeaseAttachResponse attach_responses = 3;
}
message LeaseAttachRequest {
int64 lease_id = 1;
bytes key = 2;
}
message LeaseAttachResponse {
ResponseHeader header = 1;
}
message LeaseKeepAliveRequest {
int64 lease_id = 1;
}
message LeaseKeepAliveResponse {
ResponseHeader header = 1;
int64 lease_id = 2;
int64 ttl = 3;
}

View File

@ -0,0 +1,163 @@
## Runtime Reconfiguration
etcd comes with support for incremental runtime reconfiguration, which allows users to update the membership of the cluster at run time.
Reconfiguration requests can only be processed when the the majority of the cluster members are functioning. It is **highly recommended** to always have a cluster size greater than two in production. It is unsafe to remove a member from a two member cluster. The majority of a two member cluster is also two. If there is a failure during the removal process, the cluster might not able to make progress and need to [restart from majority failure][majority failure].
To better understand the design behind runtime reconfiguration, we suggest you read [this](runtime-reconf-design.md).
[majority failure]: #restart-cluster-from-majority-failure
## Reconfiguration Use Cases
Let us walk through some common reasons for reconfiguring a cluster. Most of these just involve combinations of adding or removing a member, which are explained below under [Cluster Reconfiguration Operations](#cluster-reconfiguration-operations).
### Cycle or Upgrade Multiple Machines
If you need to move multiple members of your cluster due to planned maintenance (hardware upgrades, network downtime, etc.), it is recommended to modify members one at a time.
It is safe to remove the leader, however there is a brief period of downtime while the election process takes place. If your cluster holds more than 50MB, it is recommended to [migrate the member's data directory][member migration].
[member migration]: admin_guide.md#member-migration
### Change the Cluster Size
Increasing the cluster size can enhance [failure tolerance][fault tolerance table] and provide better read performance. Since clients can read from any member, increasing the number of members increases the overall read throughput.
Decreasing the cluster size can improve the write performance of a cluster, with a trade-off of decreased resilience. Writes into the cluster are replicated to a majority of members of the cluster before considered committed. Decreasing the cluster size lowers the majority, and each write is committed more quickly.
[fault tolerance table]: admin_guide.md#fault-tolerance-table
### Replace A Failed Machine
If a machine fails due to hardware failure, data directory corruption, or some other fatal situation, it should be replaced as soon as possible. Machines that have failed but haven't been removed adversely affect your quorum and reduce the tolerance for an additional failure.
To replace the machine, follow the instructions for [removing the member][remove member] from the cluster, and then [add a new member][add member] in its place. If your cluster holds more than 50MB, it is recommended to [migrate the failed member's data directory][member migration] if you can still access it.
[remove member]: #remove-a-member
[add member]: #add-a-new-member
### Restart Cluster from Majority Failure
If the majority of your cluster is lost or all of your nodes have changed IP addresses, then you need to take manual action in order to recover safely.
The basic steps in the recovery process include [creating a new cluster using the old data][disaster recovery], forcing a single member to act as the leader, and finally using runtime configuration to [add new members][add member] to this new cluster one at a time.
[add member]: #add-a-new-member
[disaster recovery]: admin_guide.md#disaster-recovery
## Cluster Reconfiguration Operations
Now that we have the use cases in mind, let us lay out the operations involved in each.
Before making any change, the simple majority (quorum) of etcd members must be available.
This is essentially the same requirement as for any other write to etcd.
All changes to the cluster are done one at a time:
* To update a single member peerURLs you will make an update operation
* To replace a single member you will make an add then a remove operation
* To increase from 3 to 5 members you will make two add operations
* To decrease from 5 to 3 you will make two remove operations
All of these examples will use the `etcdctl` command line tool that ships with etcd.
If you want to use the member API directly you can find the documentation [here](other_apis.md).
### Update a Member
If you would like to update a member IP address (peerURLs), first, we need to find the target member's ID. You can list all members with `etcdctl`:
```sh
$ etcdctl member list
6e3bd23ae5f1eae0: name=node2 peerURLs=http://localhost:23802 clientURLs=http://127.0.0.1:23792
924e2e83e93f2560: name=node3 peerURLs=http://localhost:23803 clientURLs=http://127.0.0.1:23793
a8266ecf031671f3: name=node1 peerURLs=http://localhost:23801 clientURLs=http://127.0.0.1:23791
```
In this example let's `update` a8266ecf031671f3 member ID and change its peerURLs value to http://10.0.1.10:2380
```sh
$ etcdctl member update a8266ecf031671f3 http://10.0.1.10:2380
Updated member with ID a8266ecf031671f3 in cluster
```
### Remove a Member
Let us say the member ID we want to remove is a8266ecf031671f3.
We then use the `remove` command to perform the removal:
```sh
$ etcdctl member remove a8266ecf031671f3
Removed member a8266ecf031671f3 from cluster
```
The target member will stop itself at this point and print out the removal in the log:
```
etcd: this member has been permanently removed from the cluster. Exiting.
```
It is safe to remove the leader, however the cluster will be inactive while a new leader is elected. This duration is normally the period of election timeout plus the voting process.
### Add a New Member
Adding a member is a two step process:
* Add the new member to the cluster via the [members API](other_apis.md#post-v2members) or the `etcdctl member add` command.
* Start the new member with the new cluster configuration, including a list of the updated members (existing members + the new member).
Using `etcdctl` let's add the new member to the cluster by specifying its [name](configuration.md#-name) and [advertised peer URLs](configuration.md#-initial-advertise-peer-urls):
```sh
$ etcdctl member add infra3 http://10.0.1.13:2380
added member 9bf1b35fc7761a23 to cluster
ETCD_NAME="infra3"
ETCD_INITIAL_CLUSTER="infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380,infra3=http://10.0.1.13:2380"
ETCD_INITIAL_CLUSTER_STATE=existing
```
`etcdctl` has informed the cluster about the new member and printed out the environment variables needed to successfully start it.
Now start the new etcd process with the relevant flags for the new member:
```sh
$ export ETCD_NAME="infra3"
$ export ETCD_INITIAL_CLUSTER="infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380,infra3=http://10.0.1.13:2380"
$ export ETCD_INITIAL_CLUSTER_STATE=existing
$ etcd -listen-client-urls http://10.0.1.13:2379 -advertise-client-urls http://10.0.1.13:2379 -listen-peer-urls http://10.0.1.13:2380 -initial-advertise-peer-urls http://10.0.1.13:2380 -data-dir %data_dir%
```
The new member will run as a part of the cluster and immediately begin catching up with the rest of the cluster.
If you are adding multiple members the best practice is to configure a single member at a time and verify it starts correctly before adding more new members.
If you add a new member to a 1-node cluster, the cluster cannot make progress before the new member starts because it needs two members as majority to agree on the consensus. You will only see this behavior between the time `etcdctl member add` informs the cluster about the new member and the new member successfully establishing a connection to the existing one.
#### Error Cases
In the following case we have not included our new host in the list of enumerated nodes.
If this is a new cluster, the node must be added to the list of initial cluster members.
```sh
$ etcd -name infra3 \
-initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380 \
-initial-cluster-state existing
etcdserver: assign ids error: the member count is unequal
exit 1
```
In this case we give a different address (10.0.1.14:2380) to the one that we used to join the cluster (10.0.1.13:2380).
```sh
$ etcd -name infra4 \
-initial-cluster infra0=http://10.0.1.10:2380,infra1=http://10.0.1.11:2380,infra2=http://10.0.1.12:2380,infra4=http://10.0.1.14:2380 \
-initial-cluster-state existing
etcdserver: assign ids error: unmatched member while checking PeerURLs
exit 1
```
When we start etcd using the data directory of a removed member, etcd will exit automatically if it connects to any alive member in the cluster:
```sh
$ etcd
etcd: this member has been permanently removed from the cluster. Exiting.
exit 1
```

View File

@ -0,0 +1,47 @@
### Design of Runtime Reconfiguration
Runtime reconfiguration is one of the hardest and most error prone features in a distributed system, especially in a consensus based system like etcd.
Read on to learn about the design of etcd's runtime reconfiguration commands and how we tackled these problems.
### Two Phase Config Changes Keep you Safe
In etcd, every runtime reconfiguration has to go through [two phases](Documentation/runtime-configuration.md#add-a-new-member) for safety reasons. For example, to add a member you need to first inform cluster of new configuration and then start the new member.
Phase 1 - Inform cluster of new configuration
To add a member into etcd cluster, you need to make an API call to request a new member to be added to the cluster. And this is only way that you can add a new member into an existing cluster. The API call returns when the cluster agrees on the configuration change.
Phase 2 - Start new member
To join the etcd member into the existing cluster, you need to specify the correct `initial-cluster` and set `initial-cluster-state` to `existing`. When the member starts, it will contact the existing cluster first and verify the current cluster configuration matches the expected one specified in `initial-cluster`. When the new member successfully starts, you know your cluster reached the expected configuration.
By splitting the process into two discrete phases users are forced to be explicit regarding cluster membership changes. This actually gives users more flexibility and makes things easier to reason about. For example, if there is an attempt to add a new member with the same ID as an existing member in an etcd cluster, the action will fail immediately during phase one without impacting the running cluster. Similar protection is provided to prevent adding new members by mistake. If a new etcd member attempts to join the cluster before the cluster has accepted the configuration change,, it will not be accepted by the cluster.
Without the explicit workflow around cluster membership etcd would be vulnerable to unexpected cluster membership changes. For example, if etcd is running under an init system such as systemd, etcd would be restarted after being removed via the membership API, and attempt to rejoin the cluster on startup. This cycle would continue every time a member is removed via the API and systemd is set to restart etcd after failing, which is unexpected.
We think runtime reconfiguration should be a low frequent operation. We made the decision to keep it explicit and user-driven to ensure configuration safety and keep your cluster always running smoothly under your control.
### Permanent Loss of Quorum Requires New Cluster
If a cluster permanently loses a majority of its members, a new cluster will need to be started from an old data directory to recover the previous state.
It is entirely possible to force removing the failed members from the existing cluster to recover. However, we decided not to support this method since it bypasses the normal consensus committing phase, which is unsafe. If the member to remove is not actually dead or you force to remove different members through different members in the same cluster, you will end up with diverged cluster with same clusterID. This is very dangerous and hard to debug/fix afterwards.
If you have a correct deployment, the possibility of permanent majority lose is very low. But it is a severe enough problem that worth special care. We strongly suggest you to read the [disaster recovery documentation](admin_guide.md#disaster-recovery) and prepare for permanent majority lose before you put etcd into production.
### Do Not Use Public Discovery Service For Runtime Reconfiguration
The public discovery service should only be used for bootstrapping a cluster. To join member into an existing cluster, you should use runtime reconfiguration API.
Discovery service is designed for bootstrapping an etcd cluster in the cloud environment, when you do not know the IP addresses of all the members beforehand. After you successfully bootstrap a cluster, the IP addresses of all the members are known. Technically, you should not need the discovery service any more.
It seems that using public discovery service is a convenient way to do runtime reconfiguration, after all discovery service already has all the cluster configuration information. However relying on public discovery service brings troubles:
1. it introduces a external dependencies for the entire life-cycle of your cluster, not just bootstrap time. If there is a network issue between your cluster and public discover service, your cluster will suffer from it.
2. public discovery service must reflect correct runtime configuration of your cluster during it life-cycle. It has to provide security mechanism to avoid bad actions, and it is hard.
3. public discovery service has to keep tens of thousands of cluster configurations. Our public discovery service backend is not ready for that workload.
If you want to have a discovery service that supports runtime reconfiguration, the best choice is to build your private one.

182
Documentation/security.md Normal file
View File

@ -0,0 +1,182 @@
# security model
etcd supports SSL/TLS as well as authentication through client certificates, both for clients to server as well as peer (server to server / cluster) communication.
To get up and running you first need to have a CA certificate and a signed key pair for one member. It is recommended to create and sign a new key pair for every member in a cluster.
For convenience the [cfssl](https://github.com/cloudflare/cfssl) tool provides an easy interface to certificate generation, and we provide a full example using the tool at [here](../hack/tls-setup). Alternatively this site provides a good reference on how to generate self-signed key pairs:
http://www.g-loaded.eu/2005/11/10/be-your-own-ca/
## Basic setup
etcd takes several certificate related configuration options, either through command-line flags or environment variables:
**Client-to-server communication:**
`--cert-file=<path>`: Certificate used for SSL/TLS connections **to** etcd. When this option is set, you can set advertise-client-urls using HTTPS schema.
`--key-file=<path>`: Key for the certificate. Must be unencrypted.
`--client-cert-auth`: When this is set etcd will check all incoming HTTPS requests for a client certificate signed by the trusted CA, requests that don't supply a valid client certificate will fail.
`--trusted-ca-file=<path>`: Trusted certificate authority.
**Peer (server-to-server / cluster) communication:**
The peer options work the same way as the client-to-server options:
`--peer-cert-file=<path>`: Certificate used for SSL/TLS connections between peers. This will be used both for listening on the peer address as well as sending requests to other peers.
`--peer-key-file=<path>`: Key for the certificate. Must be unencrypted.
`--peer-client-cert-auth`: When set, etcd will check all incoming peer requests from the cluster for valid client certificates signed by the supplied CA.
`--peer-trusted-ca-file=<path>`: Trusted certificate authority.
If either a client-to-server or peer certificate is supplied the key must also be set. All of these configuration options are also available through the environment variables, `ETCD_CA_FILE`, `ETCD_PEER_CA_FILE` and so on.
## Example 1: Client-to-server transport security with HTTPS
For this you need your CA certificate (`ca.crt`) and signed key pair (`server.crt`, `server.key`) ready.
Let us configure etcd to provide simple HTTPS transport security step by step:
```sh
$ etcd -name infra0 -data-dir infra0 \
-cert-file=/path/to/server.crt -key-file=/path/to/server.key \
-advertise-client-urls=https://127.0.0.1:2379 -listen-client-urls=https://127.0.0.1:2379
```
This should start up fine and you can now test the configuration by speaking HTTPS to etcd:
```sh
$ curl --cacert /path/to/ca.crt https://127.0.0.1:2379/v2/keys/foo -XPUT -d value=bar -v
```
You should be able to see the handshake succeed. Because we use self-signed certificates with our own certificate authorities you need to provide the CA to curl using the `--cacert` option. Another possibility would be to add your CA certificate to the trusted certificates on your system (usually in `/etc/ssl/certs`).
**OSX 10.9+ Users**: curl 7.30.0 on OSX 10.9+ doesn't understand certificates passed in on the command line.
Instead you must import the dummy ca.crt directly into the keychain or add the `-k` flag to curl to ignore errors.
If you want to test without the `-k` flag run `open ./fixtures/ca/ca.crt` and follow the prompts.
Please remove this certificate after you are done testing!
If you know of a workaround let us know.
## Example 2: Client-to-server authentication with HTTPS client certificates
For now we've given the etcd client the ability to verify the server identity and provide transport security. We can however also use client certificates to prevent unauthorized access to etcd.
The clients will provide their certificates to the server and the server will check whether the cert is signed by the supplied CA and decide whether to serve the request.
You need the same files mentioned in the first example for this, as well as a key pair for the client (`client.crt`, `client.key`) signed by the same certificate authority.
```sh
$ etcd -name infra0 -data-dir infra0 \
-client-cert-auth -trusted-ca-file=/path/to/ca.crt -cert-file=/path/to/server.crt -key-file=/path/to/server.key \
-advertise-client-urls https://127.0.0.1:2379 -listen-client-urls https://127.0.0.1:2379
```
Now try the same request as above to this server:
```sh
$ curl --cacert /path/to/ca.crt https://127.0.0.1:2379/v2/keys/foo -XPUT -d value=bar -v
```
The request should be rejected by the server:
```
...
routines:SSL3_READ_BYTES:sslv3 alert bad certificate
...
```
To make it succeed, we need to give the CA signed client certificate to the server:
```sh
$ curl --cacert /path/to/ca.crt --cert /path/to/client.crt --key /path/to/client.key \
-L https://127.0.0.1:2379/v2/keys/foo -XPUT -d value=bar -v
```
You should able to see:
```
...
SSLv3, TLS handshake, CERT verify (15):
...
TLS handshake, Finished (20)
```
And also the response from the server:
```json
{
"action": "set",
"node": {
"createdIndex": 12,
"key": "/foo",
"modifiedIndex": 12,
"value": "bar"
}
}
```
## Example 3: Transport security & client certificates in a cluster
etcd supports the same model as above for **peer communication**, that means the communication between etcd members in a cluster.
Assuming we have our `ca.crt` and two members with their own keypairs (`member1.crt` & `member1.key`, `member2.crt` & `member2.key`) signed by this CA, we launch etcd as follows:
```sh
DISCOVERY_URL=... # from https://discovery.etcd.io/new
# member1
$ etcd -name infra1 -data-dir infra1 \
-peer-client-cert-auth -peer-trusted-ca-file=/path/to/ca.crt -peer-cert-file=/path/to/member1.crt -peer-key-file=/path/to/member1.key \
-initial-advertise-peer-urls=https://10.0.1.10:2380 -listen-peer-urls=https://10.0.1.10:2380 \
-discovery ${DISCOVERY_URL}
# member2
$ etcd -name infra2 -data-dir infra2 \
-peer-client-cert-atuh -peer-trusted-ca-file=/path/to/ca.crt -peer-cert-file=/path/to/member2.crt -peer-key-file=/path/to/member2.key \
-initial-advertise-peer-urls=https://10.0.1.11:2380 -listen-peer-urls=https://10.0.1.11:2380 \
-discovery ${DISCOVERY_URL}
```
The etcd members will form a cluster and all communication between members in the cluster will be encrypted and authenticated using the client certificates. You will see in the output of etcd that the addresses it connects to use HTTPS.
## Frequently Asked Questions
### My cluster is not working with peer tls configuration?
The internal protocol of etcd v2.0.x uses a lot of short-lived HTTP connections.
So, when enabling TLS you may need to increase the heartbeat interval and election timeouts to reduce internal cluster connection churn.
A reasonable place to start are these values: ` --heartbeat-interval 500 --election-timeout 2500`.
This issues is resolved in the etcd v2.1.x series of releases which uses fewer connections.
### I'm seeing a SSLv3 alert handshake failure when using SSL client authentication?
The `crypto/tls` package of `golang` checks the key usage of the certificate public key before using it.
To use the certificate public key to do client auth, we need to add `clientAuth` to `Extended Key Usage` when creating the certificate public key.
Here is how to do it:
Add the following section to your openssl.cnf:
```
[ ssl_client ]
...
extendedKeyUsage = clientAuth
...
```
When creating the cert be sure to reference it in the `-extensions` flag:
```
$ openssl ca -config openssl.cnf -policy policy_anything -extensions ssl_client -out certs/machine.crt -infiles machine.csr
```
### With peer certificate authentication I receive "certificate is valid for 127.0.0.1, not $MY_IP"
Make sure that you sign your certificates with a Subject Name your member's public IP address. The `etcd-ca` tool for example provides an `--ip=` option for its `new-cert` command.
If you need your certificate to be signed for your member's FQDN in its Subject Name then you could use Subject Alternative Names (short IP SANs) to add your IP address. The `etcd-ca` tool provides `--domain=` option for its `new-cert` command, and openssl can make [it](http://wiki.cacert.org/FAQ/subjectAltName) too.

70
Documentation/tuning.md Normal file
View File

@ -0,0 +1,70 @@
## Tuning
The default settings in etcd should work well for installations on a local network where the average network latency is low.
However, when using etcd across multiple data centers or over networks with high latency you may need to tweak the heartbeat interval and election timeout settings.
The network isn't the only source of latency. Each request and response may be impacted by slow disks on both the leader and follower. Each of these timeouts represents the total time from request to successful response from the other machine.
### Time Parameters
The underlying distributed consensus protocol relies on two separate time parameters to ensure that nodes can handoff leadership if one stalls or goes offline.
The first parameter is called the *Heartbeat Interval*.
This is the frequency with which the leader will notify followers that it is still the leader.
For best pratices, the parameter should be set around round-trip time between members.
By default, etcd uses a `100ms` heartbeat interval.
The second parameter is the *Election Timeout*.
This timeout is how long a follower node will go without hearing a heartbeat before attempting to become leader itself.
By default, etcd uses a `1000ms` election timeout.
Adjusting these values is a trade off.
The value of heartbeat interval is recommended to be around the maximum of average round-trip time (RTT) between members, normally around 0.5-1.5x the round-trip time.
If heartbeat interval is too low, etcd will send unnecessary messages that increase the usage of CPU and network resources.
On the other side, a too high heartbeat interval leads to high election timeout. Higher election timeout takes longer time to detect a leader failure.
The easiest way to measure round-trip time (RTT) is to use [PING utility](https://en.wikipedia.org/wiki/Ping_(networking_utility)).
The election timeout should be set based on the heartbeat interval and average round-trip time between members.
Election timeouts must be at least 10 times the round-trip time so it can account for variance in your network.
For example, if the round-trip time between your members is 10ms then you should have at least a 100ms election timeout.
The upper limit of election timeout is 50000ms, which should only be used when deploying global etcd cluster. First, 5s is the upper limit of average global round-trip time. A reasonable round-trip time for the continental united states is 130ms, and the time between US and japan is around 350-400ms. Because package gets delayed a lot, and network situation may be terrible, 5s is a safe value for it. Then, because election timeout should be an order of magnitude bigger than broadcast time, 50s becomes its maximum.
You should also set your election timeout to at least 5 to 10 times your heartbeat interval to account for variance in leader replication.
For a heartbeat interval of 50ms you should set your election timeout to at least 250ms - 500ms.
The heartbeat interval and election timeout value should be the same for all members in one cluster. Setting different values for etcd members may disrupt cluster stability.
You can override the default values on the command line:
```sh
# Command line arguments:
$ etcd -heartbeat-interval=100 -election-timeout=500
# Environment variables:
$ ETCD_HEARTBEAT_INTERVAL=100 ETCD_ELECTION_TIMEOUT=500 etcd
```
The values are specified in milliseconds.
### Snapshots
etcd appends all key changes to a log file.
This log grows forever and is a complete linear history of every change made to the keys.
A complete history works well for lightly used clusters but clusters that are heavily used would carry around a large log.
To avoid having a huge log etcd makes periodic snapshots.
These snapshots provide a way for etcd to compact the log by saving the current state of the system and removing old logs.
### Snapshot Tuning
Creating snapshots can be expensive so they're only created after a given number of changes to etcd.
By default, snapshots will be made after every 10,000 changes.
If etcd's memory usage and disk usage are too high, you can lower the snapshot threshold by setting the following on the command line:
```sh
# Command line arguments:
$ etcd -snapshot-count=5000
# Environment variables:
$ ETCD_SNAPSHOT_COUNT=5000 etcd
```

View File

@ -0,0 +1,112 @@
## Upgrade etcd to 2.1
In the general case, upgrading from etcd 2.0 to 2.1 can be a zero-downtime, rolling upgrade:
- one by one, stop the etcd v2.0 processes and replace them with etcd v2.1 processes
- after you are running all v2.1 processes, new features in v2.1 are available to the cluster
Before [starting an upgrade](#upgrade-procedure), read through the rest of this guide to prepare.
### Upgrade Checklists
#### Upgrade Requirement
To upgrade an existing etcd deployment to 2.1, you must be running 2.0. If youre running a version of etcd before 2.0, you must upgrade to [2.0](https://github.com/coreos/etcd/releases/tag/v2.0.13) before upgrading to 2.1.
Also, to ensure a smooth rolling upgrade, your running cluster must be healthy. You can check the health of the cluster by using `etcdctl cluster-health` command.
#### Preparedness
Before upgrading etcd, always test the services relying on etcd in a staging environment before deploying the upgrade to the production environment.
You might also want to [backup your data directory](admin_guide.md#backing-up-the-datastore) for a potential [downgrade](#downgrade).
etcd 2.1 introduces a new [authentication](auth_api.md) feature, which is disabled by default. If your deployment depends on these, you may want to test the auth features before enabling them in production.
#### Mixed Versions
While upgrading, an etcd cluster supports mixed versions of etcd members. The cluster is only considered upgraded once all its members are upgraded to 2.1.
Internally, etcd members negotiate with each other to determine the overall etcd cluster version, which controls the reported cluster version and the supported features. For example, if you are mid-upgrade, any 2.1 features (such as the the authentication feature mentioned above) wont be available.
#### Limitations
If you encounter any issues during the upgrade, you can attempt to restart the etcd process in trouble using a newer v2.1 binary to solve the problem. One known issue is that etcd v2.0.0 and v2.0.2 may panic during rolling upgrades due to an existing bug, which has been fixed since etcd v2.0.3.
It might take up to 2 minutes for the newly upgraded member to catch up with the existing cluster when the total data size is larger than 50MB (You can check the size of the existing snapshot to know about the rough data size). In other words, it is safest to wait for 2 minutes before upgrading the next member.
If you have even more data, this might take more time. If you have a data size larger than 100MB you should contact us before upgrading, so we can make sure the upgrades work smoothly.
#### Downgrade
If all members have been upgraded to v2.1, the cluster will be upgraded to v2.1, and downgrade is **not possible**. If any member is still v2.0, the cluster will remain in v2.0, and you can go back to use v2.0 binary.
Please [backup your data directory](admin_guide.md#backing-up-the-datastore) of all etcd members if you want to downgrade the cluster, even if it is upgraded.
### Upgrade Procedure
#### 1. Check upgrade requirements.
```
$ etcdctl cluster-health
cluster is healthy
member 6e3bd23ae5f1eae0 is healthy
member 924e2e83e93f2560 is healthy
member a8266ecf031671f3 is healthy
$ curl http://127.0.0.1:4001/version
etcd 2.0.x
```
#### 2. Stop the existing etcd process
You will see similar error logging from other etcd processes in your cluster. This is normal, since you just shut down a member.
```
2015/06/23 15:45:09 sender: error posting to 6e3bd23ae5f1eae0: dial tcp 127.0.0.1:7002: connection refused
2015/06/23 15:45:09 sender: the connection with 6e3bd23ae5f1eae0 became inactive
2015/06/23 15:45:11 rafthttp: encountered error writing to server log stream: write tcp 127.0.0.1:53783: broken pipe
2015/06/23 15:45:11 rafthttp: server streaming to 6e3bd23ae5f1eae0 at term 2 has been stopped
2015/06/23 15:45:11 stream: error sending message: stopped
2015/06/23 15:45:11 stream: stopping the stream server...
```
You could [backup your data directory](https://github.com/coreos/etcd/blob/7f7e2cc79d9c5c342a6eb1e48c386b0223cf934e/Documentation/admin_guide.md#backing-up-the-datastore) for data safety.
```
$ etcdctl backup \
--data-dir /var/lib/etcd \
--backup-dir /tmp/etcd_backup
```
#### 3. Drop-in etcd v2.1 binary and start the new etcd process
You will see the etcd publish its information to the cluster.
```
2015/06/23 15:45:39 etcdserver: published {Name:infra2 ClientURLs:[http://localhost:4002]} to cluster e9c7614f68f35fb2
```
You could verify the cluster becomes healthy.
```
$ etcdctl cluster-health
cluster is healthy
member 6e3bd23ae5f1eae0 is healthy
member 924e2e83e93f2560 is healthy
member a8266ecf031671f3 is healthy
```
#### 4. Repeat step 2 to step 3 for all other members
#### 5. Finish
When all members are upgraded, you will see the cluster is upgraded to 2.1 successfully:
```
2015/06/23 15:46:35 etcdserver: updated the cluster version from 2.0.0 to 2.1.0
```
```
$ curl http://127.0.0.1:4001/version
{"etcdserver":"2.1.x","etcdcluster":"2.1.0"}
```

View File

@ -0,0 +1,128 @@
## Upgrade etcd from 2.1 to 2.2
In the general case, upgrading from etcd 2.1 to 2.2 can be a zero-downtime, rolling upgrade:
- one by one, stop the etcd v2.1 processes and replace them with etcd v2.2 processes
- after you are running all v2.2 processes, new features in v2.2 are available to the cluster
Before [starting an upgrade](#upgrade-procedure), read through the rest of this guide to prepare.
### Upgrade Checklists
#### Upgrade Requirement
To upgrade an existing etcd deployment to 2.2, you must be running 2.1. If youre running a version of etcd before 2.1, you must upgrade to [2.1](https://github.com/coreos/etcd/releases/tag/v2.1.2) before upgrading to 2.2.
Also, to ensure a smooth rolling upgrade, your running cluster must be healthy. You can check the health of the cluster by using `etcdctl cluster-health` command.
#### Preparedness
Before upgrading etcd, always test the services relying on etcd in a staging environment before deploying the upgrade to the production environment.
You might also want to [backup your data directory](admin_guide.md#backing-up-the-datastore) for a potential [downgrade](#downgrade).
#### Mixed Versions
While upgrading, an etcd cluster supports mixed versions of etcd members. The cluster is only considered upgraded once all its members are upgraded to 2.2.
Internally, etcd members negotiate with each other to determine the overall etcd cluster version, which controls the reported cluster version and the supported features.
#### Limitations
If you have a data size larger than 100MB you should contact us before upgrading, so we can make sure the upgrades work smoothly.
Every etcd 2.2 member will do health checking across the cluster periodically. etcd 2.1 member does not support health checking. During the upgrade, etcd 2.2 member will log warning about the unhealthy state of etcd 2.1 member. You can ignore the warning.
#### Downgrade
If all members have been upgraded to v2.2, the cluster will be upgraded to v2.2, and downgrade is **not possible**. If any member is still v2.1, the cluster will remain in v2.1, and you can go back to use v2.1 binary.
Please [backup your data directory](admin_guide.md#backing-up-the-datastore) of all etcd members if you want to downgrade the cluster, even if it is upgraded.
### Upgrade Procedure
In the example, we upgrade a three member v2.1 cluster running on local machine.
#### 1. Check upgrade requirements.
```
$ etcdctl cluster-health
member 6e3bd23ae5f1eae0 is healthy: got healthy result from http://localhost:22379
member 924e2e83e93f2560 is healthy: got healthy result from http://localhost:32379
member a8266ecf031671f3 is healthy: got healthy result from http://localhost:12379
cluster is healthy
$ curl http://localhost:4001/version
{"etcdserver":"2.1.x","etcdcluster":"2.1.0"}
```
#### 2. Stop the existing etcd process
You will see similar error logging from other etcd processes in your cluster. This is normal, since you just shut down a member and the connection is broken.
```
2015/09/2 09:48:35 etcdserver: failed to reach the peerURL(http://localhost:12380) of member a8266ecf031671f3 (Get http://localhost:12380/version: dial tcp [::1]:12380: getsockopt: connection refused)
2015/09/2 09:48:35 etcdserver: cannot get the version of member a8266ecf031671f3 (Get http://localhost:12380/version: dial tcp [::1]:12380: getsockopt: connection refused)
2015/09/2 09:48:35 rafthttp: failed to write a8266ecf031671f3 on stream Message (write tcp 127.0.0.1:32380->127.0.0.1:64394: write: broken pipe)
2015/09/2 09:48:35 rafthttp: failed to write a8266ecf031671f3 on pipeline (dial tcp [::1]:12380: getsockopt: connection refused)
2015/09/2 09:48:40 etcdserver: failed to reach the peerURL(http://localhost:7001) of member a8266ecf031671f3 (Get http://localhost:7001/version: dial tcp [::1]:12380: getsockopt: connection refused)
2015/09/2 09:48:40 etcdserver: cannot get the version of member a8266ecf031671f3 (Get http://localhost:12380/version: dial tcp [::1]:12380: getsockopt: connection refused)
2015/09/2 09:48:40 rafthttp: failed to heartbeat a8266ecf031671f3 on stream MsgApp v2 (write tcp 127.0.0.1:32380->127.0.0.1:64393: write: broken pipe)
```
You will see logging output like this from ungraded member due to a mixed version cluster. You can ignore this while upgrading.
```
2015/09/2 09:48:45 etcdserver: the etcd version 2.1.2+git is not up-to-date
2015/09/2 09:48:45 etcdserver: member a8266ecf031671f3 has a higher version &{2.2.0-rc.0+git 2.1.0}
```
You will also see logging output like this from the newly upgraded member, since etcd 2.1 member does not support health checking. You can ignore this while upgrading.
```
2015-09-02 09:55:42.691384 W | rafthttp: the connection to peer 6e3bd23ae5f1eae0 is unhealthy
2015-09-02 09:55:42.705626 W | rafthttp: the connection to peer 924e2e83e93f2560 is unhealthy
```
You could [backup your data directory](https://github.com/coreos/etcd/blob/7f7e2cc79d9c5c342a6eb1e48c386b0223cf934e/Documentation/admin_guide.md#backing-up-the-datastore) for data safety.
```
$ etcdctl backup \
--data-dir /var/lib/etcd \
--backup-dir /tmp/etcd_backup
```
#### 3. Drop-in etcd v2.2 binary and start the new etcd process
Now, you can start the etcd v2.2 binary with the previous configuration.
You will see the etcd start and publish its information to the cluster.
```
2015-09-02 09:56:46.117609 I | etcdserver: published {Name:infra2 ClientURLs:[http://localhost:22380]} to cluster e9c7614f68f35fb2
```
You could verify the cluster becomes healthy.
```
$ etcdctl cluster-health
member 6e3bd23ae5f1eae0 is healthy: got healthy result from http://localhost:22379
member 924e2e83e93f2560 is healthy: got healthy result from http://localhost:32379
member a8266ecf031671f3 is healthy: got healthy result from http://localhost:12379
cluster is healthy
```
#### 4. Repeat step 2 to step 3 for all other members
#### 5. Finish
When all members are upgraded, you will see the cluster is upgraded to 2.2 successfully:
```
2015-09-02 09:56:54.896848 N | etcdserver: updated the cluster version from 2.1 to 2.2
```
```
$ curl http://127.0.0.1:4001/version
{"etcdserver":"2.2.x","etcdcluster":"2.2.0"}
```

153
Godeps/Godeps.json generated Normal file
View File

@ -0,0 +1,153 @@
{
"ImportPath": "github.com/coreos/etcd",
"GoVersion": "go1.4.2",
"Packages": [
"./..."
],
"Deps": [
{
"ImportPath": "bitbucket.org/ww/goautoneg",
"Comment": "null-5",
"Rev": "75cd24fc2f2c2a2088577d12123ddee5f54e0675"
},
{
"ImportPath": "github.com/beorn7/perks/quantile",
"Rev": "b965b613227fddccbfffe13eae360ed3fa822f8d"
},
{
"ImportPath": "github.com/bgentry/speakeasy",
"Rev": "36e9cfdd690967f4f690c6edcc9ffacd006014a0"
},
{
"ImportPath": "github.com/boltdb/bolt",
"Comment": "v1.0-119-g90fef38",
"Rev": "90fef389f98027ca55594edd7dbd6e7f3926fdad"
},
{
"ImportPath": "github.com/bradfitz/http2",
"Rev": "3e36af6d3af0e56fa3da71099f864933dea3d9fb"
},
{
"ImportPath": "github.com/codegangsta/cli",
"Comment": "1.2.0-26-gf7ebb76",
"Rev": "f7ebb761e83e21225d1d8954fde853bf8edd46c4"
},
{
"ImportPath": "github.com/coreos/go-semver/semver",
"Rev": "568e959cd89871e61434c1143528d9162da89ef2"
},
{
"ImportPath": "github.com/coreos/go-systemd/daemon",
"Comment": "v3-6-gcea488b",
"Rev": "cea488b4e6855fee89b6c22a811e3c5baca861b6"
},
{
"ImportPath": "github.com/coreos/go-systemd/journal",
"Comment": "v3-6-gcea488b",
"Rev": "cea488b4e6855fee89b6c22a811e3c5baca861b6"
},
{
"ImportPath": "github.com/coreos/go-systemd/util",
"Comment": "v3-6-gcea488b",
"Rev": "cea488b4e6855fee89b6c22a811e3c5baca861b6"
},
{
"ImportPath": "github.com/coreos/pkg/capnslog",
"Rev": "2c77715c4df99b5420ffcae14ead08f52104065d"
},
{
"ImportPath": "github.com/gogo/protobuf/proto",
"Rev": "64f27bf06efee53589314a6e5a4af34cdd85adf6"
},
{
"ImportPath": "github.com/golang/glog",
"Rev": "44145f04b68cf362d9c4df2182967c2275eaefed"
},
{
"ImportPath": "github.com/golang/protobuf/proto",
"Rev": "5677a0e3d5e89854c9974e1256839ee23f8233ca"
},
{
"ImportPath": "github.com/google/btree",
"Rev": "cc6329d4279e3f025a53a83c397d2339b5705c45"
},
{
"ImportPath": "github.com/jonboulle/clockwork",
"Rev": "72f9bd7c4e0c2a40055ab3d0f09654f730cce982"
},
{
"ImportPath": "github.com/matttproud/golang_protobuf_extensions/pbutil",
"Rev": "fc2b8d3a73c4867e51861bbdd5ae3c1f0869dd6a"
},
{
"ImportPath": "github.com/prometheus/client_golang/prometheus",
"Comment": "0.7.0-52-ge51041b",
"Rev": "e51041b3fa41cece0dca035740ba6411905be473"
},
{
"ImportPath": "github.com/prometheus/client_model/go",
"Comment": "model-0.0.2-12-gfa8ad6f",
"Rev": "fa8ad6fec33561be4280a8f0514318c79d7f6cb6"
},
{
"ImportPath": "github.com/prometheus/common/expfmt",
"Rev": "ffe929a3f4c4faeaa10f2b9535c2b1be3ad15650"
},
{
"ImportPath": "github.com/prometheus/common/model",
"Rev": "ffe929a3f4c4faeaa10f2b9535c2b1be3ad15650"
},
{
"ImportPath": "github.com/prometheus/procfs",
"Rev": "454a56f35412459b5e684fd5ec0f9211b94f002a"
},
{
"ImportPath": "github.com/rakyll/pb",
"Rev": "dc507ad06b7462501281bb4691ee43f0b1d1ec37"
},
{
"ImportPath": "github.com/stretchr/testify/assert",
"Rev": "9cc77fa25329013ce07362c7742952ff887361f2"
},
{
"ImportPath": "github.com/ugorji/go/codec",
"Rev": "f1f1a805ed361a0e078bb537e4ea78cd37dcf065"
},
{
"ImportPath": "github.com/xiang90/probing",
"Rev": "6a0cc1ae81b4cc11db5e491e030e4b98fba79c19"
},
{
"ImportPath": "golang.org/x/crypto/bcrypt",
"Rev": "1351f936d976c60a0a48d728281922cf63eafb8d"
},
{
"ImportPath": "golang.org/x/crypto/blowfish",
"Rev": "1351f936d976c60a0a48d728281922cf63eafb8d"
},
{
"ImportPath": "golang.org/x/net/context",
"Rev": "7dbad50ab5b31073856416cdcfeb2796d682f844"
},
{
"ImportPath": "golang.org/x/oauth2",
"Rev": "3046bc76d6dfd7d3707f6640f85e42d9c4050f50"
},
{
"ImportPath": "golang.org/x/sys/unix",
"Rev": "9c60d1c508f5134d1ca726b4641db998f2523357"
},
{
"ImportPath": "google.golang.org/cloud/compute/metadata",
"Rev": "f20d6dcccb44ed49de45ae3703312cb46e627db1"
},
{
"ImportPath": "google.golang.org/cloud/internal",
"Rev": "f20d6dcccb44ed49de45ae3703312cb46e627db1"
},
{
"ImportPath": "google.golang.org/grpc",
"Rev": "f5ebd86be717593ab029545492c93ddf8914832b"
}
]
}

5
Godeps/Readme generated Normal file
View File

@ -0,0 +1,5 @@
This directory tree is generated automatically by godep.
Please do not edit.
See https://github.com/tools/godep for more information.

2
Godeps/_workspace/.gitignore generated vendored Normal file
View File

@ -0,0 +1,2 @@
/pkg
/bin

View File

@ -0,0 +1,13 @@
include $(GOROOT)/src/Make.inc
TARG=bitbucket.org/ww/goautoneg
GOFILES=autoneg.go
include $(GOROOT)/src/Make.pkg
format:
gofmt -w *.go
docs:
gomake clean
godoc ${TARG} > README.txt

View File

@ -0,0 +1,67 @@
PACKAGE
package goautoneg
import "bitbucket.org/ww/goautoneg"
HTTP Content-Type Autonegotiation.
The functions in this package implement the behaviour specified in
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
Copyright (c) 2011, Open Knowledge Foundation Ltd.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
Neither the name of the Open Knowledge Foundation Ltd. nor the
names of its contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
FUNCTIONS
func Negotiate(header string, alternatives []string) (content_type string)
Negotiate the most appropriate content_type given the accept header
and a list of alternatives.
func ParseAccept(header string) (accept []Accept)
Parse an Accept Header string returning a sorted list
of clauses
TYPES
type Accept struct {
Type, SubType string
Q float32
Params map[string]string
}
Structure to represent a clause in an HTTP Accept Header
SUBDIRECTORIES
.hg

View File

@ -0,0 +1,162 @@
/*
HTTP Content-Type Autonegotiation.
The functions in this package implement the behaviour specified in
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
Copyright (c) 2011, Open Knowledge Foundation Ltd.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
Neither the name of the Open Knowledge Foundation Ltd. nor the
names of its contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package goautoneg
import (
"sort"
"strconv"
"strings"
)
// Structure to represent a clause in an HTTP Accept Header
type Accept struct {
Type, SubType string
Q float64
Params map[string]string
}
// For internal use, so that we can use the sort interface
type accept_slice []Accept
func (accept accept_slice) Len() int {
slice := []Accept(accept)
return len(slice)
}
func (accept accept_slice) Less(i, j int) bool {
slice := []Accept(accept)
ai, aj := slice[i], slice[j]
if ai.Q > aj.Q {
return true
}
if ai.Type != "*" && aj.Type == "*" {
return true
}
if ai.SubType != "*" && aj.SubType == "*" {
return true
}
return false
}
func (accept accept_slice) Swap(i, j int) {
slice := []Accept(accept)
slice[i], slice[j] = slice[j], slice[i]
}
// Parse an Accept Header string returning a sorted list
// of clauses
func ParseAccept(header string) (accept []Accept) {
parts := strings.Split(header, ",")
accept = make([]Accept, 0, len(parts))
for _, part := range parts {
part := strings.Trim(part, " ")
a := Accept{}
a.Params = make(map[string]string)
a.Q = 1.0
mrp := strings.Split(part, ";")
media_range := mrp[0]
sp := strings.Split(media_range, "/")
a.Type = strings.Trim(sp[0], " ")
switch {
case len(sp) == 1 && a.Type == "*":
a.SubType = "*"
case len(sp) == 2:
a.SubType = strings.Trim(sp[1], " ")
default:
continue
}
if len(mrp) == 1 {
accept = append(accept, a)
continue
}
for _, param := range mrp[1:] {
sp := strings.SplitN(param, "=", 2)
if len(sp) != 2 {
continue
}
token := strings.Trim(sp[0], " ")
if token == "q" {
a.Q, _ = strconv.ParseFloat(sp[1], 32)
} else {
a.Params[token] = strings.Trim(sp[1], " ")
}
}
accept = append(accept, a)
}
slice := accept_slice(accept)
sort.Sort(slice)
return
}
// Negotiate the most appropriate content_type given the accept header
// and a list of alternatives.
func Negotiate(header string, alternatives []string) (content_type string) {
asp := make([][]string, 0, len(alternatives))
for _, ctype := range alternatives {
asp = append(asp, strings.SplitN(ctype, "/", 2))
}
for _, clause := range ParseAccept(header) {
for i, ctsp := range asp {
if clause.Type == ctsp[0] && clause.SubType == ctsp[1] {
content_type = alternatives[i]
return
}
if clause.Type == ctsp[0] && clause.SubType == "*" {
content_type = alternatives[i]
return
}
if clause.Type == "*" && clause.SubType == "*" {
content_type = alternatives[i]
return
}
}
}
return
}

View File

@ -0,0 +1,33 @@
package goautoneg
import (
"testing"
)
var chrome = "application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"
func TestParseAccept(t *testing.T) {
alternatives := []string{"text/html", "image/png"}
content_type := Negotiate(chrome, alternatives)
if content_type != "image/png" {
t.Errorf("got %s expected image/png", content_type)
}
alternatives = []string{"text/html", "text/plain", "text/n3"}
content_type = Negotiate(chrome, alternatives)
if content_type != "text/html" {
t.Errorf("got %s expected text/html", content_type)
}
alternatives = []string{"text/n3", "text/plain"}
content_type = Negotiate(chrome, alternatives)
if content_type != "text/plain" {
t.Errorf("got %s expected text/plain", content_type)
}
alternatives = []string{"text/n3", "application/rdf+xml"}
content_type = Negotiate(chrome, alternatives)
if content_type != "text/n3" {
t.Errorf("got %s expected text/n3", content_type)
}
}

View File

@ -0,0 +1,63 @@
package quantile
import (
"testing"
)
func BenchmarkInsertTargeted(b *testing.B) {
b.ReportAllocs()
s := NewTargeted(Targets)
b.ResetTimer()
for i := float64(0); i < float64(b.N); i++ {
s.Insert(i)
}
}
func BenchmarkInsertTargetedSmallEpsilon(b *testing.B) {
s := NewTargeted(TargetsSmallEpsilon)
b.ResetTimer()
for i := float64(0); i < float64(b.N); i++ {
s.Insert(i)
}
}
func BenchmarkInsertBiased(b *testing.B) {
s := NewLowBiased(0.01)
b.ResetTimer()
for i := float64(0); i < float64(b.N); i++ {
s.Insert(i)
}
}
func BenchmarkInsertBiasedSmallEpsilon(b *testing.B) {
s := NewLowBiased(0.0001)
b.ResetTimer()
for i := float64(0); i < float64(b.N); i++ {
s.Insert(i)
}
}
func BenchmarkQuery(b *testing.B) {
s := NewTargeted(Targets)
for i := float64(0); i < 1e6; i++ {
s.Insert(i)
}
b.ResetTimer()
n := float64(b.N)
for i := float64(0); i < n; i++ {
s.Query(i / n)
}
}
func BenchmarkQuerySmallEpsilon(b *testing.B) {
s := NewTargeted(TargetsSmallEpsilon)
for i := float64(0); i < 1e6; i++ {
s.Insert(i)
}
b.ResetTimer()
n := float64(b.N)
for i := float64(0); i < n; i++ {
s.Query(i / n)
}
}

View File

@ -0,0 +1,121 @@
// +build go1.1
package quantile_test
import (
"bufio"
"fmt"
"log"
"os"
"strconv"
"time"
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/beorn7/perks/quantile"
)
func Example_simple() {
ch := make(chan float64)
go sendFloats(ch)
// Compute the 50th, 90th, and 99th percentile.
q := quantile.NewTargeted(map[float64]float64{
0.50: 0.005,
0.90: 0.001,
0.99: 0.0001,
})
for v := range ch {
q.Insert(v)
}
fmt.Println("perc50:", q.Query(0.50))
fmt.Println("perc90:", q.Query(0.90))
fmt.Println("perc99:", q.Query(0.99))
fmt.Println("count:", q.Count())
// Output:
// perc50: 5
// perc90: 16
// perc99: 223
// count: 2388
}
func Example_mergeMultipleStreams() {
// Scenario:
// We have multiple database shards. On each shard, there is a process
// collecting query response times from the database logs and inserting
// them into a Stream (created via NewTargeted(0.90)), much like the
// Simple example. These processes expose a network interface for us to
// ask them to serialize and send us the results of their
// Stream.Samples so we may Merge and Query them.
//
// NOTES:
// * These sample sets are small, allowing us to get them
// across the network much faster than sending the entire list of data
// points.
//
// * For this to work correctly, we must supply the same quantiles
// a priori the process collecting the samples supplied to NewTargeted,
// even if we do not plan to query them all here.
ch := make(chan quantile.Samples)
getDBQuerySamples(ch)
q := quantile.NewTargeted(map[float64]float64{0.90: 0.001})
for samples := range ch {
q.Merge(samples)
}
fmt.Println("perc90:", q.Query(0.90))
}
func Example_window() {
// Scenario: We want the 90th, 95th, and 99th percentiles for each
// minute.
ch := make(chan float64)
go sendStreamValues(ch)
tick := time.NewTicker(1 * time.Minute)
q := quantile.NewTargeted(map[float64]float64{
0.90: 0.001,
0.95: 0.0005,
0.99: 0.0001,
})
for {
select {
case t := <-tick.C:
flushToDB(t, q.Samples())
q.Reset()
case v := <-ch:
q.Insert(v)
}
}
}
func sendStreamValues(ch chan float64) {
// Use your imagination
}
func flushToDB(t time.Time, samples quantile.Samples) {
// Use your imagination
}
// This is a stub for the above example. In reality this would hit the remote
// servers via http or something like it.
func getDBQuerySamples(ch chan quantile.Samples) {}
func sendFloats(ch chan<- float64) {
f, err := os.Open("exampledata.txt")
if err != nil {
log.Fatal(err)
}
sc := bufio.NewScanner(f)
for sc.Scan() {
b := sc.Bytes()
v, err := strconv.ParseFloat(string(b), 64)
if err != nil {
log.Fatal(err)
}
ch <- v
}
if sc.Err() != nil {
log.Fatal(sc.Err())
}
close(ch)
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,292 @@
// Package quantile computes approximate quantiles over an unbounded data
// stream within low memory and CPU bounds.
//
// A small amount of accuracy is traded to achieve the above properties.
//
// Multiple streams can be merged before calling Query to generate a single set
// of results. This is meaningful when the streams represent the same type of
// data. See Merge and Samples.
//
// For more detailed information about the algorithm used, see:
//
// Effective Computation of Biased Quantiles over Data Streams
//
// http://www.cs.rutgers.edu/~muthu/bquant.pdf
package quantile
import (
"math"
"sort"
)
// Sample holds an observed value and meta information for compression. JSON
// tags have been added for convenience.
type Sample struct {
Value float64 `json:",string"`
Width float64 `json:",string"`
Delta float64 `json:",string"`
}
// Samples represents a slice of samples. It implements sort.Interface.
type Samples []Sample
func (a Samples) Len() int { return len(a) }
func (a Samples) Less(i, j int) bool { return a[i].Value < a[j].Value }
func (a Samples) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
type invariant func(s *stream, r float64) float64
// NewLowBiased returns an initialized Stream for low-biased quantiles
// (e.g. 0.01, 0.1, 0.5) where the needed quantiles are not known a priori, but
// error guarantees can still be given even for the lower ranks of the data
// distribution.
//
// The provided epsilon is a relative error, i.e. the true quantile of a value
// returned by a query is guaranteed to be within (1±Epsilon)*Quantile.
//
// See http://www.cs.rutgers.edu/~muthu/bquant.pdf for time, space, and error
// properties.
func NewLowBiased(epsilon float64) *Stream {
ƒ := func(s *stream, r float64) float64 {
return 2 * epsilon * r
}
return newStream(ƒ)
}
// NewHighBiased returns an initialized Stream for high-biased quantiles
// (e.g. 0.01, 0.1, 0.5) where the needed quantiles are not known a priori, but
// error guarantees can still be given even for the higher ranks of the data
// distribution.
//
// The provided epsilon is a relative error, i.e. the true quantile of a value
// returned by a query is guaranteed to be within 1-(1±Epsilon)*(1-Quantile).
//
// See http://www.cs.rutgers.edu/~muthu/bquant.pdf for time, space, and error
// properties.
func NewHighBiased(epsilon float64) *Stream {
ƒ := func(s *stream, r float64) float64 {
return 2 * epsilon * (s.n - r)
}
return newStream(ƒ)
}
// NewTargeted returns an initialized Stream concerned with a particular set of
// quantile values that are supplied a priori. Knowing these a priori reduces
// space and computation time. The targets map maps the desired quantiles to
// their absolute errors, i.e. the true quantile of a value returned by a query
// is guaranteed to be within (Quantile±Epsilon).
//
// See http://www.cs.rutgers.edu/~muthu/bquant.pdf for time, space, and error properties.
func NewTargeted(targets map[float64]float64) *Stream {
ƒ := func(s *stream, r float64) float64 {
var m = math.MaxFloat64
var f float64
for quantile, epsilon := range targets {
if quantile*s.n <= r {
f = (2 * epsilon * r) / quantile
} else {
f = (2 * epsilon * (s.n - r)) / (1 - quantile)
}
if f < m {
m = f
}
}
return m
}
return newStream(ƒ)
}
// Stream computes quantiles for a stream of float64s. It is not thread-safe by
// design. Take care when using across multiple goroutines.
type Stream struct {
*stream
b Samples
sorted bool
}
func newStream(ƒ invariant) *Stream {
x := &stream{ƒ: ƒ}
return &Stream{x, make(Samples, 0, 500), true}
}
// Insert inserts v into the stream.
func (s *Stream) Insert(v float64) {
s.insert(Sample{Value: v, Width: 1})
}
func (s *Stream) insert(sample Sample) {
s.b = append(s.b, sample)
s.sorted = false
if len(s.b) == cap(s.b) {
s.flush()
}
}
// Query returns the computed qth percentiles value. If s was created with
// NewTargeted, and q is not in the set of quantiles provided a priori, Query
// will return an unspecified result.
func (s *Stream) Query(q float64) float64 {
if !s.flushed() {
// Fast path when there hasn't been enough data for a flush;
// this also yields better accuracy for small sets of data.
l := len(s.b)
if l == 0 {
return 0
}
i := int(float64(l) * q)
if i > 0 {
i -= 1
}
s.maybeSort()
return s.b[i].Value
}
s.flush()
return s.stream.query(q)
}
// Merge merges samples into the underlying streams samples. This is handy when
// merging multiple streams from separate threads, database shards, etc.
//
// ATTENTION: This method is broken and does not yield correct results. The
// underlying algorithm is not capable of merging streams correctly.
func (s *Stream) Merge(samples Samples) {
sort.Sort(samples)
s.stream.merge(samples)
}
// Reset reinitializes and clears the list reusing the samples buffer memory.
func (s *Stream) Reset() {
s.stream.reset()
s.b = s.b[:0]
}
// Samples returns stream samples held by s.
func (s *Stream) Samples() Samples {
if !s.flushed() {
return s.b
}
s.flush()
return s.stream.samples()
}
// Count returns the total number of samples observed in the stream
// since initialization.
func (s *Stream) Count() int {
return len(s.b) + s.stream.count()
}
func (s *Stream) flush() {
s.maybeSort()
s.stream.merge(s.b)
s.b = s.b[:0]
}
func (s *Stream) maybeSort() {
if !s.sorted {
s.sorted = true
sort.Sort(s.b)
}
}
func (s *Stream) flushed() bool {
return len(s.stream.l) > 0
}
type stream struct {
n float64
l []Sample
ƒ invariant
}
func (s *stream) reset() {
s.l = s.l[:0]
s.n = 0
}
func (s *stream) insert(v float64) {
s.merge(Samples{{v, 1, 0}})
}
func (s *stream) merge(samples Samples) {
// TODO(beorn7): This tries to merge not only individual samples, but
// whole summaries. The paper doesn't mention merging summaries at
// all. Unittests show that the merging is inaccurate. Find out how to
// do merges properly.
var r float64
i := 0
for _, sample := range samples {
for ; i < len(s.l); i++ {
c := s.l[i]
if c.Value > sample.Value {
// Insert at position i.
s.l = append(s.l, Sample{})
copy(s.l[i+1:], s.l[i:])
s.l[i] = Sample{
sample.Value,
sample.Width,
math.Max(sample.Delta, math.Floor(s.ƒ(s, r))-1),
// TODO(beorn7): How to calculate delta correctly?
}
i++
goto inserted
}
r += c.Width
}
s.l = append(s.l, Sample{sample.Value, sample.Width, 0})
i++
inserted:
s.n += sample.Width
r += sample.Width
}
s.compress()
}
func (s *stream) count() int {
return int(s.n)
}
func (s *stream) query(q float64) float64 {
t := math.Ceil(q * s.n)
t += math.Ceil(s.ƒ(s, t) / 2)
p := s.l[0]
var r float64
for _, c := range s.l[1:] {
r += p.Width
if r+c.Width+c.Delta > t {
return p.Value
}
p = c
}
return p.Value
}
func (s *stream) compress() {
if len(s.l) < 2 {
return
}
x := s.l[len(s.l)-1]
xi := len(s.l) - 1
r := s.n - 1 - x.Width
for i := len(s.l) - 2; i >= 0; i-- {
c := s.l[i]
if c.Width+x.Width+x.Delta <= s.ƒ(s, r) {
x.Width += c.Width
s.l[xi] = x
// Remove element at i.
copy(s.l[i:], s.l[i+1:])
s.l = s.l[:len(s.l)-1]
xi -= 1
} else {
x = c
xi = i
}
r -= c.Width
}
}
func (s *stream) samples() Samples {
samples := make(Samples, len(s.l))
copy(samples, s.l)
return samples
}

View File

@ -0,0 +1,188 @@
package quantile
import (
"math"
"math/rand"
"sort"
"testing"
)
var (
Targets = map[float64]float64{
0.01: 0.001,
0.10: 0.01,
0.50: 0.05,
0.90: 0.01,
0.99: 0.001,
}
TargetsSmallEpsilon = map[float64]float64{
0.01: 0.0001,
0.10: 0.001,
0.50: 0.005,
0.90: 0.001,
0.99: 0.0001,
}
LowQuantiles = []float64{0.01, 0.1, 0.5}
HighQuantiles = []float64{0.99, 0.9, 0.5}
)
const RelativeEpsilon = 0.01
func verifyPercsWithAbsoluteEpsilon(t *testing.T, a []float64, s *Stream) {
sort.Float64s(a)
for quantile, epsilon := range Targets {
n := float64(len(a))
k := int(quantile * n)
lower := int((quantile - epsilon) * n)
if lower < 1 {
lower = 1
}
upper := int(math.Ceil((quantile + epsilon) * n))
if upper > len(a) {
upper = len(a)
}
w, min, max := a[k-1], a[lower-1], a[upper-1]
if g := s.Query(quantile); g < min || g > max {
t.Errorf("q=%f: want %v [%f,%f], got %v", quantile, w, min, max, g)
}
}
}
func verifyLowPercsWithRelativeEpsilon(t *testing.T, a []float64, s *Stream) {
sort.Float64s(a)
for _, qu := range LowQuantiles {
n := float64(len(a))
k := int(qu * n)
lowerRank := int((1 - RelativeEpsilon) * qu * n)
upperRank := int(math.Ceil((1 + RelativeEpsilon) * qu * n))
w, min, max := a[k-1], a[lowerRank-1], a[upperRank-1]
if g := s.Query(qu); g < min || g > max {
t.Errorf("q=%f: want %v [%f,%f], got %v", qu, w, min, max, g)
}
}
}
func verifyHighPercsWithRelativeEpsilon(t *testing.T, a []float64, s *Stream) {
sort.Float64s(a)
for _, qu := range HighQuantiles {
n := float64(len(a))
k := int(qu * n)
lowerRank := int((1 - (1+RelativeEpsilon)*(1-qu)) * n)
upperRank := int(math.Ceil((1 - (1-RelativeEpsilon)*(1-qu)) * n))
w, min, max := a[k-1], a[lowerRank-1], a[upperRank-1]
if g := s.Query(qu); g < min || g > max {
t.Errorf("q=%f: want %v [%f,%f], got %v", qu, w, min, max, g)
}
}
}
func populateStream(s *Stream) []float64 {
a := make([]float64, 0, 1e5+100)
for i := 0; i < cap(a); i++ {
v := rand.NormFloat64()
// Add 5% asymmetric outliers.
if i%20 == 0 {
v = v*v + 1
}
s.Insert(v)
a = append(a, v)
}
return a
}
func TestTargetedQuery(t *testing.T) {
rand.Seed(42)
s := NewTargeted(Targets)
a := populateStream(s)
verifyPercsWithAbsoluteEpsilon(t, a, s)
}
func TestLowBiasedQuery(t *testing.T) {
rand.Seed(42)
s := NewLowBiased(RelativeEpsilon)
a := populateStream(s)
verifyLowPercsWithRelativeEpsilon(t, a, s)
}
func TestHighBiasedQuery(t *testing.T) {
rand.Seed(42)
s := NewHighBiased(RelativeEpsilon)
a := populateStream(s)
verifyHighPercsWithRelativeEpsilon(t, a, s)
}
// BrokenTestTargetedMerge is broken, see Merge doc comment.
func BrokenTestTargetedMerge(t *testing.T) {
rand.Seed(42)
s1 := NewTargeted(Targets)
s2 := NewTargeted(Targets)
a := populateStream(s1)
a = append(a, populateStream(s2)...)
s1.Merge(s2.Samples())
verifyPercsWithAbsoluteEpsilon(t, a, s1)
}
// BrokenTestLowBiasedMerge is broken, see Merge doc comment.
func BrokenTestLowBiasedMerge(t *testing.T) {
rand.Seed(42)
s1 := NewLowBiased(RelativeEpsilon)
s2 := NewLowBiased(RelativeEpsilon)
a := populateStream(s1)
a = append(a, populateStream(s2)...)
s1.Merge(s2.Samples())
verifyLowPercsWithRelativeEpsilon(t, a, s2)
}
// BrokenTestHighBiasedMerge is broken, see Merge doc comment.
func BrokenTestHighBiasedMerge(t *testing.T) {
rand.Seed(42)
s1 := NewHighBiased(RelativeEpsilon)
s2 := NewHighBiased(RelativeEpsilon)
a := populateStream(s1)
a = append(a, populateStream(s2)...)
s1.Merge(s2.Samples())
verifyHighPercsWithRelativeEpsilon(t, a, s2)
}
func TestUncompressed(t *testing.T) {
q := NewTargeted(Targets)
for i := 100; i > 0; i-- {
q.Insert(float64(i))
}
if g := q.Count(); g != 100 {
t.Errorf("want count 100, got %d", g)
}
// Before compression, Query should have 100% accuracy.
for quantile := range Targets {
w := quantile * 100
if g := q.Query(quantile); g != w {
t.Errorf("want %f, got %f", w, g)
}
}
}
func TestUncompressedSamples(t *testing.T) {
q := NewTargeted(map[float64]float64{0.99: 0.001})
for i := 1; i <= 100; i++ {
q.Insert(float64(i))
}
if g := q.Samples().Len(); g != 100 {
t.Errorf("want count 100, got %d", g)
}
}
func TestUncompressedOne(t *testing.T) {
q := NewTargeted(map[float64]float64{0.99: 0.01})
q.Insert(3.14)
if g := q.Query(0.90); g != 3.14 {
t.Error("want PI, got", g)
}
}
func TestDefaults(t *testing.T) {
if g := NewTargeted(map[float64]float64{0.99: 0.001}).Query(0.99); g != 0 {
t.Errorf("want 0, got %f", g)
}
}

View File

@ -0,0 +1,2 @@
example/example
example/example.exe

View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [2013] [the CloudFoundry Authors]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -0,0 +1,30 @@
# Speakeasy
This package provides cross-platform Go (#golang) helpers for taking user input
from the terminal while not echoing the input back (similar to `getpasswd`). The
package uses syscalls to avoid any dependence on cgo, and is therefore
compatible with cross-compiling.
[![GoDoc](https://godoc.org/github.com/bgentry/speakeasy?status.png)][godoc]
## Unicode
Multi-byte unicode characters work successfully on Mac OS X. On Windows,
however, this may be problematic (as is UTF in general on Windows). Other
platforms have not been tested.
## License
The code herein was not written by me, but was compiled from two separate open
source packages. Unix portions were imported from [gopass][gopass], while
Windows portions were imported from the [CloudFoundry Go CLI][cf-cli]'s
[Windows terminal helpers][cf-ui-windows].
The [license for the windows portion](./LICENSE_WINDOWS) has been copied exactly
from the source (though I attempted to fill in the correct owner in the
boilerplate copyright notice).
[cf-cli]: https://github.com/cloudfoundry/cli "CloudFoundry Go CLI"
[cf-ui-windows]: https://github.com/cloudfoundry/cli/blob/master/src/cf/terminal/ui_windows.go "CloudFoundry Go CLI Windows input helpers"
[godoc]: https://godoc.org/github.com/bgentry/speakeasy "speakeasy on Godoc.org"
[gopass]: https://code.google.com/p/gopass "gopass"

View File

@ -0,0 +1,18 @@
package main
import (
"fmt"
"os"
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/bgentry/speakeasy"
)
func main() {
password, err := speakeasy.Ask("Please enter a password: ")
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Printf("Password result: %q\n", password)
fmt.Printf("Password len: %d\n", len(password))
}

View File

@ -0,0 +1,47 @@
package speakeasy
import (
"fmt"
"io"
"os"
"strings"
)
// Ask the user to enter a password with input hidden. prompt is a string to
// display before the user's input. Returns the provided password, or an error
// if the command failed.
func Ask(prompt string) (password string, err error) {
return FAsk(os.Stdout, prompt)
}
// Same as the Ask function, except it is possible to specify the file to write
// the prompt to.
func FAsk(file *os.File, prompt string) (password string, err error) {
if prompt != "" {
fmt.Fprint(file, prompt) // Display the prompt.
}
password, err = getPassword()
// Carriage return after the user input.
fmt.Fprintln(file, "")
return
}
func readline() (value string, err error) {
var valb []byte
var n int
b := make([]byte, 1)
for {
// read one byte at a time so we don't accidentally read extra bytes
n, err = os.Stdin.Read(b)
if err != nil && err != io.EOF {
return "", err
}
if n == 0 || b[0] == '\n' {
break
}
valb = append(valb, b[0])
}
return strings.TrimSuffix(string(valb), "\r"), nil
}

View File

@ -0,0 +1,93 @@
// based on https://code.google.com/p/gopass
// Author: johnsiilver@gmail.com (John Doak)
//
// Original code is based on code by RogerV in the golang-nuts thread:
// https://groups.google.com/group/golang-nuts/browse_thread/thread/40cc41e9d9fc9247
// +build darwin freebsd linux netbsd openbsd solaris
package speakeasy
import (
"fmt"
"os"
"os/signal"
"strings"
"syscall"
)
const sttyArg0 = "/bin/stty"
var (
sttyArgvEOff = []string{"stty", "-echo"}
sttyArgvEOn = []string{"stty", "echo"}
)
// getPassword gets input hidden from the terminal from a user. This is
// accomplished by turning off terminal echo, reading input from the user and
// finally turning on terminal echo.
func getPassword() (password string, err error) {
sig := make(chan os.Signal, 10)
brk := make(chan bool)
// File descriptors for stdin, stdout, and stderr.
fd := []uintptr{os.Stdin.Fd(), os.Stdout.Fd(), os.Stderr.Fd()}
// Setup notifications of termination signals to channel sig, create a process to
// watch for these signals so we can turn back on echo if need be.
signal.Notify(sig, syscall.SIGHUP, syscall.SIGINT, syscall.SIGKILL, syscall.SIGQUIT,
syscall.SIGTERM)
go catchSignal(fd, sig, brk)
// Turn off the terminal echo.
pid, err := echoOff(fd)
if err != nil {
return "", err
}
// Turn on the terminal echo and stop listening for signals.
defer signal.Stop(sig)
defer close(brk)
defer echoOn(fd)
syscall.Wait4(pid, nil, 0, nil)
line, err := readline()
if err == nil {
password = strings.TrimSpace(line)
} else {
err = fmt.Errorf("failed during password entry: %s", err)
}
return password, err
}
// echoOff turns off the terminal echo.
func echoOff(fd []uintptr) (int, error) {
pid, err := syscall.ForkExec(sttyArg0, sttyArgvEOff, &syscall.ProcAttr{Dir: "", Files: fd})
if err != nil {
return 0, fmt.Errorf("failed turning off console echo for password entry:\n\t%s", err)
}
return pid, nil
}
// echoOn turns back on the terminal echo.
func echoOn(fd []uintptr) {
// Turn on the terminal echo.
pid, e := syscall.ForkExec(sttyArg0, sttyArgvEOn, &syscall.ProcAttr{Dir: "", Files: fd})
if e == nil {
syscall.Wait4(pid, nil, 0, nil)
}
}
// catchSignal tries to catch SIGKILL, SIGQUIT and SIGINT so that we can turn
// terminal echo back on before the program ends. Otherwise the user is left
// with echo off on their terminal.
func catchSignal(fd []uintptr, sig chan os.Signal, brk chan bool) {
select {
case <-sig:
echoOn(fd)
os.Exit(-1)
case <-brk:
}
}

View File

@ -0,0 +1,43 @@
// +build windows
package speakeasy
import (
"os"
"syscall"
)
// SetConsoleMode function can be used to change value of ENABLE_ECHO_INPUT:
// http://msdn.microsoft.com/en-us/library/windows/desktop/ms686033(v=vs.85).aspx
const ENABLE_ECHO_INPUT = 0x0004
func getPassword() (password string, err error) {
hStdin := syscall.Handle(os.Stdin.Fd())
var oldMode uint32
err = syscall.GetConsoleMode(hStdin, &oldMode)
if err != nil {
return
}
var newMode uint32 = (oldMode &^ ENABLE_ECHO_INPUT)
err = setConsoleMode(hStdin, newMode)
defer setConsoleMode(hStdin, oldMode)
if err != nil {
return
}
return readline()
}
func setConsoleMode(console syscall.Handle, mode uint32) (err error) {
dll := syscall.MustLoadDLL("kernel32")
proc := dll.MustFindProc("SetConsoleMode")
r, _, err := proc.Call(uintptr(console), uintptr(mode))
if r == 0 {
return err
}
return nil
}

View File

@ -0,0 +1,4 @@
*.prof
*.test
*.swp
/bin/

20
Godeps/_workspace/src/github.com/boltdb/bolt/LICENSE generated vendored Normal file
View File

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2013 Ben Johnson
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

54
Godeps/_workspace/src/github.com/boltdb/bolt/Makefile generated vendored Normal file
View File

@ -0,0 +1,54 @@
TEST=.
BENCH=.
COVERPROFILE=/tmp/c.out
BRANCH=`git rev-parse --abbrev-ref HEAD`
COMMIT=`git rev-parse --short HEAD`
GOLDFLAGS="-X main.branch $(BRANCH) -X main.commit $(COMMIT)"
default: build
bench:
go test -v -test.run=NOTHINCONTAINSTHIS -test.bench=$(BENCH)
# http://cloc.sourceforge.net/
cloc:
@cloc --not-match-f='Makefile|_test.go' .
cover: fmt
go test -coverprofile=$(COVERPROFILE) -test.run=$(TEST) $(COVERFLAG) .
go tool cover -html=$(COVERPROFILE)
rm $(COVERPROFILE)
cpuprofile: fmt
@go test -c
@./bolt.test -test.v -test.run=$(TEST) -test.cpuprofile cpu.prof
# go get github.com/kisielk/errcheck
errcheck:
@echo "=== errcheck ==="
@errcheck github.com/boltdb/bolt
fmt:
@go fmt ./...
get:
@go get -d ./...
build: get
@mkdir -p bin
@go build -ldflags=$(GOLDFLAGS) -a -o bin/bolt ./cmd/bolt
test: fmt
@go get github.com/stretchr/testify/assert
@echo "=== TESTS ==="
@go test -v -cover -test.run=$(TEST)
@echo ""
@echo ""
@echo "=== CLI ==="
@go test -v -test.run=$(TEST) ./cmd/bolt
@echo ""
@echo ""
@echo "=== RACE DETECTOR ==="
@go test -v -race -test.run="TestSimulate_(100op|1000op)"
.PHONY: bench cloc cover cpuprofile fmt memprofile test

621
Godeps/_workspace/src/github.com/boltdb/bolt/README.md generated vendored Normal file
View File

@ -0,0 +1,621 @@
Bolt [![Build Status](https://drone.io/github.com/boltdb/bolt/status.png)](https://drone.io/github.com/boltdb/bolt/latest) [![Coverage Status](https://coveralls.io/repos/boltdb/bolt/badge.png?branch=master)](https://coveralls.io/r/boltdb/bolt?branch=master) [![GoDoc](https://godoc.org/github.com/boltdb/bolt?status.png)](https://godoc.org/github.com/boltdb/bolt) ![Version](http://img.shields.io/badge/version-1.0-green.png)
====
Bolt is a pure Go key/value store inspired by [Howard Chu's][hyc_symas] and
the [LMDB project][lmdb]. The goal of the project is to provide a simple,
fast, and reliable database for projects that don't require a full database
server such as Postgres or MySQL.
Since Bolt is meant to be used as such a low-level piece of functionality,
simplicity is key. The API will be small and only focus on getting values
and setting values. That's it.
[hyc_symas]: https://twitter.com/hyc_symas
[lmdb]: http://symas.com/mdb/
## Project Status
Bolt is stable and the API is fixed. Full unit test coverage and randomized
black box testing are used to ensure database consistency and thread safety.
Bolt is currently in high-load production environments serving databases as
large as 1TB. Many companies such as Shopify and Heroku use Bolt-backed
services every day.
## Getting Started
### Installing
To start using Bolt, install Go and run `go get`:
```sh
$ go get github.com/boltdb/bolt/...
```
This will retrieve the library and install the `bolt` command line utility into
your `$GOBIN` path.
### Opening a database
The top-level object in Bolt is a `DB`. It is represented as a single file on
your disk and represents a consistent snapshot of your data.
To open your database, simply use the `bolt.Open()` function:
```go
package main
import (
"log"
"github.com/boltdb/bolt"
)
func main() {
// Open the my.db data file in your current directory.
// It will be created if it doesn't exist.
db, err := bolt.Open("my.db", 0600, nil)
if err != nil {
log.Fatal(err)
}
defer db.Close()
...
}
```
Please note that Bolt obtains a file lock on the data file so multiple processes
cannot open the same database at the same time. Opening an already open Bolt
database will cause it to hang until the other process closes it. To prevent
an indefinite wait you can pass a timeout option to the `Open()` function:
```go
db, err := bolt.Open("my.db", 0600, &bolt.Options{Timeout: 1 * time.Second})
```
### Transactions
Bolt allows only one read-write transaction at a time but allows as many
read-only transactions as you want at a time. Each transaction has a consistent
view of the data as it existed when the transaction started.
Individual transactions and all objects created from them (e.g. buckets, keys)
are not thread safe. To work with data in multiple goroutines you must start
a transaction for each one or use locking to ensure only one goroutine accesses
a transaction at a time. Creating transaction from the `DB` is thread safe.
Read-only transactions and read-write transactions should not depend on one
another and generally shouldn't be opened simultaneously in the same goroutine.
This can cause a deadlock as the read-write transaction needs to periodically
re-map the data file but it cannot do so while a read-only transaction is open.
#### Read-write transactions
To start a read-write transaction, you can use the `DB.Update()` function:
```go
err := db.Update(func(tx *bolt.Tx) error {
...
return nil
})
```
Inside the closure, you have a consistent view of the database. You commit the
transaction by returning `nil` at the end. You can also rollback the transaction
at any point by returning an error. All database operations are allowed inside
a read-write transaction.
Always check the return error as it will report any disk failures that can cause
your transaction to not complete. If you return an error within your closure
it will be passed through.
#### Read-only transactions
To start a read-only transaction, you can use the `DB.View()` function:
```go
err := db.View(func(tx *bolt.Tx) error {
...
return nil
})
```
You also get a consistent view of the database within this closure, however,
no mutating operations are allowed within a read-only transaction. You can only
retrieve buckets, retrieve values, and copy the database within a read-only
transaction.
#### Batch read-write transactions
Each `DB.Update()` waits for disk to commit the writes. This overhead
can be minimized by combining multiple updates with the `DB.Batch()`
function:
```go
err := db.Batch(func(tx *bolt.Tx) error {
...
return nil
})
```
Concurrent Batch calls are opportunistically combined into larger
transactions. Batch is only useful when there are multiple goroutines
calling it.
The trade-off is that `Batch` can call the given
function multiple times, if parts of the transaction fail. The
function must be idempotent and side effects must take effect only
after a successful return from `DB.Batch()`.
For example: don't display messages from inside the function, instead
set variables in the enclosing scope:
```go
var id uint64
err := db.Batch(func(tx *bolt.Tx) error {
// Find last key in bucket, decode as bigendian uint64, increment
// by one, encode back to []byte, and add new key.
...
id = newValue
return nil
})
if err != nil {
return ...
}
fmt.Println("Allocated ID %d", id)
```
#### Managing transactions manually
The `DB.View()` and `DB.Update()` functions are wrappers around the `DB.Begin()`
function. These helper functions will start the transaction, execute a function,
and then safely close your transaction if an error is returned. This is the
recommended way to use Bolt transactions.
However, sometimes you may want to manually start and end your transactions.
You can use the `Tx.Begin()` function directly but _please_ be sure to close the
transaction.
```go
// Start a writable transaction.
tx, err := db.Begin(true)
if err != nil {
return err
}
defer tx.Rollback()
// Use the transaction...
_, err := tx.CreateBucket([]byte("MyBucket"))
if err != nil {
return err
}
// Commit the transaction and check for error.
if err := tx.Commit(); err != nil {
return err
}
```
The first argument to `DB.Begin()` is a boolean stating if the transaction
should be writable.
### Using buckets
Buckets are collections of key/value pairs within the database. All keys in a
bucket must be unique. You can create a bucket using the `DB.CreateBucket()`
function:
```go
db.Update(func(tx *bolt.Tx) error {
b, err := tx.CreateBucket([]byte("MyBucket"))
if err != nil {
return fmt.Errorf("create bucket: %s", err)
}
return nil
})
```
You can also create a bucket only if it doesn't exist by using the
`Tx.CreateBucketIfNotExists()` function. It's a common pattern to call this
function for all your top-level buckets after you open your database so you can
guarantee that they exist for future transactions.
To delete a bucket, simply call the `Tx.DeleteBucket()` function.
### Using key/value pairs
To save a key/value pair to a bucket, use the `Bucket.Put()` function:
```go
db.Update(func(tx *bolt.Tx) error {
b := tx.Bucket([]byte("MyBucket"))
err := b.Put([]byte("answer"), []byte("42"))
return err
})
```
This will set the value of the `"answer"` key to `"42"` in the `MyBucket`
bucket. To retrieve this value, we can use the `Bucket.Get()` function:
```go
db.View(func(tx *bolt.Tx) error {
b := tx.Bucket([]byte("MyBucket"))
v := b.Get([]byte("answer"))
fmt.Printf("The answer is: %s\n", v)
return nil
})
```
The `Get()` function does not return an error because its operation is
guarenteed to work (unless there is some kind of system failure). If the key
exists then it will return its byte slice value. If it doesn't exist then it
will return `nil`. It's important to note that you can have a zero-length value
set to a key which is different than the key not existing.
Use the `Bucket.Delete()` function to delete a key from the bucket.
Please note that values returned from `Get()` are only valid while the
transaction is open. If you need to use a value outside of the transaction
then you must use `copy()` to copy it to another byte slice.
### Iterating over keys
Bolt stores its keys in byte-sorted order within a bucket. This makes sequential
iteration over these keys extremely fast. To iterate over keys we'll use a
`Cursor`:
```go
db.View(func(tx *bolt.Tx) error {
b := tx.Bucket([]byte("MyBucket"))
c := b.Cursor()
for k, v := c.First(); k != nil; k, v = c.Next() {
fmt.Printf("key=%s, value=%s\n", k, v)
}
return nil
})
```
The cursor allows you to move to a specific point in the list of keys and move
forward or backward through the keys one at a time.
The following functions are available on the cursor:
```
First() Move to the first key.
Last() Move to the last key.
Seek() Move to a specific key.
Next() Move to the next key.
Prev() Move to the previous key.
```
When you have iterated to the end of the cursor then `Next()` will return `nil`.
You must seek to a position using `First()`, `Last()`, or `Seek()` before
calling `Next()` or `Prev()`. If you do not seek to a position then these
functions will return `nil`.
#### Prefix scans
To iterate over a key prefix, you can combine `Seek()` and `bytes.HasPrefix()`:
```go
db.View(func(tx *bolt.Tx) error {
c := tx.Bucket([]byte("MyBucket")).Cursor()
prefix := []byte("1234")
for k, v := c.Seek(prefix); bytes.HasPrefix(k, prefix); k, v = c.Next() {
fmt.Printf("key=%s, value=%s\n", k, v)
}
return nil
})
```
#### Range scans
Another common use case is scanning over a range such as a time range. If you
use a sortable time encoding such as RFC3339 then you can query a specific
date range like this:
```go
db.View(func(tx *bolt.Tx) error {
// Assume our events bucket has RFC3339 encoded time keys.
c := tx.Bucket([]byte("Events")).Cursor()
// Our time range spans the 90's decade.
min := []byte("1990-01-01T00:00:00Z")
max := []byte("2000-01-01T00:00:00Z")
// Iterate over the 90's.
for k, v := c.Seek(min); k != nil && bytes.Compare(k, max) <= 0; k, v = c.Next() {
fmt.Printf("%s: %s\n", k, v)
}
return nil
})
```
#### ForEach()
You can also use the function `ForEach()` if you know you'll be iterating over
all the keys in a bucket:
```go
db.View(func(tx *bolt.Tx) error {
b := tx.Bucket([]byte("MyBucket"))
b.ForEach(func(k, v []byte) error {
fmt.Printf("key=%s, value=%s\n", k, v)
return nil
})
return nil
})
```
### Nested buckets
You can also store a bucket in a key to create nested buckets. The API is the
same as the bucket management API on the `DB` object:
```go
func (*Bucket) CreateBucket(key []byte) (*Bucket, error)
func (*Bucket) CreateBucketIfNotExists(key []byte) (*Bucket, error)
func (*Bucket) DeleteBucket(key []byte) error
```
### Database backups
Bolt is a single file so it's easy to backup. You can use the `Tx.WriteTo()`
function to write a consistent view of the database to a writer. If you call
this from a read-only transaction, it will perform a hot backup and not block
your other database reads and writes. It will also use `O_DIRECT` when available
to prevent page cache trashing.
One common use case is to backup over HTTP so you can use tools like `cURL` to
do database backups:
```go
func BackupHandleFunc(w http.ResponseWriter, req *http.Request) {
err := db.View(func(tx *bolt.Tx) error {
w.Header().Set("Content-Type", "application/octet-stream")
w.Header().Set("Content-Disposition", `attachment; filename="my.db"`)
w.Header().Set("Content-Length", strconv.Itoa(int(tx.Size())))
_, err := tx.WriteTo(w)
return err
})
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
}
```
Then you can backup using this command:
```sh
$ curl http://localhost/backup > my.db
```
Or you can open your browser to `http://localhost/backup` and it will download
automatically.
If you want to backup to another file you can use the `Tx.CopyFile()` helper
function.
### Statistics
The database keeps a running count of many of the internal operations it
performs so you can better understand what's going on. By grabbing a snapshot
of these stats at two points in time we can see what operations were performed
in that time range.
For example, we could start a goroutine to log stats every 10 seconds:
```go
go func() {
// Grab the initial stats.
prev := db.Stats()
for {
// Wait for 10s.
time.Sleep(10 * time.Second)
// Grab the current stats and diff them.
stats := db.Stats()
diff := stats.Sub(&prev)
// Encode stats to JSON and print to STDERR.
json.NewEncoder(os.Stderr).Encode(diff)
// Save stats for the next loop.
prev = stats
}
}()
```
It's also useful to pipe these stats to a service such as statsd for monitoring
or to provide an HTTP endpoint that will perform a fixed-length sample.
### Read-Only Mode
Sometimes it is useful to create a shared, read-only Bolt database. To this,
set the `Options.ReadOnly` flag when opening your database. Read-only mode
uses a shared lock to allow multiple processes to read from the database but
it will block any processes from opening the database in read-write mode.
```go
db, err := bolt.Open("my.db", 0666, &bolt.Options{ReadOnly: true})
if err != nil {
log.Fatal(err)
}
```
## Resources
For more information on getting started with Bolt, check out the following articles:
* [Intro to BoltDB: Painless Performant Persistence](http://npf.io/2014/07/intro-to-boltdb-painless-performant-persistence/) by [Nate Finch](https://github.com/natefinch).
* [Bolt -- an embedded key/value database for Go](https://www.progville.com/go/bolt-embedded-db-golang/) by Progville
## Comparison with other databases
### Postgres, MySQL, & other relational databases
Relational databases structure data into rows and are only accessible through
the use of SQL. This approach provides flexibility in how you store and query
your data but also incurs overhead in parsing and planning SQL statements. Bolt
accesses all data by a byte slice key. This makes Bolt fast to read and write
data by key but provides no built-in support for joining values together.
Most relational databases (with the exception of SQLite) are standalone servers
that run separately from your application. This gives your systems
flexibility to connect multiple application servers to a single database
server but also adds overhead in serializing and transporting data over the
network. Bolt runs as a library included in your application so all data access
has to go through your application's process. This brings data closer to your
application but limits multi-process access to the data.
### LevelDB, RocksDB
LevelDB and its derivatives (RocksDB, HyperLevelDB) are similar to Bolt in that
they are libraries bundled into the application, however, their underlying
structure is a log-structured merge-tree (LSM tree). An LSM tree optimizes
random writes by using a write ahead log and multi-tiered, sorted files called
SSTables. Bolt uses a B+tree internally and only a single file. Both approaches
have trade offs.
If you require a high random write throughput (>10,000 w/sec) or you need to use
spinning disks then LevelDB could be a good choice. If your application is
read-heavy or does a lot of range scans then Bolt could be a good choice.
One other important consideration is that LevelDB does not have transactions.
It supports batch writing of key/values pairs and it supports read snapshots
but it will not give you the ability to do a compare-and-swap operation safely.
Bolt supports fully serializable ACID transactions.
### LMDB
Bolt was originally a port of LMDB so it is architecturally similar. Both use
a B+tree, have ACID semantics with fully serializable transactions, and support
lock-free MVCC using a single writer and multiple readers.
The two projects have somewhat diverged. LMDB heavily focuses on raw performance
while Bolt has focused on simplicity and ease of use. For example, LMDB allows
several unsafe actions such as direct writes for the sake of performance. Bolt
opts to disallow actions which can leave the database in a corrupted state. The
only exception to this in Bolt is `DB.NoSync`.
There are also a few differences in API. LMDB requires a maximum mmap size when
opening an `mdb_env` whereas Bolt will handle incremental mmap resizing
automatically. LMDB overloads the getter and setter functions with multiple
flags whereas Bolt splits these specialized cases into their own functions.
## Caveats & Limitations
It's important to pick the right tool for the job and Bolt is no exception.
Here are a few things to note when evaluating and using Bolt:
* Bolt is good for read intensive workloads. Sequential write performance is
also fast but random writes can be slow. You can add a write-ahead log or
[transaction coalescer](https://github.com/boltdb/coalescer) in front of Bolt
to mitigate this issue.
* Bolt uses a B+tree internally so there can be a lot of random page access.
SSDs provide a significant performance boost over spinning disks.
* Try to avoid long running read transactions. Bolt uses copy-on-write so
old pages cannot be reclaimed while an old transaction is using them.
* Byte slices returned from Bolt are only valid during a transaction. Once the
transaction has been committed or rolled back then the memory they point to
can be reused by a new page or can be unmapped from virtual memory and you'll
see an `unexpected fault address` panic when accessing it.
* Be careful when using `Bucket.FillPercent`. Setting a high fill percent for
buckets that have random inserts will cause your database to have very poor
page utilization.
* Use larger buckets in general. Smaller buckets causes poor page utilization
once they become larger than the page size (typically 4KB).
* Bulk loading a lot of random writes into a new bucket can be slow as the
page will not split until the transaction is committed. Randomly inserting
more than 100,000 key/value pairs into a single new bucket in a single
transaction is not advised.
* Bolt uses a memory-mapped file so the underlying operating system handles the
caching of the data. Typically, the OS will cache as much of the file as it
can in memory and will release memory as needed to other processes. This means
that Bolt can show very high memory usage when working with large databases.
However, this is expected and the OS will release memory as needed. Bolt can
handle databases much larger than the available physical RAM.
* The data structures in the Bolt database are memory mapped so the data file
will be endian specific. This means that you cannot copy a Bolt file from a
little endian machine to a big endian machine and have it work. For most
users this is not a concern since most modern CPUs are little endian.
* Because of the way pages are laid out on disk, Bolt cannot truncate data files
and return free pages back to the disk. Instead, Bolt maintains a free list
of unused pages within its data file. These free pages can be reused by later
transactions. This works well for many use cases as databases generally tend
to grow. However, it's important to note that deleting large chunks of data
will not allow you to reclaim that space on disk.
For more information on page allocation, [see this comment][page-allocation].
[page-allocation]: https://github.com/boltdb/bolt/issues/308#issuecomment-74811638
## Other Projects Using Bolt
Below is a list of public, open source projects that use Bolt:
* [Operation Go: A Routine Mission](http://gocode.io) - An online programming game for Golang using Bolt for user accounts and a leaderboard.
* [Bazil](https://bazil.org/) - A file system that lets your data reside where it is most convenient for it to reside.
* [DVID](https://github.com/janelia-flyem/dvid) - Added Bolt as optional storage engine and testing it against Basho-tuned leveldb.
* [Skybox Analytics](https://github.com/skybox/skybox) - A standalone funnel analysis tool for web analytics.
* [Scuttlebutt](https://github.com/benbjohnson/scuttlebutt) - Uses Bolt to store and process all Twitter mentions of GitHub projects.
* [Wiki](https://github.com/peterhellberg/wiki) - A tiny wiki using Goji, BoltDB and Blackfriday.
* [ChainStore](https://github.com/nulayer/chainstore) - Simple key-value interface to a variety of storage engines organized as a chain of operations.
* [MetricBase](https://github.com/msiebuhr/MetricBase) - Single-binary version of Graphite.
* [Gitchain](https://github.com/gitchain/gitchain) - Decentralized, peer-to-peer Git repositories aka "Git meets Bitcoin".
* [event-shuttle](https://github.com/sclasen/event-shuttle) - A Unix system service to collect and reliably deliver messages to Kafka.
* [ipxed](https://github.com/kelseyhightower/ipxed) - Web interface and api for ipxed.
* [BoltStore](https://github.com/yosssi/boltstore) - Session store using Bolt.
* [photosite/session](http://godoc.org/bitbucket.org/kardianos/photosite/session) - Sessions for a photo viewing site.
* [LedisDB](https://github.com/siddontang/ledisdb) - A high performance NoSQL, using Bolt as optional storage.
* [ipLocator](https://github.com/AndreasBriese/ipLocator) - A fast ip-geo-location-server using bolt with bloom filters.
* [cayley](https://github.com/google/cayley) - Cayley is an open-source graph database using Bolt as optional backend.
* [bleve](http://www.blevesearch.com/) - A pure Go search engine similar to ElasticSearch that uses Bolt as the default storage backend.
* [tentacool](https://github.com/optiflows/tentacool) - REST api server to manage system stuff (IP, DNS, Gateway...) on a linux server.
* [SkyDB](https://github.com/skydb/sky) - Behavioral analytics database.
* [Seaweed File System](https://github.com/chrislusf/weed-fs) - Highly scalable distributed key~file system with O(1) disk read.
* [InfluxDB](http://influxdb.com) - Scalable datastore for metrics, events, and real-time analytics.
* [Freehold](http://tshannon.bitbucket.org/freehold/) - An open, secure, and lightweight platform for your files and data.
* [Prometheus Annotation Server](https://github.com/oliver006/prom_annotation_server) - Annotation server for PromDash & Prometheus service monitoring system.
* [Consul](https://github.com/hashicorp/consul) - Consul is service discovery and configuration made easy. Distributed, highly available, and datacenter-aware.
* [Kala](https://github.com/ajvb/kala) - Kala is a modern job scheduler optimized to run on a single node. It is persistant, JSON over HTTP API, ISO 8601 duration notation, and dependent jobs.
* [drive](https://github.com/odeke-em/drive) - drive is an unofficial Google Drive command line client for \*NIX operating systems.
If you are using Bolt in a project please send a pull request to add it to the list.

138
Godeps/_workspace/src/github.com/boltdb/bolt/batch.go generated vendored Normal file
View File

@ -0,0 +1,138 @@
package bolt
import (
"errors"
"fmt"
"sync"
"time"
)
// Batch calls fn as part of a batch. It behaves similar to Update,
// except:
//
// 1. concurrent Batch calls can be combined into a single Bolt
// transaction.
//
// 2. the function passed to Batch may be called multiple times,
// regardless of whether it returns error or not.
//
// This means that Batch function side effects must be idempotent and
// take permanent effect only after a successful return is seen in
// caller.
//
// The maximum batch size and delay can be adjusted with DB.MaxBatchSize
// and DB.MaxBatchDelay, respectively.
//
// Batch is only useful when there are multiple goroutines calling it.
func (db *DB) Batch(fn func(*Tx) error) error {
errCh := make(chan error, 1)
db.batchMu.Lock()
if (db.batch == nil) || (db.batch != nil && len(db.batch.calls) >= db.MaxBatchSize) {
// There is no existing batch, or the existing batch is full; start a new one.
db.batch = &batch{
db: db,
}
db.batch.timer = time.AfterFunc(db.MaxBatchDelay, db.batch.trigger)
}
db.batch.calls = append(db.batch.calls, call{fn: fn, err: errCh})
if len(db.batch.calls) >= db.MaxBatchSize {
// wake up batch, it's ready to run
go db.batch.trigger()
}
db.batchMu.Unlock()
err := <-errCh
if err == trySolo {
err = db.Update(fn)
}
return err
}
type call struct {
fn func(*Tx) error
err chan<- error
}
type batch struct {
db *DB
timer *time.Timer
start sync.Once
calls []call
}
// trigger runs the batch if it hasn't already been run.
func (b *batch) trigger() {
b.start.Do(b.run)
}
// run performs the transactions in the batch and communicates results
// back to DB.Batch.
func (b *batch) run() {
b.db.batchMu.Lock()
b.timer.Stop()
// Make sure no new work is added to this batch, but don't break
// other batches.
if b.db.batch == b {
b.db.batch = nil
}
b.db.batchMu.Unlock()
retry:
for len(b.calls) > 0 {
var failIdx = -1
err := b.db.Update(func(tx *Tx) error {
for i, c := range b.calls {
if err := safelyCall(c.fn, tx); err != nil {
failIdx = i
return err
}
}
return nil
})
if failIdx >= 0 {
// take the failing transaction out of the batch. it's
// safe to shorten b.calls here because db.batch no longer
// points to us, and we hold the mutex anyway.
c := b.calls[failIdx]
b.calls[failIdx], b.calls = b.calls[len(b.calls)-1], b.calls[:len(b.calls)-1]
// tell the submitter re-run it solo, continue with the rest of the batch
c.err <- trySolo
continue retry
}
// pass success, or bolt internal errors, to all callers
for _, c := range b.calls {
if c.err != nil {
c.err <- err
}
}
break retry
}
}
// trySolo is a special sentinel error value used for signaling that a
// transaction function should be re-run. It should never be seen by
// callers.
var trySolo = errors.New("batch function returned an error and should be re-run solo")
type panicked struct {
reason interface{}
}
func (p panicked) Error() string {
if err, ok := p.reason.(error); ok {
return err.Error()
}
return fmt.Sprintf("panic: %v", p.reason)
}
func safelyCall(fn func(*Tx) error, tx *Tx) (err error) {
defer func() {
if p := recover(); p != nil {
err = panicked{p}
}
}()
return fn(tx)
}

View File

@ -0,0 +1,170 @@
package bolt_test
import (
"bytes"
"encoding/binary"
"errors"
"hash/fnv"
"sync"
"testing"
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/boltdb/bolt"
)
func validateBatchBench(b *testing.B, db *TestDB) {
var rollback = errors.New("sentinel error to cause rollback")
validate := func(tx *bolt.Tx) error {
bucket := tx.Bucket([]byte("bench"))
h := fnv.New32a()
buf := make([]byte, 4)
for id := uint32(0); id < 1000; id++ {
binary.LittleEndian.PutUint32(buf, id)
h.Reset()
h.Write(buf[:])
k := h.Sum(nil)
v := bucket.Get(k)
if v == nil {
b.Errorf("not found id=%d key=%x", id, k)
continue
}
if g, e := v, []byte("filler"); !bytes.Equal(g, e) {
b.Errorf("bad value for id=%d key=%x: %s != %q", id, k, g, e)
}
if err := bucket.Delete(k); err != nil {
return err
}
}
// should be empty now
c := bucket.Cursor()
for k, v := c.First(); k != nil; k, v = c.Next() {
b.Errorf("unexpected key: %x = %q", k, v)
}
return rollback
}
if err := db.Update(validate); err != nil && err != rollback {
b.Error(err)
}
}
func BenchmarkDBBatchAutomatic(b *testing.B) {
db := NewTestDB()
defer db.Close()
db.MustCreateBucket([]byte("bench"))
b.ResetTimer()
for i := 0; i < b.N; i++ {
start := make(chan struct{})
var wg sync.WaitGroup
for round := 0; round < 1000; round++ {
wg.Add(1)
go func(id uint32) {
defer wg.Done()
<-start
h := fnv.New32a()
buf := make([]byte, 4)
binary.LittleEndian.PutUint32(buf, id)
h.Write(buf[:])
k := h.Sum(nil)
insert := func(tx *bolt.Tx) error {
b := tx.Bucket([]byte("bench"))
return b.Put(k, []byte("filler"))
}
if err := db.Batch(insert); err != nil {
b.Error(err)
return
}
}(uint32(round))
}
close(start)
wg.Wait()
}
b.StopTimer()
validateBatchBench(b, db)
}
func BenchmarkDBBatchSingle(b *testing.B) {
db := NewTestDB()
defer db.Close()
db.MustCreateBucket([]byte("bench"))
b.ResetTimer()
for i := 0; i < b.N; i++ {
start := make(chan struct{})
var wg sync.WaitGroup
for round := 0; round < 1000; round++ {
wg.Add(1)
go func(id uint32) {
defer wg.Done()
<-start
h := fnv.New32a()
buf := make([]byte, 4)
binary.LittleEndian.PutUint32(buf, id)
h.Write(buf[:])
k := h.Sum(nil)
insert := func(tx *bolt.Tx) error {
b := tx.Bucket([]byte("bench"))
return b.Put(k, []byte("filler"))
}
if err := db.Update(insert); err != nil {
b.Error(err)
return
}
}(uint32(round))
}
close(start)
wg.Wait()
}
b.StopTimer()
validateBatchBench(b, db)
}
func BenchmarkDBBatchManual10x100(b *testing.B) {
db := NewTestDB()
defer db.Close()
db.MustCreateBucket([]byte("bench"))
b.ResetTimer()
for i := 0; i < b.N; i++ {
start := make(chan struct{})
var wg sync.WaitGroup
for major := 0; major < 10; major++ {
wg.Add(1)
go func(id uint32) {
defer wg.Done()
<-start
insert100 := func(tx *bolt.Tx) error {
h := fnv.New32a()
buf := make([]byte, 4)
for minor := uint32(0); minor < 100; minor++ {
binary.LittleEndian.PutUint32(buf, uint32(id*100+minor))
h.Reset()
h.Write(buf[:])
k := h.Sum(nil)
b := tx.Bucket([]byte("bench"))
if err := b.Put(k, []byte("filler")); err != nil {
return err
}
}
return nil
}
if err := db.Update(insert100); err != nil {
b.Fatal(err)
}
}(uint32(major))
}
close(start)
wg.Wait()
}
b.StopTimer()
validateBatchBench(b, db)
}

View File

@ -0,0 +1,148 @@
package bolt_test
import (
"encoding/binary"
"fmt"
"io/ioutil"
"log"
"math/rand"
"net/http"
"net/http/httptest"
"os"
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/boltdb/bolt"
)
// Set this to see how the counts are actually updated.
const verbose = false
// Counter updates a counter in Bolt for every URL path requested.
type counter struct {
db *bolt.DB
}
func (c counter) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
// Communicates the new count from a successful database
// transaction.
var result uint64
increment := func(tx *bolt.Tx) error {
b, err := tx.CreateBucketIfNotExists([]byte("hits"))
if err != nil {
return err
}
key := []byte(req.URL.String())
// Decode handles key not found for us.
count := decode(b.Get(key)) + 1
b.Put(key, encode(count))
// All good, communicate new count.
result = count
return nil
}
if err := c.db.Batch(increment); err != nil {
http.Error(rw, err.Error(), 500)
return
}
if verbose {
log.Printf("server: %s: %d", req.URL.String(), result)
}
rw.Header().Set("Content-Type", "application/octet-stream")
fmt.Fprintf(rw, "%d\n", result)
}
func client(id int, base string, paths []string) error {
// Process paths in random order.
rng := rand.New(rand.NewSource(int64(id)))
permutation := rng.Perm(len(paths))
for i := range paths {
path := paths[permutation[i]]
resp, err := http.Get(base + path)
if err != nil {
return err
}
defer resp.Body.Close()
buf, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
if verbose {
log.Printf("client: %s: %s", path, buf)
}
}
return nil
}
func ExampleDB_Batch() {
// Open the database.
db, _ := bolt.Open(tempfile(), 0666, nil)
defer os.Remove(db.Path())
defer db.Close()
// Start our web server
count := counter{db}
srv := httptest.NewServer(count)
defer srv.Close()
// Decrease the batch size to make things more interesting.
db.MaxBatchSize = 3
// Get every path multiple times concurrently.
const clients = 10
paths := []string{
"/foo",
"/bar",
"/baz",
"/quux",
"/thud",
"/xyzzy",
}
errors := make(chan error, clients)
for i := 0; i < clients; i++ {
go func(id int) {
errors <- client(id, srv.URL, paths)
}(i)
}
// Check all responses to make sure there's no error.
for i := 0; i < clients; i++ {
if err := <-errors; err != nil {
fmt.Printf("client error: %v", err)
return
}
}
// Check the final result
db.View(func(tx *bolt.Tx) error {
b := tx.Bucket([]byte("hits"))
c := b.Cursor()
for k, v := c.First(); k != nil; k, v = c.Next() {
fmt.Printf("hits to %s: %d\n", k, decode(v))
}
return nil
})
// Output:
// hits to /bar: 10
// hits to /baz: 10
// hits to /foo: 10
// hits to /quux: 10
// hits to /thud: 10
// hits to /xyzzy: 10
}
// encode marshals a counter.
func encode(n uint64) []byte {
buf := make([]byte, 8)
binary.BigEndian.PutUint64(buf, n)
return buf
}
// decode unmarshals a counter. Nil buffers are decoded as 0.
func decode(buf []byte) uint64 {
if buf == nil {
return 0
}
return binary.BigEndian.Uint64(buf)
}

View File

@ -0,0 +1,167 @@
package bolt_test
import (
"testing"
"time"
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/boltdb/bolt"
)
// Ensure two functions can perform updates in a single batch.
func TestDB_Batch(t *testing.T) {
db := NewTestDB()
defer db.Close()
db.MustCreateBucket([]byte("widgets"))
// Iterate over multiple updates in separate goroutines.
n := 2
ch := make(chan error)
for i := 0; i < n; i++ {
go func(i int) {
ch <- db.Batch(func(tx *bolt.Tx) error {
return tx.Bucket([]byte("widgets")).Put(u64tob(uint64(i)), []byte{})
})
}(i)
}
// Check all responses to make sure there's no error.
for i := 0; i < n; i++ {
if err := <-ch; err != nil {
t.Fatal(err)
}
}
// Ensure data is correct.
db.MustView(func(tx *bolt.Tx) error {
b := tx.Bucket([]byte("widgets"))
for i := 0; i < n; i++ {
if v := b.Get(u64tob(uint64(i))); v == nil {
t.Errorf("key not found: %d", i)
}
}
return nil
})
}
func TestDB_Batch_Panic(t *testing.T) {
db := NewTestDB()
defer db.Close()
var sentinel int
var bork = &sentinel
var problem interface{}
var err error
// Execute a function inside a batch that panics.
func() {
defer func() {
if p := recover(); p != nil {
problem = p
}
}()
err = db.Batch(func(tx *bolt.Tx) error {
panic(bork)
})
}()
// Verify there is no error.
if g, e := err, error(nil); g != e {
t.Fatalf("wrong error: %v != %v", g, e)
}
// Verify the panic was captured.
if g, e := problem, bork; g != e {
t.Fatalf("wrong error: %v != %v", g, e)
}
}
func TestDB_BatchFull(t *testing.T) {
db := NewTestDB()
defer db.Close()
db.MustCreateBucket([]byte("widgets"))
const size = 3
// buffered so we never leak goroutines
ch := make(chan error, size)
put := func(i int) {
ch <- db.Batch(func(tx *bolt.Tx) error {
return tx.Bucket([]byte("widgets")).Put(u64tob(uint64(i)), []byte{})
})
}
db.MaxBatchSize = size
// high enough to never trigger here
db.MaxBatchDelay = 1 * time.Hour
go put(1)
go put(2)
// Give the batch a chance to exhibit bugs.
time.Sleep(10 * time.Millisecond)
// not triggered yet
select {
case <-ch:
t.Fatalf("batch triggered too early")
default:
}
go put(3)
// Check all responses to make sure there's no error.
for i := 0; i < size; i++ {
if err := <-ch; err != nil {
t.Fatal(err)
}
}
// Ensure data is correct.
db.MustView(func(tx *bolt.Tx) error {
b := tx.Bucket([]byte("widgets"))
for i := 1; i <= size; i++ {
if v := b.Get(u64tob(uint64(i))); v == nil {
t.Errorf("key not found: %d", i)
}
}
return nil
})
}
func TestDB_BatchTime(t *testing.T) {
db := NewTestDB()
defer db.Close()
db.MustCreateBucket([]byte("widgets"))
const size = 1
// buffered so we never leak goroutines
ch := make(chan error, size)
put := func(i int) {
ch <- db.Batch(func(tx *bolt.Tx) error {
return tx.Bucket([]byte("widgets")).Put(u64tob(uint64(i)), []byte{})
})
}
db.MaxBatchSize = 1000
db.MaxBatchDelay = 0
go put(1)
// Batch must trigger by time alone.
// Check all responses to make sure there's no error.
for i := 0; i < size; i++ {
if err := <-ch; err != nil {
t.Fatal(err)
}
}
// Ensure data is correct.
db.MustView(func(tx *bolt.Tx) error {
b := tx.Bucket([]byte("widgets"))
for i := 1; i <= size; i++ {
if v := b.Get(u64tob(uint64(i))); v == nil {
t.Errorf("key not found: %d", i)
}
}
return nil
})
}

View File

@ -0,0 +1,7 @@
package bolt
// maxMapSize represents the largest mmap size supported by Bolt.
const maxMapSize = 0x7FFFFFFF // 2GB
// maxAllocSize is the size used when creating array pointers.
const maxAllocSize = 0xFFFFFFF

View File

@ -0,0 +1,7 @@
package bolt
// maxMapSize represents the largest mmap size supported by Bolt.
const maxMapSize = 0xFFFFFFFFFFFF // 256TB
// maxAllocSize is the size used when creating array pointers.
const maxAllocSize = 0x7FFFFFFF

View File

@ -0,0 +1,7 @@
package bolt
// maxMapSize represents the largest mmap size supported by Bolt.
const maxMapSize = 0x7FFFFFFF // 2GB
// maxAllocSize is the size used when creating array pointers.
const maxAllocSize = 0xFFFFFFF

View File

@ -0,0 +1,12 @@
package bolt
import (
"syscall"
)
var odirect = syscall.O_DIRECT
// fdatasync flushes written data to a file descriptor.
func fdatasync(db *DB) error {
return syscall.Fdatasync(int(db.file.Fd()))
}

View File

@ -0,0 +1,29 @@
package bolt
import (
"syscall"
"unsafe"
)
const (
msAsync = 1 << iota // perform asynchronous writes
msSync // perform synchronous writes
msInvalidate // invalidate cached data
)
var odirect int
func msync(db *DB) error {
_, _, errno := syscall.Syscall(syscall.SYS_MSYNC, uintptr(unsafe.Pointer(db.data)), uintptr(db.datasz), msInvalidate)
if errno != 0 {
return errno
}
return nil
}
func fdatasync(db *DB) error {
if db.data != nil {
return msync(db)
}
return db.file.Sync()
}

View File

@ -0,0 +1,36 @@
package bolt_test
import (
"fmt"
"path/filepath"
"reflect"
"runtime"
"testing"
)
// assert fails the test if the condition is false.
func assert(tb testing.TB, condition bool, msg string, v ...interface{}) {
if !condition {
_, file, line, _ := runtime.Caller(1)
fmt.Printf("\033[31m%s:%d: "+msg+"\033[39m\n\n", append([]interface{}{filepath.Base(file), line}, v...)...)
tb.FailNow()
}
}
// ok fails the test if an err is not nil.
func ok(tb testing.TB, err error) {
if err != nil {
_, file, line, _ := runtime.Caller(1)
fmt.Printf("\033[31m%s:%d: unexpected error: %s\033[39m\n\n", filepath.Base(file), line, err.Error())
tb.FailNow()
}
}
// equals fails the test if exp is not equal to act.
func equals(tb testing.TB, exp, act interface{}) {
if !reflect.DeepEqual(exp, act) {
_, file, line, _ := runtime.Caller(1)
fmt.Printf("\033[31m%s:%d:\n\n\texp: %#v\n\n\tgot: %#v\033[39m\n\n", filepath.Base(file), line, exp, act)
tb.FailNow()
}
}

View File

@ -0,0 +1,100 @@
// +build !windows,!plan9,!solaris
package bolt
import (
"fmt"
"os"
"syscall"
"time"
"unsafe"
)
// flock acquires an advisory lock on a file descriptor.
func flock(f *os.File, exclusive bool, timeout time.Duration) error {
var t time.Time
for {
// If we're beyond our timeout then return an error.
// This can only occur after we've attempted a flock once.
if t.IsZero() {
t = time.Now()
} else if timeout > 0 && time.Since(t) > timeout {
return ErrTimeout
}
flag := syscall.LOCK_SH
if exclusive {
flag = syscall.LOCK_EX
}
// Otherwise attempt to obtain an exclusive lock.
err := syscall.Flock(int(f.Fd()), flag|syscall.LOCK_NB)
if err == nil {
return nil
} else if err != syscall.EWOULDBLOCK {
return err
}
// Wait for a bit and try again.
time.Sleep(50 * time.Millisecond)
}
}
// funlock releases an advisory lock on a file descriptor.
func funlock(f *os.File) error {
return syscall.Flock(int(f.Fd()), syscall.LOCK_UN)
}
// mmap memory maps a DB's data file.
func mmap(db *DB, sz int) error {
// Truncate and fsync to ensure file size metadata is flushed.
// https://github.com/boltdb/bolt/issues/284
if !db.NoGrowSync && !db.readOnly {
if err := db.file.Truncate(int64(sz)); err != nil {
return fmt.Errorf("file resize error: %s", err)
}
if err := db.file.Sync(); err != nil {
return fmt.Errorf("file sync error: %s", err)
}
}
// Map the data file to memory.
b, err := syscall.Mmap(int(db.file.Fd()), 0, sz, syscall.PROT_READ, syscall.MAP_SHARED)
if err != nil {
return err
}
// Advise the kernel that the mmap is accessed randomly.
if err := madvise(b, syscall.MADV_RANDOM); err != nil {
return fmt.Errorf("madvise: %s", err)
}
// Save the original byte slice and convert to a byte array pointer.
db.dataref = b
db.data = (*[maxMapSize]byte)(unsafe.Pointer(&b[0]))
db.datasz = sz
return nil
}
// munmap unmaps a DB's data file from memory.
func munmap(db *DB) error {
// Ignore the unmap if we have no mapped data.
if db.dataref == nil {
return nil
}
// Unmap using the original byte slice.
err := syscall.Munmap(db.dataref)
db.dataref = nil
db.data = nil
db.datasz = 0
return err
}
// NOTE: This function is copied from stdlib because it is not available on darwin.
func madvise(b []byte, advice int) (err error) {
_, _, e1 := syscall.Syscall(syscall.SYS_MADVISE, uintptr(unsafe.Pointer(&b[0])), uintptr(len(b)), uintptr(advice))
if e1 != 0 {
err = e1
}
return
}

View File

@ -0,0 +1,100 @@
package bolt
import (
"fmt"
"github.com/coreos/etcd/Godeps/_workspace/src/golang.org/x/sys/unix"
"os"
"syscall"
"time"
"unsafe"
)
// flock acquires an advisory lock on a file descriptor.
func flock(f *os.File, exclusive bool, timeout time.Duration) error {
var t time.Time
for {
// If we're beyond our timeout then return an error.
// This can only occur after we've attempted a flock once.
if t.IsZero() {
t = time.Now()
} else if timeout > 0 && time.Since(t) > timeout {
return ErrTimeout
}
var lock syscall.Flock_t
lock.Start = 0
lock.Len = 0
lock.Pid = 0
lock.Whence = 0
lock.Pid = 0
if exclusive {
lock.Type = syscall.F_WRLCK
} else {
lock.Type = syscall.F_RDLCK
}
err := syscall.FcntlFlock(f.Fd(), syscall.F_SETLK, &lock)
if err == nil {
return nil
} else if err != syscall.EAGAIN {
return err
}
// Wait for a bit and try again.
time.Sleep(50 * time.Millisecond)
}
}
// funlock releases an advisory lock on a file descriptor.
func funlock(f *os.File) error {
var lock syscall.Flock_t
lock.Start = 0
lock.Len = 0
lock.Type = syscall.F_UNLCK
lock.Whence = 0
return syscall.FcntlFlock(uintptr(f.Fd()), syscall.F_SETLK, &lock)
}
// mmap memory maps a DB's data file.
func mmap(db *DB, sz int) error {
// Truncate and fsync to ensure file size metadata is flushed.
// https://github.com/boltdb/bolt/issues/284
if !db.NoGrowSync && !db.readOnly {
if err := db.file.Truncate(int64(sz)); err != nil {
return fmt.Errorf("file resize error: %s", err)
}
if err := db.file.Sync(); err != nil {
return fmt.Errorf("file sync error: %s", err)
}
}
// Map the data file to memory.
b, err := unix.Mmap(int(db.file.Fd()), 0, sz, syscall.PROT_READ, syscall.MAP_SHARED)
if err != nil {
return err
}
// Advise the kernel that the mmap is accessed randomly.
if err := unix.Madvise(b, syscall.MADV_RANDOM); err != nil {
return fmt.Errorf("madvise: %s", err)
}
// Save the original byte slice and convert to a byte array pointer.
db.dataref = b
db.data = (*[maxMapSize]byte)(unsafe.Pointer(&b[0]))
db.datasz = sz
return nil
}
// munmap unmaps a DB's data file from memory.
func munmap(db *DB) error {
// Ignore the unmap if we have no mapped data.
if db.dataref == nil {
return nil
}
// Unmap using the original byte slice.
err := unix.Munmap(db.dataref)
db.dataref = nil
db.data = nil
db.datasz = 0
return err
}

View File

@ -0,0 +1,76 @@
package bolt
import (
"fmt"
"os"
"syscall"
"time"
"unsafe"
)
var odirect int
// fdatasync flushes written data to a file descriptor.
func fdatasync(db *DB) error {
return db.file.Sync()
}
// flock acquires an advisory lock on a file descriptor.
func flock(f *os.File, _ bool, _ time.Duration) error {
return nil
}
// funlock releases an advisory lock on a file descriptor.
func funlock(f *os.File) error {
return nil
}
// mmap memory maps a DB's data file.
// Based on: https://github.com/edsrzf/mmap-go
func mmap(db *DB, sz int) error {
if !db.readOnly {
// Truncate the database to the size of the mmap.
if err := db.file.Truncate(int64(sz)); err != nil {
return fmt.Errorf("truncate: %s", err)
}
}
// Open a file mapping handle.
sizelo := uint32(sz >> 32)
sizehi := uint32(sz) & 0xffffffff
h, errno := syscall.CreateFileMapping(syscall.Handle(db.file.Fd()), nil, syscall.PAGE_READONLY, sizelo, sizehi, nil)
if h == 0 {
return os.NewSyscallError("CreateFileMapping", errno)
}
// Create the memory map.
addr, errno := syscall.MapViewOfFile(h, syscall.FILE_MAP_READ, 0, 0, uintptr(sz))
if addr == 0 {
return os.NewSyscallError("MapViewOfFile", errno)
}
// Close mapping handle.
if err := syscall.CloseHandle(syscall.Handle(h)); err != nil {
return os.NewSyscallError("CloseHandle", err)
}
// Convert to a byte array.
db.data = ((*[maxMapSize]byte)(unsafe.Pointer(addr)))
db.datasz = sz
return nil
}
// munmap unmaps a pointer from a file.
// Based on: https://github.com/edsrzf/mmap-go
func munmap(db *DB) error {
if db.data == nil {
return nil
}
addr := (uintptr)(unsafe.Pointer(&db.data[0]))
if err := syscall.UnmapViewOfFile(addr); err != nil {
return os.NewSyscallError("UnmapViewOfFile", err)
}
return nil
}

View File

@ -0,0 +1,10 @@
// +build !windows,!plan9,!linux,!openbsd
package bolt
var odirect int
// fdatasync flushes written data to a file descriptor.
func fdatasync(db *DB) error {
return db.file.Sync()
}

743
Godeps/_workspace/src/github.com/boltdb/bolt/bucket.go generated vendored Normal file
View File

@ -0,0 +1,743 @@
package bolt
import (
"bytes"
"fmt"
"unsafe"
)
const (
// MaxKeySize is the maximum length of a key, in bytes.
MaxKeySize = 32768
// MaxValueSize is the maximum length of a value, in bytes.
MaxValueSize = 4294967295
)
const (
maxUint = ^uint(0)
minUint = 0
maxInt = int(^uint(0) >> 1)
minInt = -maxInt - 1
)
const bucketHeaderSize = int(unsafe.Sizeof(bucket{}))
const (
minFillPercent = 0.1
maxFillPercent = 1.0
)
// DefaultFillPercent is the percentage that split pages are filled.
// This value can be changed by setting Bucket.FillPercent.
const DefaultFillPercent = 0.5
// Bucket represents a collection of key/value pairs inside the database.
type Bucket struct {
*bucket
tx *Tx // the associated transaction
buckets map[string]*Bucket // subbucket cache
page *page // inline page reference
rootNode *node // materialized node for the root page.
nodes map[pgid]*node // node cache
// Sets the threshold for filling nodes when they split. By default,
// the bucket will fill to 50% but it can be useful to increase this
// amount if you know that your write workloads are mostly append-only.
//
// This is non-persisted across transactions so it must be set in every Tx.
FillPercent float64
}
// bucket represents the on-file representation of a bucket.
// This is stored as the "value" of a bucket key. If the bucket is small enough,
// then its root page can be stored inline in the "value", after the bucket
// header. In the case of inline buckets, the "root" will be 0.
type bucket struct {
root pgid // page id of the bucket's root-level page
sequence uint64 // monotonically incrementing, used by NextSequence()
}
// newBucket returns a new bucket associated with a transaction.
func newBucket(tx *Tx) Bucket {
var b = Bucket{tx: tx, FillPercent: DefaultFillPercent}
if tx.writable {
b.buckets = make(map[string]*Bucket)
b.nodes = make(map[pgid]*node)
}
return b
}
// Tx returns the tx of the bucket.
func (b *Bucket) Tx() *Tx {
return b.tx
}
// Root returns the root of the bucket.
func (b *Bucket) Root() pgid {
return b.root
}
// Writable returns whether the bucket is writable.
func (b *Bucket) Writable() bool {
return b.tx.writable
}
// Cursor creates a cursor associated with the bucket.
// The cursor is only valid as long as the transaction is open.
// Do not use a cursor after the transaction is closed.
func (b *Bucket) Cursor() *Cursor {
// Update transaction statistics.
b.tx.stats.CursorCount++
// Allocate and return a cursor.
return &Cursor{
bucket: b,
stack: make([]elemRef, 0),
}
}
// Bucket retrieves a nested bucket by name.
// Returns nil if the bucket does not exist.
func (b *Bucket) Bucket(name []byte) *Bucket {
if b.buckets != nil {
if child := b.buckets[string(name)]; child != nil {
return child
}
}
// Move cursor to key.
c := b.Cursor()
k, v, flags := c.seek(name)
// Return nil if the key doesn't exist or it is not a bucket.
if !bytes.Equal(name, k) || (flags&bucketLeafFlag) == 0 {
return nil
}
// Otherwise create a bucket and cache it.
var child = b.openBucket(v)
if b.buckets != nil {
b.buckets[string(name)] = child
}
return child
}
// Helper method that re-interprets a sub-bucket value
// from a parent into a Bucket
func (b *Bucket) openBucket(value []byte) *Bucket {
var child = newBucket(b.tx)
// If this is a writable transaction then we need to copy the bucket entry.
// Read-only transactions can point directly at the mmap entry.
if b.tx.writable {
child.bucket = &bucket{}
*child.bucket = *(*bucket)(unsafe.Pointer(&value[0]))
} else {
child.bucket = (*bucket)(unsafe.Pointer(&value[0]))
}
// Save a reference to the inline page if the bucket is inline.
if child.root == 0 {
child.page = (*page)(unsafe.Pointer(&value[bucketHeaderSize]))
}
return &child
}
// CreateBucket creates a new bucket at the given key and returns the new bucket.
// Returns an error if the key already exists, if the bucket name is blank, or if the bucket name is too long.
func (b *Bucket) CreateBucket(key []byte) (*Bucket, error) {
if b.tx.db == nil {
return nil, ErrTxClosed
} else if !b.tx.writable {
return nil, ErrTxNotWritable
} else if len(key) == 0 {
return nil, ErrBucketNameRequired
}
// Move cursor to correct position.
c := b.Cursor()
k, _, flags := c.seek(key)
// Return an error if there is an existing key.
if bytes.Equal(key, k) {
if (flags & bucketLeafFlag) != 0 {
return nil, ErrBucketExists
} else {
return nil, ErrIncompatibleValue
}
}
// Create empty, inline bucket.
var bucket = Bucket{
bucket: &bucket{},
rootNode: &node{isLeaf: true},
FillPercent: DefaultFillPercent,
}
var value = bucket.write()
// Insert into node.
key = cloneBytes(key)
c.node().put(key, key, value, 0, bucketLeafFlag)
// Since subbuckets are not allowed on inline buckets, we need to
// dereference the inline page, if it exists. This will cause the bucket
// to be treated as a regular, non-inline bucket for the rest of the tx.
b.page = nil
return b.Bucket(key), nil
}
// CreateBucketIfNotExists creates a new bucket if it doesn't already exist and returns a reference to it.
// Returns an error if the bucket name is blank, or if the bucket name is too long.
func (b *Bucket) CreateBucketIfNotExists(key []byte) (*Bucket, error) {
child, err := b.CreateBucket(key)
if err == ErrBucketExists {
return b.Bucket(key), nil
} else if err != nil {
return nil, err
}
return child, nil
}
// DeleteBucket deletes a bucket at the given key.
// Returns an error if the bucket does not exists, or if the key represents a non-bucket value.
func (b *Bucket) DeleteBucket(key []byte) error {
if b.tx.db == nil {
return ErrTxClosed
} else if !b.Writable() {
return ErrTxNotWritable
}
// Move cursor to correct position.
c := b.Cursor()
k, _, flags := c.seek(key)
// Return an error if bucket doesn't exist or is not a bucket.
if !bytes.Equal(key, k) {
return ErrBucketNotFound
} else if (flags & bucketLeafFlag) == 0 {
return ErrIncompatibleValue
}
// Recursively delete all child buckets.
child := b.Bucket(key)
err := child.ForEach(func(k, v []byte) error {
if v == nil {
if err := child.DeleteBucket(k); err != nil {
return fmt.Errorf("delete bucket: %s", err)
}
}
return nil
})
if err != nil {
return err
}
// Remove cached copy.
delete(b.buckets, string(key))
// Release all bucket pages to freelist.
child.nodes = nil
child.rootNode = nil
child.free()
// Delete the node if we have a matching key.
c.node().del(key)
return nil
}
// Get retrieves the value for a key in the bucket.
// Returns a nil value if the key does not exist or if the key is a nested bucket.
// The returned value is only valid for the life of the transaction.
func (b *Bucket) Get(key []byte) []byte {
k, v, flags := b.Cursor().seek(key)
// Return nil if this is a bucket.
if (flags & bucketLeafFlag) != 0 {
return nil
}
// If our target node isn't the same key as what's passed in then return nil.
if !bytes.Equal(key, k) {
return nil
}
return v
}
// Put sets the value for a key in the bucket.
// If the key exist then its previous value will be overwritten.
// Returns an error if the bucket was created from a read-only transaction, if the key is blank, if the key is too large, or if the value is too large.
func (b *Bucket) Put(key []byte, value []byte) error {
if b.tx.db == nil {
return ErrTxClosed
} else if !b.Writable() {
return ErrTxNotWritable
} else if len(key) == 0 {
return ErrKeyRequired
} else if len(key) > MaxKeySize {
return ErrKeyTooLarge
} else if int64(len(value)) > MaxValueSize {
return ErrValueTooLarge
}
// Move cursor to correct position.
c := b.Cursor()
k, _, flags := c.seek(key)
// Return an error if there is an existing key with a bucket value.
if bytes.Equal(key, k) && (flags&bucketLeafFlag) != 0 {
return ErrIncompatibleValue
}
// Insert into node.
key = cloneBytes(key)
c.node().put(key, key, value, 0, 0)
return nil
}
// Delete removes a key from the bucket.
// If the key does not exist then nothing is done and a nil error is returned.
// Returns an error if the bucket was created from a read-only transaction.
func (b *Bucket) Delete(key []byte) error {
if b.tx.db == nil {
return ErrTxClosed
} else if !b.Writable() {
return ErrTxNotWritable
}
// Move cursor to correct position.
c := b.Cursor()
_, _, flags := c.seek(key)
// Return an error if there is already existing bucket value.
if (flags & bucketLeafFlag) != 0 {
return ErrIncompatibleValue
}
// Delete the node if we have a matching key.
c.node().del(key)
return nil
}
// NextSequence returns an autoincrementing integer for the bucket.
func (b *Bucket) NextSequence() (uint64, error) {
if b.tx.db == nil {
return 0, ErrTxClosed
} else if !b.Writable() {
return 0, ErrTxNotWritable
}
// Materialize the root node if it hasn't been already so that the
// bucket will be saved during commit.
if b.rootNode == nil {
_ = b.node(b.root, nil)
}
// Increment and return the sequence.
b.bucket.sequence++
return b.bucket.sequence, nil
}
// ForEach executes a function for each key/value pair in a bucket.
// If the provided function returns an error then the iteration is stopped and
// the error is returned to the caller.
func (b *Bucket) ForEach(fn func(k, v []byte) error) error {
if b.tx.db == nil {
return ErrTxClosed
}
c := b.Cursor()
for k, v := c.First(); k != nil; k, v = c.Next() {
if err := fn(k, v); err != nil {
return err
}
}
return nil
}
// Stat returns stats on a bucket.
func (b *Bucket) Stats() BucketStats {
var s, subStats BucketStats
pageSize := b.tx.db.pageSize
s.BucketN += 1
if b.root == 0 {
s.InlineBucketN += 1
}
b.forEachPage(func(p *page, depth int) {
if (p.flags & leafPageFlag) != 0 {
s.KeyN += int(p.count)
// used totals the used bytes for the page
used := pageHeaderSize
if p.count != 0 {
// If page has any elements, add all element headers.
used += leafPageElementSize * int(p.count-1)
// Add all element key, value sizes.
// The computation takes advantage of the fact that the position
// of the last element's key/value equals to the total of the sizes
// of all previous elements' keys and values.
// It also includes the last element's header.
lastElement := p.leafPageElement(p.count - 1)
used += int(lastElement.pos + lastElement.ksize + lastElement.vsize)
}
if b.root == 0 {
// For inlined bucket just update the inline stats
s.InlineBucketInuse += used
} else {
// For non-inlined bucket update all the leaf stats
s.LeafPageN++
s.LeafInuse += used
s.LeafOverflowN += int(p.overflow)
// Collect stats from sub-buckets.
// Do that by iterating over all element headers
// looking for the ones with the bucketLeafFlag.
for i := uint16(0); i < p.count; i++ {
e := p.leafPageElement(i)
if (e.flags & bucketLeafFlag) != 0 {
// For any bucket element, open the element value
// and recursively call Stats on the contained bucket.
subStats.Add(b.openBucket(e.value()).Stats())
}
}
}
} else if (p.flags & branchPageFlag) != 0 {
s.BranchPageN++
lastElement := p.branchPageElement(p.count - 1)
// used totals the used bytes for the page
// Add header and all element headers.
used := pageHeaderSize + (branchPageElementSize * int(p.count-1))
// Add size of all keys and values.
// Again, use the fact that last element's position equals to
// the total of key, value sizes of all previous elements.
used += int(lastElement.pos + lastElement.ksize)
s.BranchInuse += used
s.BranchOverflowN += int(p.overflow)
}
// Keep track of maximum page depth.
if depth+1 > s.Depth {
s.Depth = (depth + 1)
}
})
// Alloc stats can be computed from page counts and pageSize.
s.BranchAlloc = (s.BranchPageN + s.BranchOverflowN) * pageSize
s.LeafAlloc = (s.LeafPageN + s.LeafOverflowN) * pageSize
// Add the max depth of sub-buckets to get total nested depth.
s.Depth += subStats.Depth
// Add the stats for all sub-buckets
s.Add(subStats)
return s
}
// forEachPage iterates over every page in a bucket, including inline pages.
func (b *Bucket) forEachPage(fn func(*page, int)) {
// If we have an inline page then just use that.
if b.page != nil {
fn(b.page, 0)
return
}
// Otherwise traverse the page hierarchy.
b.tx.forEachPage(b.root, 0, fn)
}
// forEachPageNode iterates over every page (or node) in a bucket.
// This also includes inline pages.
func (b *Bucket) forEachPageNode(fn func(*page, *node, int)) {
// If we have an inline page or root node then just use that.
if b.page != nil {
fn(b.page, nil, 0)
return
}
b._forEachPageNode(b.root, 0, fn)
}
func (b *Bucket) _forEachPageNode(pgid pgid, depth int, fn func(*page, *node, int)) {
var p, n = b.pageNode(pgid)
// Execute function.
fn(p, n, depth)
// Recursively loop over children.
if p != nil {
if (p.flags & branchPageFlag) != 0 {
for i := 0; i < int(p.count); i++ {
elem := p.branchPageElement(uint16(i))
b._forEachPageNode(elem.pgid, depth+1, fn)
}
}
} else {
if !n.isLeaf {
for _, inode := range n.inodes {
b._forEachPageNode(inode.pgid, depth+1, fn)
}
}
}
}
// spill writes all the nodes for this bucket to dirty pages.
func (b *Bucket) spill() error {
// Spill all child buckets first.
for name, child := range b.buckets {
// If the child bucket is small enough and it has no child buckets then
// write it inline into the parent bucket's page. Otherwise spill it
// like a normal bucket and make the parent value a pointer to the page.
var value []byte
if child.inlineable() {
child.free()
value = child.write()
} else {
if err := child.spill(); err != nil {
return err
}
// Update the child bucket header in this bucket.
value = make([]byte, unsafe.Sizeof(bucket{}))
var bucket = (*bucket)(unsafe.Pointer(&value[0]))
*bucket = *child.bucket
}
// Skip writing the bucket if there are no materialized nodes.
if child.rootNode == nil {
continue
}
// Update parent node.
var c = b.Cursor()
k, _, flags := c.seek([]byte(name))
if !bytes.Equal([]byte(name), k) {
panic(fmt.Sprintf("misplaced bucket header: %x -> %x", []byte(name), k))
}
if flags&bucketLeafFlag == 0 {
panic(fmt.Sprintf("unexpected bucket header flag: %x", flags))
}
c.node().put([]byte(name), []byte(name), value, 0, bucketLeafFlag)
}
// Ignore if there's not a materialized root node.
if b.rootNode == nil {
return nil
}
// Spill nodes.
if err := b.rootNode.spill(); err != nil {
return err
}
b.rootNode = b.rootNode.root()
// Update the root node for this bucket.
if b.rootNode.pgid >= b.tx.meta.pgid {
panic(fmt.Sprintf("pgid (%d) above high water mark (%d)", b.rootNode.pgid, b.tx.meta.pgid))
}
b.root = b.rootNode.pgid
return nil
}
// inlineable returns true if a bucket is small enough to be written inline
// and if it contains no subbuckets. Otherwise returns false.
func (b *Bucket) inlineable() bool {
var n = b.rootNode
// Bucket must only contain a single leaf node.
if n == nil || !n.isLeaf {
return false
}
// Bucket is not inlineable if it contains subbuckets or if it goes beyond
// our threshold for inline bucket size.
var size = pageHeaderSize
for _, inode := range n.inodes {
size += leafPageElementSize + len(inode.key) + len(inode.value)
if inode.flags&bucketLeafFlag != 0 {
return false
} else if size > b.maxInlineBucketSize() {
return false
}
}
return true
}
// Returns the maximum total size of a bucket to make it a candidate for inlining.
func (b *Bucket) maxInlineBucketSize() int {
return b.tx.db.pageSize / 4
}
// write allocates and writes a bucket to a byte slice.
func (b *Bucket) write() []byte {
// Allocate the appropriate size.
var n = b.rootNode
var value = make([]byte, bucketHeaderSize+n.size())
// Write a bucket header.
var bucket = (*bucket)(unsafe.Pointer(&value[0]))
*bucket = *b.bucket
// Convert byte slice to a fake page and write the root node.
var p = (*page)(unsafe.Pointer(&value[bucketHeaderSize]))
n.write(p)
return value
}
// rebalance attempts to balance all nodes.
func (b *Bucket) rebalance() {
for _, n := range b.nodes {
n.rebalance()
}
for _, child := range b.buckets {
child.rebalance()
}
}
// node creates a node from a page and associates it with a given parent.
func (b *Bucket) node(pgid pgid, parent *node) *node {
_assert(b.nodes != nil, "nodes map expected")
// Retrieve node if it's already been created.
if n := b.nodes[pgid]; n != nil {
return n
}
// Otherwise create a node and cache it.
n := &node{bucket: b, parent: parent}
if parent == nil {
b.rootNode = n
} else {
parent.children = append(parent.children, n)
}
// Use the inline page if this is an inline bucket.
var p = b.page
if p == nil {
p = b.tx.page(pgid)
}
// Read the page into the node and cache it.
n.read(p)
b.nodes[pgid] = n
// Update statistics.
b.tx.stats.NodeCount++
return n
}
// free recursively frees all pages in the bucket.
func (b *Bucket) free() {
if b.root == 0 {
return
}
var tx = b.tx
b.forEachPageNode(func(p *page, n *node, _ int) {
if p != nil {
tx.db.freelist.free(tx.meta.txid, p)
} else {
n.free()
}
})
b.root = 0
}
// dereference removes all references to the old mmap.
func (b *Bucket) dereference() {
if b.rootNode != nil {
b.rootNode.root().dereference()
}
for _, child := range b.buckets {
child.dereference()
}
}
// pageNode returns the in-memory node, if it exists.
// Otherwise returns the underlying page.
func (b *Bucket) pageNode(id pgid) (*page, *node) {
// Inline buckets have a fake page embedded in their value so treat them
// differently. We'll return the rootNode (if available) or the fake page.
if b.root == 0 {
if id != 0 {
panic(fmt.Sprintf("inline bucket non-zero page access(2): %d != 0", id))
}
if b.rootNode != nil {
return nil, b.rootNode
}
return b.page, nil
}
// Check the node cache for non-inline buckets.
if b.nodes != nil {
if n := b.nodes[id]; n != nil {
return nil, n
}
}
// Finally lookup the page from the transaction if no node is materialized.
return b.tx.page(id), nil
}
// BucketStats records statistics about resources used by a bucket.
type BucketStats struct {
// Page count statistics.
BranchPageN int // number of logical branch pages
BranchOverflowN int // number of physical branch overflow pages
LeafPageN int // number of logical leaf pages
LeafOverflowN int // number of physical leaf overflow pages
// Tree statistics.
KeyN int // number of keys/value pairs
Depth int // number of levels in B+tree
// Page size utilization.
BranchAlloc int // bytes allocated for physical branch pages
BranchInuse int // bytes actually used for branch data
LeafAlloc int // bytes allocated for physical leaf pages
LeafInuse int // bytes actually used for leaf data
// Bucket statistics
BucketN int // total number of buckets including the top bucket
InlineBucketN int // total number on inlined buckets
InlineBucketInuse int // bytes used for inlined buckets (also accounted for in LeafInuse)
}
func (s *BucketStats) Add(other BucketStats) {
s.BranchPageN += other.BranchPageN
s.BranchOverflowN += other.BranchOverflowN
s.LeafPageN += other.LeafPageN
s.LeafOverflowN += other.LeafOverflowN
s.KeyN += other.KeyN
if s.Depth < other.Depth {
s.Depth = other.Depth
}
s.BranchAlloc += other.BranchAlloc
s.BranchInuse += other.BranchInuse
s.LeafAlloc += other.LeafAlloc
s.LeafInuse += other.LeafInuse
s.BucketN += other.BucketN
s.InlineBucketN += other.InlineBucketN
s.InlineBucketInuse += other.InlineBucketInuse
}
// cloneBytes returns a copy of a given slice.
func cloneBytes(v []byte) []byte {
var clone = make([]byte, len(v))
copy(clone, v)
return clone
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,145 @@
package main_test
import (
"bytes"
"io/ioutil"
"os"
"strconv"
"testing"
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/boltdb/bolt"
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/boltdb/bolt/cmd/bolt"
)
// Ensure the "info" command can print information about a database.
func TestInfoCommand_Run(t *testing.T) {
db := MustOpen(0666, nil)
db.DB.Close()
defer db.Close()
// Run the info command.
m := NewMain()
if err := m.Run("info", db.Path); err != nil {
t.Fatal(err)
}
}
// Ensure the "stats" command can execute correctly.
func TestStatsCommand_Run(t *testing.T) {
// Ignore
if os.Getpagesize() != 4096 {
t.Skip("system does not use 4KB page size")
}
db := MustOpen(0666, nil)
defer db.Close()
if err := db.Update(func(tx *bolt.Tx) error {
// Create "foo" bucket.
b, err := tx.CreateBucket([]byte("foo"))
if err != nil {
return err
}
for i := 0; i < 10; i++ {
if err := b.Put([]byte(strconv.Itoa(i)), []byte(strconv.Itoa(i))); err != nil {
return err
}
}
// Create "bar" bucket.
b, err = tx.CreateBucket([]byte("bar"))
if err != nil {
return err
}
for i := 0; i < 100; i++ {
if err := b.Put([]byte(strconv.Itoa(i)), []byte(strconv.Itoa(i))); err != nil {
return err
}
}
// Create "baz" bucket.
b, err = tx.CreateBucket([]byte("baz"))
if err != nil {
return err
}
if err := b.Put([]byte("key"), []byte("value")); err != nil {
return err
}
return nil
}); err != nil {
t.Fatal(err)
}
db.DB.Close()
// Generate expected result.
exp := "Aggregate statistics for 3 buckets\n\n" +
"Page count statistics\n" +
"\tNumber of logical branch pages: 0\n" +
"\tNumber of physical branch overflow pages: 0\n" +
"\tNumber of logical leaf pages: 1\n" +
"\tNumber of physical leaf overflow pages: 0\n" +
"Tree statistics\n" +
"\tNumber of keys/value pairs: 111\n" +
"\tNumber of levels in B+tree: 1\n" +
"Page size utilization\n" +
"\tBytes allocated for physical branch pages: 0\n" +
"\tBytes actually used for branch data: 0 (0%)\n" +
"\tBytes allocated for physical leaf pages: 4096\n" +
"\tBytes actually used for leaf data: 1996 (48%)\n" +
"Bucket statistics\n" +
"\tTotal number of buckets: 3\n" +
"\tTotal number on inlined buckets: 2 (66%)\n" +
"\tBytes used for inlined buckets: 236 (11%)\n"
// Run the command.
m := NewMain()
if err := m.Run("stats", db.Path); err != nil {
t.Fatal(err)
} else if m.Stdout.String() != exp {
t.Fatalf("unexpected stdout:\n\n%s", m.Stdout.String())
}
}
// Main represents a test wrapper for main.Main that records output.
type Main struct {
*main.Main
Stdin bytes.Buffer
Stdout bytes.Buffer
Stderr bytes.Buffer
}
// NewMain returns a new instance of Main.
func NewMain() *Main {
m := &Main{Main: main.NewMain()}
m.Main.Stdin = &m.Stdin
m.Main.Stdout = &m.Stdout
m.Main.Stderr = &m.Stderr
return m
}
// MustOpen creates a Bolt database in a temporary location.
func MustOpen(mode os.FileMode, options *bolt.Options) *DB {
// Create temporary path.
f, _ := ioutil.TempFile("", "bolt-")
f.Close()
os.Remove(f.Name())
db, err := bolt.Open(f.Name(), mode, options)
if err != nil {
panic(err.Error())
}
return &DB{DB: db, Path: f.Name()}
}
// DB is a test wrapper for bolt.DB.
type DB struct {
*bolt.DB
Path string
}
// Close closes and removes the database.
func (db *DB) Close() error {
defer os.Remove(db.Path)
return db.DB.Close()
}

384
Godeps/_workspace/src/github.com/boltdb/bolt/cursor.go generated vendored Normal file
View File

@ -0,0 +1,384 @@
package bolt
import (
"bytes"
"fmt"
"sort"
)
// Cursor represents an iterator that can traverse over all key/value pairs in a bucket in sorted order.
// Cursors see nested buckets with value == nil.
// Cursors can be obtained from a transaction and are valid as long as the transaction is open.
//
// Keys and values returned from the cursor are only valid for the life of the transaction.
//
// Changing data while traversing with a cursor may cause it to be invalidated
// and return unexpected keys and/or values. You must reposition your cursor
// after mutating data.
type Cursor struct {
bucket *Bucket
stack []elemRef
}
// Bucket returns the bucket that this cursor was created from.
func (c *Cursor) Bucket() *Bucket {
return c.bucket
}
// First moves the cursor to the first item in the bucket and returns its key and value.
// If the bucket is empty then a nil key and value are returned.
// The returned key and value are only valid for the life of the transaction.
func (c *Cursor) First() (key []byte, value []byte) {
_assert(c.bucket.tx.db != nil, "tx closed")
c.stack = c.stack[:0]
p, n := c.bucket.pageNode(c.bucket.root)
c.stack = append(c.stack, elemRef{page: p, node: n, index: 0})
c.first()
k, v, flags := c.keyValue()
if (flags & uint32(bucketLeafFlag)) != 0 {
return k, nil
}
return k, v
}
// Last moves the cursor to the last item in the bucket and returns its key and value.
// If the bucket is empty then a nil key and value are returned.
// The returned key and value are only valid for the life of the transaction.
func (c *Cursor) Last() (key []byte, value []byte) {
_assert(c.bucket.tx.db != nil, "tx closed")
c.stack = c.stack[:0]
p, n := c.bucket.pageNode(c.bucket.root)
ref := elemRef{page: p, node: n}
ref.index = ref.count() - 1
c.stack = append(c.stack, ref)
c.last()
k, v, flags := c.keyValue()
if (flags & uint32(bucketLeafFlag)) != 0 {
return k, nil
}
return k, v
}
// Next moves the cursor to the next item in the bucket and returns its key and value.
// If the cursor is at the end of the bucket then a nil key and value are returned.
// The returned key and value are only valid for the life of the transaction.
func (c *Cursor) Next() (key []byte, value []byte) {
_assert(c.bucket.tx.db != nil, "tx closed")
k, v, flags := c.next()
if (flags & uint32(bucketLeafFlag)) != 0 {
return k, nil
}
return k, v
}
// Prev moves the cursor to the previous item in the bucket and returns its key and value.
// If the cursor is at the beginning of the bucket then a nil key and value are returned.
// The returned key and value are only valid for the life of the transaction.
func (c *Cursor) Prev() (key []byte, value []byte) {
_assert(c.bucket.tx.db != nil, "tx closed")
// Attempt to move back one element until we're successful.
// Move up the stack as we hit the beginning of each page in our stack.
for i := len(c.stack) - 1; i >= 0; i-- {
elem := &c.stack[i]
if elem.index > 0 {
elem.index--
break
}
c.stack = c.stack[:i]
}
// If we've hit the end then return nil.
if len(c.stack) == 0 {
return nil, nil
}
// Move down the stack to find the last element of the last leaf under this branch.
c.last()
k, v, flags := c.keyValue()
if (flags & uint32(bucketLeafFlag)) != 0 {
return k, nil
}
return k, v
}
// Seek moves the cursor to a given key and returns it.
// If the key does not exist then the next key is used. If no keys
// follow, a nil key is returned.
// The returned key and value are only valid for the life of the transaction.
func (c *Cursor) Seek(seek []byte) (key []byte, value []byte) {
k, v, flags := c.seek(seek)
// If we ended up after the last element of a page then move to the next one.
if ref := &c.stack[len(c.stack)-1]; ref.index >= ref.count() {
k, v, flags = c.next()
}
if k == nil {
return nil, nil
} else if (flags & uint32(bucketLeafFlag)) != 0 {
return k, nil
}
return k, v
}
// Delete removes the current key/value under the cursor from the bucket.
// Delete fails if current key/value is a bucket or if the transaction is not writable.
func (c *Cursor) Delete() error {
if c.bucket.tx.db == nil {
return ErrTxClosed
} else if !c.bucket.Writable() {
return ErrTxNotWritable
}
key, _, flags := c.keyValue()
// Return an error if current value is a bucket.
if (flags & bucketLeafFlag) != 0 {
return ErrIncompatibleValue
}
c.node().del(key)
return nil
}
// seek moves the cursor to a given key and returns it.
// If the key does not exist then the next key is used.
func (c *Cursor) seek(seek []byte) (key []byte, value []byte, flags uint32) {
_assert(c.bucket.tx.db != nil, "tx closed")
// Start from root page/node and traverse to correct page.
c.stack = c.stack[:0]
c.search(seek, c.bucket.root)
ref := &c.stack[len(c.stack)-1]
// If the cursor is pointing to the end of page/node then return nil.
if ref.index >= ref.count() {
return nil, nil, 0
}
// If this is a bucket then return a nil value.
return c.keyValue()
}
// first moves the cursor to the first leaf element under the last page in the stack.
func (c *Cursor) first() {
for {
// Exit when we hit a leaf page.
var ref = &c.stack[len(c.stack)-1]
if ref.isLeaf() {
break
}
// Keep adding pages pointing to the first element to the stack.
var pgid pgid
if ref.node != nil {
pgid = ref.node.inodes[ref.index].pgid
} else {
pgid = ref.page.branchPageElement(uint16(ref.index)).pgid
}
p, n := c.bucket.pageNode(pgid)
c.stack = append(c.stack, elemRef{page: p, node: n, index: 0})
}
}
// last moves the cursor to the last leaf element under the last page in the stack.
func (c *Cursor) last() {
for {
// Exit when we hit a leaf page.
ref := &c.stack[len(c.stack)-1]
if ref.isLeaf() {
break
}
// Keep adding pages pointing to the last element in the stack.
var pgid pgid
if ref.node != nil {
pgid = ref.node.inodes[ref.index].pgid
} else {
pgid = ref.page.branchPageElement(uint16(ref.index)).pgid
}
p, n := c.bucket.pageNode(pgid)
var nextRef = elemRef{page: p, node: n}
nextRef.index = nextRef.count() - 1
c.stack = append(c.stack, nextRef)
}
}
// next moves to the next leaf element and returns the key and value.
// If the cursor is at the last leaf element then it stays there and returns nil.
func (c *Cursor) next() (key []byte, value []byte, flags uint32) {
// Attempt to move over one element until we're successful.
// Move up the stack as we hit the end of each page in our stack.
var i int
for i = len(c.stack) - 1; i >= 0; i-- {
elem := &c.stack[i]
if elem.index < elem.count()-1 {
elem.index++
break
}
}
// If we've hit the root page then stop and return. This will leave the
// cursor on the last element of the last page.
if i == -1 {
return nil, nil, 0
}
// Otherwise start from where we left off in the stack and find the
// first element of the first leaf page.
c.stack = c.stack[:i+1]
c.first()
return c.keyValue()
}
// search recursively performs a binary search against a given page/node until it finds a given key.
func (c *Cursor) search(key []byte, pgid pgid) {
p, n := c.bucket.pageNode(pgid)
if p != nil && (p.flags&(branchPageFlag|leafPageFlag)) == 0 {
panic(fmt.Sprintf("invalid page type: %d: %x", p.id, p.flags))
}
e := elemRef{page: p, node: n}
c.stack = append(c.stack, e)
// If we're on a leaf page/node then find the specific node.
if e.isLeaf() {
c.nsearch(key)
return
}
if n != nil {
c.searchNode(key, n)
return
}
c.searchPage(key, p)
}
func (c *Cursor) searchNode(key []byte, n *node) {
var exact bool
index := sort.Search(len(n.inodes), func(i int) bool {
// TODO(benbjohnson): Optimize this range search. It's a bit hacky right now.
// sort.Search() finds the lowest index where f() != -1 but we need the highest index.
ret := bytes.Compare(n.inodes[i].key, key)
if ret == 0 {
exact = true
}
return ret != -1
})
if !exact && index > 0 {
index--
}
c.stack[len(c.stack)-1].index = index
// Recursively search to the next page.
c.search(key, n.inodes[index].pgid)
}
func (c *Cursor) searchPage(key []byte, p *page) {
// Binary search for the correct range.
inodes := p.branchPageElements()
var exact bool
index := sort.Search(int(p.count), func(i int) bool {
// TODO(benbjohnson): Optimize this range search. It's a bit hacky right now.
// sort.Search() finds the lowest index where f() != -1 but we need the highest index.
ret := bytes.Compare(inodes[i].key(), key)
if ret == 0 {
exact = true
}
return ret != -1
})
if !exact && index > 0 {
index--
}
c.stack[len(c.stack)-1].index = index
// Recursively search to the next page.
c.search(key, inodes[index].pgid)
}
// nsearch searches the leaf node on the top of the stack for a key.
func (c *Cursor) nsearch(key []byte) {
e := &c.stack[len(c.stack)-1]
p, n := e.page, e.node
// If we have a node then search its inodes.
if n != nil {
index := sort.Search(len(n.inodes), func(i int) bool {
return bytes.Compare(n.inodes[i].key, key) != -1
})
e.index = index
return
}
// If we have a page then search its leaf elements.
inodes := p.leafPageElements()
index := sort.Search(int(p.count), func(i int) bool {
return bytes.Compare(inodes[i].key(), key) != -1
})
e.index = index
}
// keyValue returns the key and value of the current leaf element.
func (c *Cursor) keyValue() ([]byte, []byte, uint32) {
ref := &c.stack[len(c.stack)-1]
if ref.count() == 0 || ref.index >= ref.count() {
return nil, nil, 0
}
// Retrieve value from node.
if ref.node != nil {
inode := &ref.node.inodes[ref.index]
return inode.key, inode.value, inode.flags
}
// Or retrieve value from page.
elem := ref.page.leafPageElement(uint16(ref.index))
return elem.key(), elem.value(), elem.flags
}
// node returns the node that the cursor is currently positioned on.
func (c *Cursor) node() *node {
_assert(len(c.stack) > 0, "accessing a node with a zero-length cursor stack")
// If the top of the stack is a leaf node then just return it.
if ref := &c.stack[len(c.stack)-1]; ref.node != nil && ref.isLeaf() {
return ref.node
}
// Start from root and traverse down the hierarchy.
var n = c.stack[0].node
if n == nil {
n = c.bucket.node(c.stack[0].page.id, nil)
}
for _, ref := range c.stack[:len(c.stack)-1] {
_assert(!n.isLeaf, "expected branch node")
n = n.childAt(int(ref.index))
}
_assert(n.isLeaf, "expected leaf node")
return n
}
// elemRef represents a reference to an element on a given page/node.
type elemRef struct {
page *page
node *node
index int
}
// isLeaf returns whether the ref is pointing at a leaf page/node.
func (r *elemRef) isLeaf() bool {
if r.node != nil {
return r.node.isLeaf
}
return (r.page.flags & leafPageFlag) != 0
}
// count returns the number of inodes or page elements.
func (r *elemRef) count() int {
if r.node != nil {
return len(r.node.inodes)
}
return int(r.page.count)
}

View File

@ -0,0 +1,511 @@
package bolt_test
import (
"bytes"
"encoding/binary"
"fmt"
"os"
"sort"
"testing"
"testing/quick"
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/boltdb/bolt"
)
// Ensure that a cursor can return a reference to the bucket that created it.
func TestCursor_Bucket(t *testing.T) {
db := NewTestDB()
defer db.Close()
db.Update(func(tx *bolt.Tx) error {
b, _ := tx.CreateBucket([]byte("widgets"))
c := b.Cursor()
equals(t, b, c.Bucket())
return nil
})
}
// Ensure that a Tx cursor can seek to the appropriate keys.
func TestCursor_Seek(t *testing.T) {
db := NewTestDB()
defer db.Close()
db.Update(func(tx *bolt.Tx) error {
b, err := tx.CreateBucket([]byte("widgets"))
ok(t, err)
ok(t, b.Put([]byte("foo"), []byte("0001")))
ok(t, b.Put([]byte("bar"), []byte("0002")))
ok(t, b.Put([]byte("baz"), []byte("0003")))
_, err = b.CreateBucket([]byte("bkt"))
ok(t, err)
return nil
})
db.View(func(tx *bolt.Tx) error {
c := tx.Bucket([]byte("widgets")).Cursor()
// Exact match should go to the key.
k, v := c.Seek([]byte("bar"))
equals(t, []byte("bar"), k)
equals(t, []byte("0002"), v)
// Inexact match should go to the next key.
k, v = c.Seek([]byte("bas"))
equals(t, []byte("baz"), k)
equals(t, []byte("0003"), v)
// Low key should go to the first key.
k, v = c.Seek([]byte(""))
equals(t, []byte("bar"), k)
equals(t, []byte("0002"), v)
// High key should return no key.
k, v = c.Seek([]byte("zzz"))
assert(t, k == nil, "")
assert(t, v == nil, "")
// Buckets should return their key but no value.
k, v = c.Seek([]byte("bkt"))
equals(t, []byte("bkt"), k)
assert(t, v == nil, "")
return nil
})
}
func TestCursor_Delete(t *testing.T) {
db := NewTestDB()
defer db.Close()
var count = 1000
// Insert every other key between 0 and $count.
db.Update(func(tx *bolt.Tx) error {
b, _ := tx.CreateBucket([]byte("widgets"))
for i := 0; i < count; i += 1 {
k := make([]byte, 8)
binary.BigEndian.PutUint64(k, uint64(i))
b.Put(k, make([]byte, 100))
}
b.CreateBucket([]byte("sub"))
return nil
})
db.Update(func(tx *bolt.Tx) error {
c := tx.Bucket([]byte("widgets")).Cursor()
bound := make([]byte, 8)
binary.BigEndian.PutUint64(bound, uint64(count/2))
for key, _ := c.First(); bytes.Compare(key, bound) < 0; key, _ = c.Next() {
if err := c.Delete(); err != nil {
return err
}
}
c.Seek([]byte("sub"))
err := c.Delete()
equals(t, err, bolt.ErrIncompatibleValue)
return nil
})
db.View(func(tx *bolt.Tx) error {
b := tx.Bucket([]byte("widgets"))
equals(t, b.Stats().KeyN, count/2+1)
return nil
})
}
// Ensure that a Tx cursor can seek to the appropriate keys when there are a
// large number of keys. This test also checks that seek will always move
// forward to the next key.
//
// Related: https://github.com/boltdb/bolt/pull/187
func TestCursor_Seek_Large(t *testing.T) {
db := NewTestDB()
defer db.Close()
var count = 10000
// Insert every other key between 0 and $count.
db.Update(func(tx *bolt.Tx) error {
b, _ := tx.CreateBucket([]byte("widgets"))
for i := 0; i < count; i += 100 {
for j := i; j < i+100; j += 2 {
k := make([]byte, 8)
binary.BigEndian.PutUint64(k, uint64(j))
b.Put(k, make([]byte, 100))
}
}
return nil
})
db.View(func(tx *bolt.Tx) error {
c := tx.Bucket([]byte("widgets")).Cursor()
for i := 0; i < count; i++ {
seek := make([]byte, 8)
binary.BigEndian.PutUint64(seek, uint64(i))
k, _ := c.Seek(seek)
// The last seek is beyond the end of the the range so
// it should return nil.
if i == count-1 {
assert(t, k == nil, "")
continue
}
// Otherwise we should seek to the exact key or the next key.
num := binary.BigEndian.Uint64(k)
if i%2 == 0 {
equals(t, uint64(i), num)
} else {
equals(t, uint64(i+1), num)
}
}
return nil
})
}
// Ensure that a cursor can iterate over an empty bucket without error.
func TestCursor_EmptyBucket(t *testing.T) {
db := NewTestDB()
defer db.Close()
db.Update(func(tx *bolt.Tx) error {
_, err := tx.CreateBucket([]byte("widgets"))
return err
})
db.View(func(tx *bolt.Tx) error {
c := tx.Bucket([]byte("widgets")).Cursor()
k, v := c.First()
assert(t, k == nil, "")
assert(t, v == nil, "")
return nil
})
}
// Ensure that a Tx cursor can reverse iterate over an empty bucket without error.
func TestCursor_EmptyBucketReverse(t *testing.T) {
db := NewTestDB()
defer db.Close()
db.Update(func(tx *bolt.Tx) error {
_, err := tx.CreateBucket([]byte("widgets"))
return err
})
db.View(func(tx *bolt.Tx) error {
c := tx.Bucket([]byte("widgets")).Cursor()
k, v := c.Last()
assert(t, k == nil, "")
assert(t, v == nil, "")
return nil
})
}
// Ensure that a Tx cursor can iterate over a single root with a couple elements.
func TestCursor_Iterate_Leaf(t *testing.T) {
db := NewTestDB()
defer db.Close()
db.Update(func(tx *bolt.Tx) error {
tx.CreateBucket([]byte("widgets"))
tx.Bucket([]byte("widgets")).Put([]byte("baz"), []byte{})
tx.Bucket([]byte("widgets")).Put([]byte("foo"), []byte{0})
tx.Bucket([]byte("widgets")).Put([]byte("bar"), []byte{1})
return nil
})
tx, _ := db.Begin(false)
c := tx.Bucket([]byte("widgets")).Cursor()
k, v := c.First()
equals(t, string(k), "bar")
equals(t, v, []byte{1})
k, v = c.Next()
equals(t, string(k), "baz")
equals(t, v, []byte{})
k, v = c.Next()
equals(t, string(k), "foo")
equals(t, v, []byte{0})
k, v = c.Next()
assert(t, k == nil, "")
assert(t, v == nil, "")
k, v = c.Next()
assert(t, k == nil, "")
assert(t, v == nil, "")
tx.Rollback()
}
// Ensure that a Tx cursor can iterate in reverse over a single root with a couple elements.
func TestCursor_LeafRootReverse(t *testing.T) {
db := NewTestDB()
defer db.Close()
db.Update(func(tx *bolt.Tx) error {
tx.CreateBucket([]byte("widgets"))
tx.Bucket([]byte("widgets")).Put([]byte("baz"), []byte{})
tx.Bucket([]byte("widgets")).Put([]byte("foo"), []byte{0})
tx.Bucket([]byte("widgets")).Put([]byte("bar"), []byte{1})
return nil
})
tx, _ := db.Begin(false)
c := tx.Bucket([]byte("widgets")).Cursor()
k, v := c.Last()
equals(t, string(k), "foo")
equals(t, v, []byte{0})
k, v = c.Prev()
equals(t, string(k), "baz")
equals(t, v, []byte{})
k, v = c.Prev()
equals(t, string(k), "bar")
equals(t, v, []byte{1})
k, v = c.Prev()
assert(t, k == nil, "")
assert(t, v == nil, "")
k, v = c.Prev()
assert(t, k == nil, "")
assert(t, v == nil, "")
tx.Rollback()
}
// Ensure that a Tx cursor can restart from the beginning.
func TestCursor_Restart(t *testing.T) {
db := NewTestDB()
defer db.Close()
db.Update(func(tx *bolt.Tx) error {
tx.CreateBucket([]byte("widgets"))
tx.Bucket([]byte("widgets")).Put([]byte("bar"), []byte{})
tx.Bucket([]byte("widgets")).Put([]byte("foo"), []byte{})
return nil
})
tx, _ := db.Begin(false)
c := tx.Bucket([]byte("widgets")).Cursor()
k, _ := c.First()
equals(t, string(k), "bar")
k, _ = c.Next()
equals(t, string(k), "foo")
k, _ = c.First()
equals(t, string(k), "bar")
k, _ = c.Next()
equals(t, string(k), "foo")
tx.Rollback()
}
// Ensure that a Tx can iterate over all elements in a bucket.
func TestCursor_QuickCheck(t *testing.T) {
f := func(items testdata) bool {
db := NewTestDB()
defer db.Close()
// Bulk insert all values.
tx, _ := db.Begin(true)
tx.CreateBucket([]byte("widgets"))
b := tx.Bucket([]byte("widgets"))
for _, item := range items {
ok(t, b.Put(item.Key, item.Value))
}
ok(t, tx.Commit())
// Sort test data.
sort.Sort(items)
// Iterate over all items and check consistency.
var index = 0
tx, _ = db.Begin(false)
c := tx.Bucket([]byte("widgets")).Cursor()
for k, v := c.First(); k != nil && index < len(items); k, v = c.Next() {
equals(t, k, items[index].Key)
equals(t, v, items[index].Value)
index++
}
equals(t, len(items), index)
tx.Rollback()
return true
}
if err := quick.Check(f, qconfig()); err != nil {
t.Error(err)
}
}
// Ensure that a transaction can iterate over all elements in a bucket in reverse.
func TestCursor_QuickCheck_Reverse(t *testing.T) {
f := func(items testdata) bool {
db := NewTestDB()
defer db.Close()
// Bulk insert all values.
tx, _ := db.Begin(true)
tx.CreateBucket([]byte("widgets"))
b := tx.Bucket([]byte("widgets"))
for _, item := range items {
ok(t, b.Put(item.Key, item.Value))
}
ok(t, tx.Commit())
// Sort test data.
sort.Sort(revtestdata(items))
// Iterate over all items and check consistency.
var index = 0
tx, _ = db.Begin(false)
c := tx.Bucket([]byte("widgets")).Cursor()
for k, v := c.Last(); k != nil && index < len(items); k, v = c.Prev() {
equals(t, k, items[index].Key)
equals(t, v, items[index].Value)
index++
}
equals(t, len(items), index)
tx.Rollback()
return true
}
if err := quick.Check(f, qconfig()); err != nil {
t.Error(err)
}
}
// Ensure that a Tx cursor can iterate over subbuckets.
func TestCursor_QuickCheck_BucketsOnly(t *testing.T) {
db := NewTestDB()
defer db.Close()
db.Update(func(tx *bolt.Tx) error {
b, err := tx.CreateBucket([]byte("widgets"))
ok(t, err)
_, err = b.CreateBucket([]byte("foo"))
ok(t, err)
_, err = b.CreateBucket([]byte("bar"))
ok(t, err)
_, err = b.CreateBucket([]byte("baz"))
ok(t, err)
return nil
})
db.View(func(tx *bolt.Tx) error {
var names []string
c := tx.Bucket([]byte("widgets")).Cursor()
for k, v := c.First(); k != nil; k, v = c.Next() {
names = append(names, string(k))
assert(t, v == nil, "")
}
equals(t, names, []string{"bar", "baz", "foo"})
return nil
})
}
// Ensure that a Tx cursor can reverse iterate over subbuckets.
func TestCursor_QuickCheck_BucketsOnly_Reverse(t *testing.T) {
db := NewTestDB()
defer db.Close()
db.Update(func(tx *bolt.Tx) error {
b, err := tx.CreateBucket([]byte("widgets"))
ok(t, err)
_, err = b.CreateBucket([]byte("foo"))
ok(t, err)
_, err = b.CreateBucket([]byte("bar"))
ok(t, err)
_, err = b.CreateBucket([]byte("baz"))
ok(t, err)
return nil
})
db.View(func(tx *bolt.Tx) error {
var names []string
c := tx.Bucket([]byte("widgets")).Cursor()
for k, v := c.Last(); k != nil; k, v = c.Prev() {
names = append(names, string(k))
assert(t, v == nil, "")
}
equals(t, names, []string{"foo", "baz", "bar"})
return nil
})
}
func ExampleCursor() {
// Open the database.
db, _ := bolt.Open(tempfile(), 0666, nil)
defer os.Remove(db.Path())
defer db.Close()
// Start a read-write transaction.
db.Update(func(tx *bolt.Tx) error {
// Create a new bucket.
tx.CreateBucket([]byte("animals"))
// Insert data into a bucket.
b := tx.Bucket([]byte("animals"))
b.Put([]byte("dog"), []byte("fun"))
b.Put([]byte("cat"), []byte("lame"))
b.Put([]byte("liger"), []byte("awesome"))
// Create a cursor for iteration.
c := b.Cursor()
// Iterate over items in sorted key order. This starts from the
// first key/value pair and updates the k/v variables to the
// next key/value on each iteration.
//
// The loop finishes at the end of the cursor when a nil key is returned.
for k, v := c.First(); k != nil; k, v = c.Next() {
fmt.Printf("A %s is %s.\n", k, v)
}
return nil
})
// Output:
// A cat is lame.
// A dog is fun.
// A liger is awesome.
}
func ExampleCursor_reverse() {
// Open the database.
db, _ := bolt.Open(tempfile(), 0666, nil)
defer os.Remove(db.Path())
defer db.Close()
// Start a read-write transaction.
db.Update(func(tx *bolt.Tx) error {
// Create a new bucket.
tx.CreateBucket([]byte("animals"))
// Insert data into a bucket.
b := tx.Bucket([]byte("animals"))
b.Put([]byte("dog"), []byte("fun"))
b.Put([]byte("cat"), []byte("lame"))
b.Put([]byte("liger"), []byte("awesome"))
// Create a cursor for iteration.
c := b.Cursor()
// Iterate over items in reverse sorted key order. This starts
// from the last key/value pair and updates the k/v variables to
// the previous key/value on each iteration.
//
// The loop finishes at the beginning of the cursor when a nil key
// is returned.
for k, v := c.Last(); k != nil; k, v = c.Prev() {
fmt.Printf("A %s is %s.\n", k, v)
}
return nil
})
// Output:
// A liger is awesome.
// A dog is fun.
// A cat is lame.
}

792
Godeps/_workspace/src/github.com/boltdb/bolt/db.go generated vendored Normal file
View File

@ -0,0 +1,792 @@
package bolt
import (
"fmt"
"hash/fnv"
"os"
"runtime"
"runtime/debug"
"strings"
"sync"
"time"
"unsafe"
)
// The largest step that can be taken when remapping the mmap.
const maxMmapStep = 1 << 30 // 1GB
// The data file format version.
const version = 2
// Represents a marker value to indicate that a file is a Bolt DB.
const magic uint32 = 0xED0CDAED
// IgnoreNoSync specifies whether the NoSync field of a DB is ignored when
// syncing changes to a file. This is required as some operating systems,
// such as OpenBSD, do not have a unified buffer cache (UBC) and writes
// must be synchronzied using the msync(2) syscall.
const IgnoreNoSync = runtime.GOOS == "openbsd"
// Default values if not set in a DB instance.
const (
DefaultMaxBatchSize int = 1000
DefaultMaxBatchDelay = 10 * time.Millisecond
)
// DB represents a collection of buckets persisted to a file on disk.
// All data access is performed through transactions which can be obtained through the DB.
// All the functions on DB will return a ErrDatabaseNotOpen if accessed before Open() is called.
type DB struct {
// When enabled, the database will perform a Check() after every commit.
// A panic is issued if the database is in an inconsistent state. This
// flag has a large performance impact so it should only be used for
// debugging purposes.
StrictMode bool
// Setting the NoSync flag will cause the database to skip fsync()
// calls after each commit. This can be useful when bulk loading data
// into a database and you can restart the bulk load in the event of
// a system failure or database corruption. Do not set this flag for
// normal use.
//
// If the package global IgnoreNoSync constant is true, this value is
// ignored. See the comment on that constant for more details.
//
// THIS IS UNSAFE. PLEASE USE WITH CAUTION.
NoSync bool
// When true, skips the truncate call when growing the database.
// Setting this to true is only safe on non-ext3/ext4 systems.
// Skipping truncation avoids preallocation of hard drive space and
// bypasses a truncate() and fsync() syscall on remapping.
//
// https://github.com/boltdb/bolt/issues/284
NoGrowSync bool
// MaxBatchSize is the maximum size of a batch. Default value is
// copied from DefaultMaxBatchSize in Open.
//
// If <=0, disables batching.
//
// Do not change concurrently with calls to Batch.
MaxBatchSize int
// MaxBatchDelay is the maximum delay before a batch starts.
// Default value is copied from DefaultMaxBatchDelay in Open.
//
// If <=0, effectively disables batching.
//
// Do not change concurrently with calls to Batch.
MaxBatchDelay time.Duration
path string
file *os.File
dataref []byte // mmap'ed readonly, write throws SEGV
data *[maxMapSize]byte
datasz int
meta0 *meta
meta1 *meta
pageSize int
opened bool
rwtx *Tx
txs []*Tx
freelist *freelist
stats Stats
batchMu sync.Mutex
batch *batch
rwlock sync.Mutex // Allows only one writer at a time.
metalock sync.Mutex // Protects meta page access.
mmaplock sync.RWMutex // Protects mmap access during remapping.
statlock sync.RWMutex // Protects stats access.
ops struct {
writeAt func(b []byte, off int64) (n int, err error)
}
// Read only mode.
// When true, Update() and Begin(true) return ErrDatabaseReadOnly immediately.
readOnly bool
}
// Path returns the path to currently open database file.
func (db *DB) Path() string {
return db.path
}
// GoString returns the Go string representation of the database.
func (db *DB) GoString() string {
return fmt.Sprintf("bolt.DB{path:%q}", db.path)
}
// String returns the string representation of the database.
func (db *DB) String() string {
return fmt.Sprintf("DB<%q>", db.path)
}
// Open creates and opens a database at the given path.
// If the file does not exist then it will be created automatically.
// Passing in nil options will cause Bolt to open the database with the default options.
func Open(path string, mode os.FileMode, options *Options) (*DB, error) {
var db = &DB{opened: true}
// Set default options if no options are provided.
if options == nil {
options = DefaultOptions
}
db.NoGrowSync = options.NoGrowSync
// Set default values for later DB operations.
db.MaxBatchSize = DefaultMaxBatchSize
db.MaxBatchDelay = DefaultMaxBatchDelay
flag := os.O_RDWR
if options.ReadOnly {
flag = os.O_RDONLY
db.readOnly = true
}
// Open data file and separate sync handler for metadata writes.
db.path = path
var err error
if db.file, err = os.OpenFile(db.path, flag|os.O_CREATE, mode); err != nil {
_ = db.close()
return nil, err
}
// Lock file so that other processes using Bolt in read-write mode cannot
// use the database at the same time. This would cause corruption since
// the two processes would write meta pages and free pages separately.
// The database file is locked exclusively (only one process can grab the lock)
// if !options.ReadOnly.
// The database file is locked using the shared lock (more than one process may
// hold a lock at the same time) otherwise (options.ReadOnly is set).
if err := flock(db.file, !db.readOnly, options.Timeout); err != nil {
_ = db.close()
return nil, err
}
// Default values for test hooks
db.ops.writeAt = db.file.WriteAt
// Initialize the database if it doesn't exist.
if info, err := db.file.Stat(); err != nil {
return nil, fmt.Errorf("stat error: %s", err)
} else if info.Size() == 0 {
// Initialize new files with meta pages.
if err := db.init(); err != nil {
return nil, err
}
} else {
// Read the first meta page to determine the page size.
var buf [0x1000]byte
if _, err := db.file.ReadAt(buf[:], 0); err == nil {
m := db.pageInBuffer(buf[:], 0).meta()
if err := m.validate(); err != nil {
return nil, fmt.Errorf("meta0 error: %s", err)
}
db.pageSize = int(m.pageSize)
}
}
// Memory map the data file.
if err := db.mmap(0); err != nil {
_ = db.close()
return nil, err
}
// Read in the freelist.
db.freelist = newFreelist()
db.freelist.read(db.page(db.meta().freelist))
// Mark the database as opened and return.
return db, nil
}
// mmap opens the underlying memory-mapped file and initializes the meta references.
// minsz is the minimum size that the new mmap can be.
func (db *DB) mmap(minsz int) error {
db.mmaplock.Lock()
defer db.mmaplock.Unlock()
info, err := db.file.Stat()
if err != nil {
return fmt.Errorf("mmap stat error: %s", err)
} else if int(info.Size()) < db.pageSize*2 {
return fmt.Errorf("file size too small")
}
// Ensure the size is at least the minimum size.
var size = int(info.Size())
if size < minsz {
size = minsz
}
size, err = db.mmapSize(size)
if err != nil {
return err
}
// Dereference all mmap references before unmapping.
if db.rwtx != nil {
db.rwtx.root.dereference()
}
// Unmap existing data before continuing.
if err := db.munmap(); err != nil {
return err
}
// Memory-map the data file as a byte slice.
if err := mmap(db, size); err != nil {
return err
}
// Save references to the meta pages.
db.meta0 = db.page(0).meta()
db.meta1 = db.page(1).meta()
// Validate the meta pages.
if err := db.meta0.validate(); err != nil {
return fmt.Errorf("meta0 error: %s", err)
}
if err := db.meta1.validate(); err != nil {
return fmt.Errorf("meta1 error: %s", err)
}
return nil
}
// munmap unmaps the data file from memory.
func (db *DB) munmap() error {
if err := munmap(db); err != nil {
return fmt.Errorf("unmap error: " + err.Error())
}
return nil
}
// mmapSize determines the appropriate size for the mmap given the current size
// of the database. The minimum size is 1MB and doubles until it reaches 1GB.
// Returns an error if the new mmap size is greater than the max allowed.
func (db *DB) mmapSize(size int) (int, error) {
// Double the size from 32KB until 1GB.
for i := uint(15); i <= 30; i++ {
if size <= 1<<i {
return 1 << i, nil
}
}
// Verify the requested size is not above the maximum allowed.
if size > maxMapSize {
return 0, fmt.Errorf("mmap too large")
}
// If larger than 1GB then grow by 1GB at a time.
sz := int64(size)
if remainder := sz % int64(maxMmapStep); remainder > 0 {
sz += int64(maxMmapStep) - remainder
}
// Ensure that the mmap size is a multiple of the page size.
// This should always be true since we're incrementing in MBs.
pageSize := int64(db.pageSize)
if (sz % pageSize) != 0 {
sz = ((sz / pageSize) + 1) * pageSize
}
// If we've exceeded the max size then only grow up to the max size.
if sz > maxMapSize {
sz = maxMapSize
}
return int(sz), nil
}
// init creates a new database file and initializes its meta pages.
func (db *DB) init() error {
// Set the page size to the OS page size.
db.pageSize = os.Getpagesize()
// Create two meta pages on a buffer.
buf := make([]byte, db.pageSize*4)
for i := 0; i < 2; i++ {
p := db.pageInBuffer(buf[:], pgid(i))
p.id = pgid(i)
p.flags = metaPageFlag
// Initialize the meta page.
m := p.meta()
m.magic = magic
m.version = version
m.pageSize = uint32(db.pageSize)
m.freelist = 2
m.root = bucket{root: 3}
m.pgid = 4
m.txid = txid(i)
}
// Write an empty freelist at page 3.
p := db.pageInBuffer(buf[:], pgid(2))
p.id = pgid(2)
p.flags = freelistPageFlag
p.count = 0
// Write an empty leaf page at page 4.
p = db.pageInBuffer(buf[:], pgid(3))
p.id = pgid(3)
p.flags = leafPageFlag
p.count = 0
// Write the buffer to our data file.
if _, err := db.ops.writeAt(buf, 0); err != nil {
return err
}
if err := fdatasync(db); err != nil {
return err
}
return nil
}
// Close releases all database resources.
// All transactions must be closed before closing the database.
func (db *DB) Close() error {
db.rwlock.Lock()
defer db.rwlock.Unlock()
db.metalock.Lock()
defer db.metalock.Unlock()
db.mmaplock.RLock()
defer db.mmaplock.RUnlock()
return db.close()
}
func (db *DB) close() error {
db.opened = false
db.freelist = nil
db.path = ""
// Clear ops.
db.ops.writeAt = nil
// Close the mmap.
if err := db.munmap(); err != nil {
return err
}
// Close file handles.
if db.file != nil {
// No need to unlock read-only file.
if !db.readOnly {
// Unlock the file.
_ = funlock(db.file)
}
// Close the file descriptor.
if err := db.file.Close(); err != nil {
return fmt.Errorf("db file close: %s", err)
}
db.file = nil
}
return nil
}
// Begin starts a new transaction.
// Multiple read-only transactions can be used concurrently but only one
// write transaction can be used at a time. Starting multiple write transactions
// will cause the calls to block and be serialized until the current write
// transaction finishes.
//
// Transactions should not be depedent on one another. Opening a read
// transaction and a write transaction in the same goroutine can cause the
// writer to deadlock because the database periodically needs to re-mmap itself
// as it grows and it cannot do that while a read transaction is open.
//
// IMPORTANT: You must close read-only transactions after you are finished or
// else the database will not reclaim old pages.
func (db *DB) Begin(writable bool) (*Tx, error) {
if writable {
return db.beginRWTx()
}
return db.beginTx()
}
func (db *DB) beginTx() (*Tx, error) {
// Lock the meta pages while we initialize the transaction. We obtain
// the meta lock before the mmap lock because that's the order that the
// write transaction will obtain them.
db.metalock.Lock()
// Obtain a read-only lock on the mmap. When the mmap is remapped it will
// obtain a write lock so all transactions must finish before it can be
// remapped.
db.mmaplock.RLock()
// Exit if the database is not open yet.
if !db.opened {
db.mmaplock.RUnlock()
db.metalock.Unlock()
return nil, ErrDatabaseNotOpen
}
// Create a transaction associated with the database.
t := &Tx{}
t.init(db)
// Keep track of transaction until it closes.
db.txs = append(db.txs, t)
n := len(db.txs)
// Unlock the meta pages.
db.metalock.Unlock()
// Update the transaction stats.
db.statlock.Lock()
db.stats.TxN++
db.stats.OpenTxN = n
db.statlock.Unlock()
return t, nil
}
func (db *DB) beginRWTx() (*Tx, error) {
// If the database was opened with Options.ReadOnly, return an error.
if db.readOnly {
return nil, ErrDatabaseReadOnly
}
// Obtain writer lock. This is released by the transaction when it closes.
// This enforces only one writer transaction at a time.
db.rwlock.Lock()
// Once we have the writer lock then we can lock the meta pages so that
// we can set up the transaction.
db.metalock.Lock()
defer db.metalock.Unlock()
// Exit if the database is not open yet.
if !db.opened {
db.rwlock.Unlock()
return nil, ErrDatabaseNotOpen
}
// Create a transaction associated with the database.
t := &Tx{writable: true}
t.init(db)
db.rwtx = t
// Free any pages associated with closed read-only transactions.
var minid txid = 0xFFFFFFFFFFFFFFFF
for _, t := range db.txs {
if t.meta.txid < minid {
minid = t.meta.txid
}
}
if minid > 0 {
db.freelist.release(minid - 1)
}
return t, nil
}
// removeTx removes a transaction from the database.
func (db *DB) removeTx(tx *Tx) {
// Release the read lock on the mmap.
db.mmaplock.RUnlock()
// Use the meta lock to restrict access to the DB object.
db.metalock.Lock()
// Remove the transaction.
for i, t := range db.txs {
if t == tx {
db.txs = append(db.txs[:i], db.txs[i+1:]...)
break
}
}
n := len(db.txs)
// Unlock the meta pages.
db.metalock.Unlock()
// Merge statistics.
db.statlock.Lock()
db.stats.OpenTxN = n
db.stats.TxStats.add(&tx.stats)
db.statlock.Unlock()
}
// Update executes a function within the context of a read-write managed transaction.
// If no error is returned from the function then the transaction is committed.
// If an error is returned then the entire transaction is rolled back.
// Any error that is returned from the function or returned from the commit is
// returned from the Update() method.
//
// Attempting to manually commit or rollback within the function will cause a panic.
func (db *DB) Update(fn func(*Tx) error) error {
t, err := db.Begin(true)
if err != nil {
return err
}
// Make sure the transaction rolls back in the event of a panic.
defer func() {
if t.db != nil {
t.rollback()
}
}()
// Mark as a managed tx so that the inner function cannot manually commit.
t.managed = true
// If an error is returned from the function then rollback and return error.
err = fn(t)
t.managed = false
if err != nil {
_ = t.Rollback()
return err
}
return t.Commit()
}
// View executes a function within the context of a managed read-only transaction.
// Any error that is returned from the function is returned from the View() method.
//
// Attempting to manually rollback within the function will cause a panic.
func (db *DB) View(fn func(*Tx) error) error {
t, err := db.Begin(false)
if err != nil {
return err
}
// Make sure the transaction rolls back in the event of a panic.
defer func() {
if t.db != nil {
t.rollback()
}
}()
// Mark as a managed tx so that the inner function cannot manually rollback.
t.managed = true
// If an error is returned from the function then pass it through.
err = fn(t)
t.managed = false
if err != nil {
_ = t.Rollback()
return err
}
if err := t.Rollback(); err != nil {
return err
}
return nil
}
// Sync executes fdatasync() against the database file handle.
//
// This is not necessary under normal operation, however, if you use NoSync
// then it allows you to force the database file to sync against the disk.
func (db *DB) Sync() error { return fdatasync(db) }
// Stats retrieves ongoing performance stats for the database.
// This is only updated when a transaction closes.
func (db *DB) Stats() Stats {
db.statlock.RLock()
defer db.statlock.RUnlock()
return db.stats
}
// This is for internal access to the raw data bytes from the C cursor, use
// carefully, or not at all.
func (db *DB) Info() *Info {
return &Info{uintptr(unsafe.Pointer(&db.data[0])), db.pageSize}
}
// page retrieves a page reference from the mmap based on the current page size.
func (db *DB) page(id pgid) *page {
pos := id * pgid(db.pageSize)
return (*page)(unsafe.Pointer(&db.data[pos]))
}
// pageInBuffer retrieves a page reference from a given byte array based on the current page size.
func (db *DB) pageInBuffer(b []byte, id pgid) *page {
return (*page)(unsafe.Pointer(&b[id*pgid(db.pageSize)]))
}
// meta retrieves the current meta page reference.
func (db *DB) meta() *meta {
if db.meta0.txid > db.meta1.txid {
return db.meta0
}
return db.meta1
}
// allocate returns a contiguous block of memory starting at a given page.
func (db *DB) allocate(count int) (*page, error) {
// Allocate a temporary buffer for the page.
buf := make([]byte, count*db.pageSize)
p := (*page)(unsafe.Pointer(&buf[0]))
p.overflow = uint32(count - 1)
// Use pages from the freelist if they are available.
if p.id = db.freelist.allocate(count); p.id != 0 {
return p, nil
}
// Resize mmap() if we're at the end.
p.id = db.rwtx.meta.pgid
var minsz = int((p.id+pgid(count))+1) * db.pageSize
if minsz >= db.datasz {
if err := db.mmap(minsz); err != nil {
return nil, fmt.Errorf("mmap allocate error: %s", err)
}
}
// Move the page id high water mark.
db.rwtx.meta.pgid += pgid(count)
return p, nil
}
func (db *DB) IsReadOnly() bool {
return db.readOnly
}
// Options represents the options that can be set when opening a database.
type Options struct {
// Timeout is the amount of time to wait to obtain a file lock.
// When set to zero it will wait indefinitely. This option is only
// available on Darwin and Linux.
Timeout time.Duration
// Sets the DB.NoGrowSync flag before memory mapping the file.
NoGrowSync bool
// Open database in read-only mode. Uses flock(..., LOCK_SH |LOCK_NB) to
// grab a shared lock (UNIX).
ReadOnly bool
}
// DefaultOptions represent the options used if nil options are passed into Open().
// No timeout is used which will cause Bolt to wait indefinitely for a lock.
var DefaultOptions = &Options{
Timeout: 0,
NoGrowSync: false,
}
// Stats represents statistics about the database.
type Stats struct {
// Freelist stats
FreePageN int // total number of free pages on the freelist
PendingPageN int // total number of pending pages on the freelist
FreeAlloc int // total bytes allocated in free pages
FreelistInuse int // total bytes used by the freelist
// Transaction stats
TxN int // total number of started read transactions
OpenTxN int // number of currently open read transactions
TxStats TxStats // global, ongoing stats.
}
// Sub calculates and returns the difference between two sets of database stats.
// This is useful when obtaining stats at two different points and time and
// you need the performance counters that occurred within that time span.
func (s *Stats) Sub(other *Stats) Stats {
if other == nil {
return *s
}
var diff Stats
diff.FreePageN = s.FreePageN
diff.PendingPageN = s.PendingPageN
diff.FreeAlloc = s.FreeAlloc
diff.FreelistInuse = s.FreelistInuse
diff.TxN = other.TxN - s.TxN
diff.TxStats = s.TxStats.Sub(&other.TxStats)
return diff
}
func (s *Stats) add(other *Stats) {
s.TxStats.add(&other.TxStats)
}
type Info struct {
Data uintptr
PageSize int
}
type meta struct {
magic uint32
version uint32
pageSize uint32
flags uint32
root bucket
freelist pgid
pgid pgid
txid txid
checksum uint64
}
// validate checks the marker bytes and version of the meta page to ensure it matches this binary.
func (m *meta) validate() error {
if m.checksum != 0 && m.checksum != m.sum64() {
return ErrChecksum
} else if m.magic != magic {
return ErrInvalid
} else if m.version != version {
return ErrVersionMismatch
}
return nil
}
// copy copies one meta object to another.
func (m *meta) copy(dest *meta) {
*dest = *m
}
// write writes the meta onto a page.
func (m *meta) write(p *page) {
if m.root.root >= m.pgid {
panic(fmt.Sprintf("root bucket pgid (%d) above high water mark (%d)", m.root.root, m.pgid))
} else if m.freelist >= m.pgid {
panic(fmt.Sprintf("freelist pgid (%d) above high water mark (%d)", m.freelist, m.pgid))
}
// Page id is either going to be 0 or 1 which we can determine by the transaction ID.
p.id = pgid(m.txid % 2)
p.flags |= metaPageFlag
// Calculate the checksum.
m.checksum = m.sum64()
m.copy(p.meta())
}
// generates the checksum for the meta.
func (m *meta) sum64() uint64 {
var h = fnv.New64a()
_, _ = h.Write((*[unsafe.Offsetof(meta{}.checksum)]byte)(unsafe.Pointer(m))[:])
return h.Sum64()
}
// _assert will panic with a given formatted message if the given condition is false.
func _assert(condition bool, msg string, v ...interface{}) {
if !condition {
panic(fmt.Sprintf("assertion failed: "+msg, v...))
}
}
func warn(v ...interface{}) { fmt.Fprintln(os.Stderr, v...) }
func warnf(msg string, v ...interface{}) { fmt.Fprintf(os.Stderr, msg+"\n", v...) }
func printstack() {
stack := strings.Join(strings.Split(string(debug.Stack()), "\n")[2:], "\n")
fmt.Fprintln(os.Stderr, stack)
}

913
Godeps/_workspace/src/github.com/boltdb/bolt/db_test.go generated vendored Normal file
View File

@ -0,0 +1,913 @@
package bolt_test
import (
"encoding/binary"
"errors"
"flag"
"fmt"
"io/ioutil"
"os"
"regexp"
"runtime"
"sort"
"strings"
"testing"
"time"
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/boltdb/bolt"
)
var statsFlag = flag.Bool("stats", false, "show performance stats")
// Ensure that opening a database with a bad path returns an error.
func TestOpen_BadPath(t *testing.T) {
db, err := bolt.Open("", 0666, nil)
assert(t, err != nil, "err: %s", err)
assert(t, db == nil, "")
}
// Ensure that a database can be opened without error.
func TestOpen(t *testing.T) {
path := tempfile()
defer os.Remove(path)
db, err := bolt.Open(path, 0666, nil)
assert(t, db != nil, "")
ok(t, err)
equals(t, db.Path(), path)
ok(t, db.Close())
}
// Ensure that opening an already open database file will timeout.
func TestOpen_Timeout(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("timeout not supported on windows")
}
if runtime.GOOS == "solaris" {
t.Skip("solaris fcntl locks don't support intra-process locking")
}
path := tempfile()
defer os.Remove(path)
// Open a data file.
db0, err := bolt.Open(path, 0666, nil)
assert(t, db0 != nil, "")
ok(t, err)
// Attempt to open the database again.
start := time.Now()
db1, err := bolt.Open(path, 0666, &bolt.Options{Timeout: 100 * time.Millisecond})
assert(t, db1 == nil, "")
equals(t, bolt.ErrTimeout, err)
assert(t, time.Since(start) > 100*time.Millisecond, "")
db0.Close()
}
// Ensure that opening an already open database file will wait until its closed.
func TestOpen_Wait(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("timeout not supported on windows")
}
if runtime.GOOS == "solaris" {
t.Skip("solaris fcntl locks don't support intra-process locking")
}
path := tempfile()
defer os.Remove(path)
// Open a data file.
db0, err := bolt.Open(path, 0666, nil)
assert(t, db0 != nil, "")
ok(t, err)
// Close it in just a bit.
time.AfterFunc(100*time.Millisecond, func() { db0.Close() })
// Attempt to open the database again.
start := time.Now()
db1, err := bolt.Open(path, 0666, &bolt.Options{Timeout: 200 * time.Millisecond})
assert(t, db1 != nil, "")
ok(t, err)
assert(t, time.Since(start) > 100*time.Millisecond, "")
}
// Ensure that opening a database does not increase its size.
// https://github.com/boltdb/bolt/issues/291
func TestOpen_Size(t *testing.T) {
// Open a data file.
db := NewTestDB()
path := db.Path()
defer db.Close()
// Insert until we get above the minimum 4MB size.
ok(t, db.Update(func(tx *bolt.Tx) error {
b, _ := tx.CreateBucketIfNotExists([]byte("data"))
for i := 0; i < 10000; i++ {
ok(t, b.Put([]byte(fmt.Sprintf("%04d", i)), make([]byte, 1000)))
}
return nil
}))
// Close database and grab the size.
db.DB.Close()
sz := fileSize(path)
if sz == 0 {
t.Fatalf("unexpected new file size: %d", sz)
}
// Reopen database, update, and check size again.
db0, err := bolt.Open(path, 0666, nil)
ok(t, err)
ok(t, db0.Update(func(tx *bolt.Tx) error { return tx.Bucket([]byte("data")).Put([]byte{0}, []byte{0}) }))
ok(t, db0.Close())
newSz := fileSize(path)
if newSz == 0 {
t.Fatalf("unexpected new file size: %d", newSz)
}
// Compare the original size with the new size.
if sz != newSz {
t.Fatalf("unexpected file growth: %d => %d", sz, newSz)
}
}
// Ensure that opening a database beyond the max step size does not increase its size.
// https://github.com/boltdb/bolt/issues/303
func TestOpen_Size_Large(t *testing.T) {
if testing.Short() {
t.Skip("short mode")
}
// Open a data file.
db := NewTestDB()
path := db.Path()
defer db.Close()
// Insert until we get above the minimum 4MB size.
var index uint64
for i := 0; i < 10000; i++ {
ok(t, db.Update(func(tx *bolt.Tx) error {
b, _ := tx.CreateBucketIfNotExists([]byte("data"))
for j := 0; j < 1000; j++ {
ok(t, b.Put(u64tob(index), make([]byte, 50)))
index++
}
return nil
}))
}
// Close database and grab the size.
db.DB.Close()
sz := fileSize(path)
if sz == 0 {
t.Fatalf("unexpected new file size: %d", sz)
} else if sz < (1 << 30) {
t.Fatalf("expected larger initial size: %d", sz)
}
// Reopen database, update, and check size again.
db0, err := bolt.Open(path, 0666, nil)
ok(t, err)
ok(t, db0.Update(func(tx *bolt.Tx) error { return tx.Bucket([]byte("data")).Put([]byte{0}, []byte{0}) }))
ok(t, db0.Close())
newSz := fileSize(path)
if newSz == 0 {
t.Fatalf("unexpected new file size: %d", newSz)
}
// Compare the original size with the new size.
if sz != newSz {
t.Fatalf("unexpected file growth: %d => %d", sz, newSz)
}
}
// Ensure that a re-opened database is consistent.
func TestOpen_Check(t *testing.T) {
path := tempfile()
defer os.Remove(path)
db, err := bolt.Open(path, 0666, nil)
ok(t, err)
ok(t, db.View(func(tx *bolt.Tx) error { return <-tx.Check() }))
db.Close()
db, err = bolt.Open(path, 0666, nil)
ok(t, err)
ok(t, db.View(func(tx *bolt.Tx) error { return <-tx.Check() }))
db.Close()
}
// Ensure that the database returns an error if the file handle cannot be open.
func TestDB_Open_FileError(t *testing.T) {
path := tempfile()
defer os.Remove(path)
_, err := bolt.Open(path+"/youre-not-my-real-parent", 0666, nil)
assert(t, err.(*os.PathError) != nil, "")
equals(t, path+"/youre-not-my-real-parent", err.(*os.PathError).Path)
equals(t, "open", err.(*os.PathError).Op)
}
// Ensure that write errors to the meta file handler during initialization are returned.
func TestDB_Open_MetaInitWriteError(t *testing.T) {
t.Skip("pending")
}
// Ensure that a database that is too small returns an error.
func TestDB_Open_FileTooSmall(t *testing.T) {
path := tempfile()
defer os.Remove(path)
db, err := bolt.Open(path, 0666, nil)
ok(t, err)
db.Close()
// corrupt the database
ok(t, os.Truncate(path, int64(os.Getpagesize())))
db, err = bolt.Open(path, 0666, nil)
equals(t, errors.New("file size too small"), err)
}
// Ensure that a database can be opened in read-only mode by multiple processes
// and that a database can not be opened in read-write mode and in read-only
// mode at the same time.
func TestOpen_ReadOnly(t *testing.T) {
if runtime.GOOS == "solaris" {
t.Skip("solaris fcntl locks don't support intra-process locking")
}
bucket, key, value := []byte(`bucket`), []byte(`key`), []byte(`value`)
path := tempfile()
defer os.Remove(path)
// Open in read-write mode.
db, err := bolt.Open(path, 0666, nil)
ok(t, db.Update(func(tx *bolt.Tx) error {
b, err := tx.CreateBucket(bucket)
if err != nil {
return err
}
return b.Put(key, value)
}))
assert(t, db != nil, "")
assert(t, !db.IsReadOnly(), "")
ok(t, err)
ok(t, db.Close())
// Open in read-only mode.
db0, err := bolt.Open(path, 0666, &bolt.Options{ReadOnly: true})
ok(t, err)
defer db0.Close()
// Opening in read-write mode should return an error.
_, err = bolt.Open(path, 0666, &bolt.Options{Timeout: time.Millisecond * 100})
assert(t, err != nil, "")
// And again (in read-only mode).
db1, err := bolt.Open(path, 0666, &bolt.Options{ReadOnly: true})
ok(t, err)
defer db1.Close()
// Verify both read-only databases are accessible.
for _, db := range []*bolt.DB{db0, db1} {
// Verify is is in read only mode indeed.
assert(t, db.IsReadOnly(), "")
// Read-only databases should not allow updates.
assert(t,
bolt.ErrDatabaseReadOnly == db.Update(func(*bolt.Tx) error {
panic(`should never get here`)
}),
"")
// Read-only databases should not allow beginning writable txns.
_, err = db.Begin(true)
assert(t, bolt.ErrDatabaseReadOnly == err, "")
// Verify the data.
ok(t, db.View(func(tx *bolt.Tx) error {
b := tx.Bucket(bucket)
if b == nil {
return fmt.Errorf("expected bucket `%s`", string(bucket))
}
got := string(b.Get(key))
expected := string(value)
if got != expected {
return fmt.Errorf("expected `%s`, got `%s`", expected, got)
}
return nil
}))
}
}
// TODO(benbjohnson): Test corruption at every byte of the first two pages.
// Ensure that a database cannot open a transaction when it's not open.
func TestDB_Begin_DatabaseNotOpen(t *testing.T) {
var db bolt.DB
tx, err := db.Begin(false)
assert(t, tx == nil, "")
equals(t, err, bolt.ErrDatabaseNotOpen)
}
// Ensure that a read-write transaction can be retrieved.
func TestDB_BeginRW(t *testing.T) {
db := NewTestDB()
defer db.Close()
tx, err := db.Begin(true)
assert(t, tx != nil, "")
ok(t, err)
assert(t, tx.DB() == db.DB, "")
equals(t, tx.Writable(), true)
ok(t, tx.Commit())
}
// Ensure that opening a transaction while the DB is closed returns an error.
func TestDB_BeginRW_Closed(t *testing.T) {
var db bolt.DB
tx, err := db.Begin(true)
equals(t, err, bolt.ErrDatabaseNotOpen)
assert(t, tx == nil, "")
}
func TestDB_Close_PendingTx_RW(t *testing.T) { testDB_Close_PendingTx(t, true) }
func TestDB_Close_PendingTx_RO(t *testing.T) { testDB_Close_PendingTx(t, false) }
// Ensure that a database cannot close while transactions are open.
func testDB_Close_PendingTx(t *testing.T, writable bool) {
db := NewTestDB()
defer db.Close()
// Start transaction.
tx, err := db.Begin(true)
if err != nil {
t.Fatal(err)
}
// Open update in separate goroutine.
done := make(chan struct{})
go func() {
db.Close()
close(done)
}()
// Ensure database hasn't closed.
time.Sleep(100 * time.Millisecond)
select {
case <-done:
t.Fatal("database closed too early")
default:
}
// Commit transaction.
if err := tx.Commit(); err != nil {
t.Fatal(err)
}
// Ensure database closed now.
time.Sleep(100 * time.Millisecond)
select {
case <-done:
default:
t.Fatal("database did not close")
}
}
// Ensure a database can provide a transactional block.
func TestDB_Update(t *testing.T) {
db := NewTestDB()
defer db.Close()
err := db.Update(func(tx *bolt.Tx) error {
tx.CreateBucket([]byte("widgets"))
b := tx.Bucket([]byte("widgets"))
b.Put([]byte("foo"), []byte("bar"))
b.Put([]byte("baz"), []byte("bat"))
b.Delete([]byte("foo"))
return nil
})
ok(t, err)
err = db.View(func(tx *bolt.Tx) error {
assert(t, tx.Bucket([]byte("widgets")).Get([]byte("foo")) == nil, "")
equals(t, []byte("bat"), tx.Bucket([]byte("widgets")).Get([]byte("baz")))
return nil
})
ok(t, err)
}
// Ensure a closed database returns an error while running a transaction block
func TestDB_Update_Closed(t *testing.T) {
var db bolt.DB
err := db.Update(func(tx *bolt.Tx) error {
tx.CreateBucket([]byte("widgets"))
return nil
})
equals(t, err, bolt.ErrDatabaseNotOpen)
}
// Ensure a panic occurs while trying to commit a managed transaction.
func TestDB_Update_ManualCommit(t *testing.T) {
db := NewTestDB()
defer db.Close()
var ok bool
db.Update(func(tx *bolt.Tx) error {
func() {
defer func() {
if r := recover(); r != nil {
ok = true
}
}()
tx.Commit()
}()
return nil
})
assert(t, ok, "expected panic")
}
// Ensure a panic occurs while trying to rollback a managed transaction.
func TestDB_Update_ManualRollback(t *testing.T) {
db := NewTestDB()
defer db.Close()
var ok bool
db.Update(func(tx *bolt.Tx) error {
func() {
defer func() {
if r := recover(); r != nil {
ok = true
}
}()
tx.Rollback()
}()
return nil
})
assert(t, ok, "expected panic")
}
// Ensure a panic occurs while trying to commit a managed transaction.
func TestDB_View_ManualCommit(t *testing.T) {
db := NewTestDB()
defer db.Close()
var ok bool
db.Update(func(tx *bolt.Tx) error {
func() {
defer func() {
if r := recover(); r != nil {
ok = true
}
}()
tx.Commit()
}()
return nil
})
assert(t, ok, "expected panic")
}
// Ensure a panic occurs while trying to rollback a managed transaction.
func TestDB_View_ManualRollback(t *testing.T) {
db := NewTestDB()
defer db.Close()
var ok bool
db.Update(func(tx *bolt.Tx) error {
func() {
defer func() {
if r := recover(); r != nil {
ok = true
}
}()
tx.Rollback()
}()
return nil
})
assert(t, ok, "expected panic")
}
// Ensure a write transaction that panics does not hold open locks.
func TestDB_Update_Panic(t *testing.T) {
db := NewTestDB()
defer db.Close()
func() {
defer func() {
if r := recover(); r != nil {
t.Log("recover: update", r)
}
}()
db.Update(func(tx *bolt.Tx) error {
tx.CreateBucket([]byte("widgets"))
panic("omg")
})
}()
// Verify we can update again.
err := db.Update(func(tx *bolt.Tx) error {
_, err := tx.CreateBucket([]byte("widgets"))
return err
})
ok(t, err)
// Verify that our change persisted.
err = db.Update(func(tx *bolt.Tx) error {
assert(t, tx.Bucket([]byte("widgets")) != nil, "")
return nil
})
}
// Ensure a database can return an error through a read-only transactional block.
func TestDB_View_Error(t *testing.T) {
db := NewTestDB()
defer db.Close()
err := db.View(func(tx *bolt.Tx) error {
return errors.New("xxx")
})
equals(t, errors.New("xxx"), err)
}
// Ensure a read transaction that panics does not hold open locks.
func TestDB_View_Panic(t *testing.T) {
db := NewTestDB()
defer db.Close()
db.Update(func(tx *bolt.Tx) error {
tx.CreateBucket([]byte("widgets"))
return nil
})
func() {
defer func() {
if r := recover(); r != nil {
t.Log("recover: view", r)
}
}()
db.View(func(tx *bolt.Tx) error {
assert(t, tx.Bucket([]byte("widgets")) != nil, "")
panic("omg")
})
}()
// Verify that we can still use read transactions.
db.View(func(tx *bolt.Tx) error {
assert(t, tx.Bucket([]byte("widgets")) != nil, "")
return nil
})
}
// Ensure that an error is returned when a database write fails.
func TestDB_Commit_WriteFail(t *testing.T) {
t.Skip("pending") // TODO(benbjohnson)
}
// Ensure that DB stats can be returned.
func TestDB_Stats(t *testing.T) {
db := NewTestDB()
defer db.Close()
db.Update(func(tx *bolt.Tx) error {
_, err := tx.CreateBucket([]byte("widgets"))
return err
})
stats := db.Stats()
equals(t, 2, stats.TxStats.PageCount)
equals(t, 0, stats.FreePageN)
equals(t, 2, stats.PendingPageN)
}
// Ensure that database pages are in expected order and type.
func TestDB_Consistency(t *testing.T) {
db := NewTestDB()
defer db.Close()
db.Update(func(tx *bolt.Tx) error {
_, err := tx.CreateBucket([]byte("widgets"))
return err
})
for i := 0; i < 10; i++ {
db.Update(func(tx *bolt.Tx) error {
ok(t, tx.Bucket([]byte("widgets")).Put([]byte("foo"), []byte("bar")))
return nil
})
}
db.Update(func(tx *bolt.Tx) error {
p, _ := tx.Page(0)
assert(t, p != nil, "")
equals(t, "meta", p.Type)
p, _ = tx.Page(1)
assert(t, p != nil, "")
equals(t, "meta", p.Type)
p, _ = tx.Page(2)
assert(t, p != nil, "")
equals(t, "free", p.Type)
p, _ = tx.Page(3)
assert(t, p != nil, "")
equals(t, "free", p.Type)
p, _ = tx.Page(4)
assert(t, p != nil, "")
equals(t, "leaf", p.Type)
p, _ = tx.Page(5)
assert(t, p != nil, "")
equals(t, "freelist", p.Type)
p, _ = tx.Page(6)
assert(t, p == nil, "")
return nil
})
}
// Ensure that DB stats can be substracted from one another.
func TestDBStats_Sub(t *testing.T) {
var a, b bolt.Stats
a.TxStats.PageCount = 3
a.FreePageN = 4
b.TxStats.PageCount = 10
b.FreePageN = 14
diff := b.Sub(&a)
equals(t, 7, diff.TxStats.PageCount)
// free page stats are copied from the receiver and not subtracted
equals(t, 14, diff.FreePageN)
}
func ExampleDB_Update() {
// Open the database.
db, _ := bolt.Open(tempfile(), 0666, nil)
defer os.Remove(db.Path())
defer db.Close()
// Execute several commands within a write transaction.
err := db.Update(func(tx *bolt.Tx) error {
b, err := tx.CreateBucket([]byte("widgets"))
if err != nil {
return err
}
if err := b.Put([]byte("foo"), []byte("bar")); err != nil {
return err
}
return nil
})
// If our transactional block didn't return an error then our data is saved.
if err == nil {
db.View(func(tx *bolt.Tx) error {
value := tx.Bucket([]byte("widgets")).Get([]byte("foo"))
fmt.Printf("The value of 'foo' is: %s\n", value)
return nil
})
}
// Output:
// The value of 'foo' is: bar
}
func ExampleDB_View() {
// Open the database.
db, _ := bolt.Open(tempfile(), 0666, nil)
defer os.Remove(db.Path())
defer db.Close()
// Insert data into a bucket.
db.Update(func(tx *bolt.Tx) error {
tx.CreateBucket([]byte("people"))
b := tx.Bucket([]byte("people"))
b.Put([]byte("john"), []byte("doe"))
b.Put([]byte("susy"), []byte("que"))
return nil
})
// Access data from within a read-only transactional block.
db.View(func(tx *bolt.Tx) error {
v := tx.Bucket([]byte("people")).Get([]byte("john"))
fmt.Printf("John's last name is %s.\n", v)
return nil
})
// Output:
// John's last name is doe.
}
func ExampleDB_Begin_ReadOnly() {
// Open the database.
db, _ := bolt.Open(tempfile(), 0666, nil)
defer os.Remove(db.Path())
defer db.Close()
// Create a bucket.
db.Update(func(tx *bolt.Tx) error {
_, err := tx.CreateBucket([]byte("widgets"))
return err
})
// Create several keys in a transaction.
tx, _ := db.Begin(true)
b := tx.Bucket([]byte("widgets"))
b.Put([]byte("john"), []byte("blue"))
b.Put([]byte("abby"), []byte("red"))
b.Put([]byte("zephyr"), []byte("purple"))
tx.Commit()
// Iterate over the values in sorted key order.
tx, _ = db.Begin(false)
c := tx.Bucket([]byte("widgets")).Cursor()
for k, v := c.First(); k != nil; k, v = c.Next() {
fmt.Printf("%s likes %s\n", k, v)
}
tx.Rollback()
// Output:
// abby likes red
// john likes blue
// zephyr likes purple
}
// TestDB represents a wrapper around a Bolt DB to handle temporary file
// creation and automatic cleanup on close.
type TestDB struct {
*bolt.DB
}
// NewTestDB returns a new instance of TestDB.
func NewTestDB() *TestDB {
db, err := bolt.Open(tempfile(), 0666, nil)
if err != nil {
panic("cannot open db: " + err.Error())
}
return &TestDB{db}
}
// MustView executes a read-only function. Panic on error.
func (db *TestDB) MustView(fn func(tx *bolt.Tx) error) {
if err := db.DB.View(func(tx *bolt.Tx) error {
return fn(tx)
}); err != nil {
panic(err.Error())
}
}
// MustUpdate executes a read-write function. Panic on error.
func (db *TestDB) MustUpdate(fn func(tx *bolt.Tx) error) {
if err := db.DB.View(func(tx *bolt.Tx) error {
return fn(tx)
}); err != nil {
panic(err.Error())
}
}
// MustCreateBucket creates a new bucket. Panic on error.
func (db *TestDB) MustCreateBucket(name []byte) {
if err := db.Update(func(tx *bolt.Tx) error {
_, err := tx.CreateBucket([]byte(name))
return err
}); err != nil {
panic(err.Error())
}
}
// Close closes the database and deletes the underlying file.
func (db *TestDB) Close() {
// Log statistics.
if *statsFlag {
db.PrintStats()
}
// Check database consistency after every test.
db.MustCheck()
// Close database and remove file.
defer os.Remove(db.Path())
db.DB.Close()
}
// PrintStats prints the database stats
func (db *TestDB) PrintStats() {
var stats = db.Stats()
fmt.Printf("[db] %-20s %-20s %-20s\n",
fmt.Sprintf("pg(%d/%d)", stats.TxStats.PageCount, stats.TxStats.PageAlloc),
fmt.Sprintf("cur(%d)", stats.TxStats.CursorCount),
fmt.Sprintf("node(%d/%d)", stats.TxStats.NodeCount, stats.TxStats.NodeDeref),
)
fmt.Printf(" %-20s %-20s %-20s\n",
fmt.Sprintf("rebal(%d/%v)", stats.TxStats.Rebalance, truncDuration(stats.TxStats.RebalanceTime)),
fmt.Sprintf("spill(%d/%v)", stats.TxStats.Spill, truncDuration(stats.TxStats.SpillTime)),
fmt.Sprintf("w(%d/%v)", stats.TxStats.Write, truncDuration(stats.TxStats.WriteTime)),
)
}
// MustCheck runs a consistency check on the database and panics if any errors are found.
func (db *TestDB) MustCheck() {
db.Update(func(tx *bolt.Tx) error {
// Collect all the errors.
var errors []error
for err := range tx.Check() {
errors = append(errors, err)
if len(errors) > 10 {
break
}
}
// If errors occurred, copy the DB and print the errors.
if len(errors) > 0 {
var path = tempfile()
tx.CopyFile(path, 0600)
// Print errors.
fmt.Print("\n\n")
fmt.Printf("consistency check failed (%d errors)\n", len(errors))
for _, err := range errors {
fmt.Println(err)
}
fmt.Println("")
fmt.Println("db saved to:")
fmt.Println(path)
fmt.Print("\n\n")
os.Exit(-1)
}
return nil
})
}
// CopyTempFile copies a database to a temporary file.
func (db *TestDB) CopyTempFile() {
path := tempfile()
db.View(func(tx *bolt.Tx) error { return tx.CopyFile(path, 0600) })
fmt.Println("db copied to: ", path)
}
// tempfile returns a temporary file path.
func tempfile() string {
f, _ := ioutil.TempFile("", "bolt-")
f.Close()
os.Remove(f.Name())
return f.Name()
}
// mustContainKeys checks that a bucket contains a given set of keys.
func mustContainKeys(b *bolt.Bucket, m map[string]string) {
found := make(map[string]string)
b.ForEach(func(k, _ []byte) error {
found[string(k)] = ""
return nil
})
// Check for keys found in bucket that shouldn't be there.
var keys []string
for k, _ := range found {
if _, ok := m[string(k)]; !ok {
keys = append(keys, k)
}
}
if len(keys) > 0 {
sort.Strings(keys)
panic(fmt.Sprintf("keys found(%d): %s", len(keys), strings.Join(keys, ",")))
}
// Check for keys not found in bucket that should be there.
for k, _ := range m {
if _, ok := found[string(k)]; !ok {
keys = append(keys, k)
}
}
if len(keys) > 0 {
sort.Strings(keys)
panic(fmt.Sprintf("keys not found(%d): %s", len(keys), strings.Join(keys, ",")))
}
}
func trunc(b []byte, length int) []byte {
if length < len(b) {
return b[:length]
}
return b
}
func truncDuration(d time.Duration) string {
return regexp.MustCompile(`^(\d+)(\.\d+)`).ReplaceAllString(d.String(), "$1")
}
func fileSize(path string) int64 {
fi, err := os.Stat(path)
if err != nil {
return 0
}
return fi.Size()
}
func warn(v ...interface{}) { fmt.Fprintln(os.Stderr, v...) }
func warnf(msg string, v ...interface{}) { fmt.Fprintf(os.Stderr, msg+"\n", v...) }
// u64tob converts a uint64 into an 8-byte slice.
func u64tob(v uint64) []byte {
b := make([]byte, 8)
binary.BigEndian.PutUint64(b, v)
return b
}
// btou64 converts an 8-byte slice into an uint64.
func btou64(b []byte) uint64 { return binary.BigEndian.Uint64(b) }

44
Godeps/_workspace/src/github.com/boltdb/bolt/doc.go generated vendored Normal file
View File

@ -0,0 +1,44 @@
/*
Package bolt implements a low-level key/value store in pure Go. It supports
fully serializable transactions, ACID semantics, and lock-free MVCC with
multiple readers and a single writer. Bolt can be used for projects that
want a simple data store without the need to add large dependencies such as
Postgres or MySQL.
Bolt is a single-level, zero-copy, B+tree data store. This means that Bolt is
optimized for fast read access and does not require recovery in the event of a
system crash. Transactions which have not finished committing will simply be
rolled back in the event of a crash.
The design of Bolt is based on Howard Chu's LMDB database project.
Bolt currently works on Windows, Mac OS X, and Linux.
Basics
There are only a few types in Bolt: DB, Bucket, Tx, and Cursor. The DB is
a collection of buckets and is represented by a single file on disk. A bucket is
a collection of unique keys that are associated with values.
Transactions provide either read-only or read-write access to the database.
Read-only transactions can retrieve key/value pairs and can use Cursors to
iterate over the dataset sequentially. Read-write transactions can create and
delete buckets and can insert and remove keys. Only one read-write transaction
is allowed at a time.
Caveats
The database uses a read-only, memory-mapped data file to ensure that
applications cannot corrupt the database, however, this means that keys and
values returned from Bolt cannot be changed. Writing to a read-only byte slice
will cause Go to panic.
Keys and values retrieved from the database are only valid for the life of
the transaction. When used outside the transaction, these byte slices can
point to different data or can point to invalid memory which will cause a panic.
*/
package bolt

70
Godeps/_workspace/src/github.com/boltdb/bolt/errors.go generated vendored Normal file
View File

@ -0,0 +1,70 @@
package bolt
import "errors"
// These errors can be returned when opening or calling methods on a DB.
var (
// ErrDatabaseNotOpen is returned when a DB instance is accessed before it
// is opened or after it is closed.
ErrDatabaseNotOpen = errors.New("database not open")
// ErrDatabaseOpen is returned when opening a database that is
// already open.
ErrDatabaseOpen = errors.New("database already open")
// ErrInvalid is returned when a data file is not a Bolt-formatted database.
ErrInvalid = errors.New("invalid database")
// ErrVersionMismatch is returned when the data file was created with a
// different version of Bolt.
ErrVersionMismatch = errors.New("version mismatch")
// ErrChecksum is returned when either meta page checksum does not match.
ErrChecksum = errors.New("checksum error")
// ErrTimeout is returned when a database cannot obtain an exclusive lock
// on the data file after the timeout passed to Open().
ErrTimeout = errors.New("timeout")
)
// These errors can occur when beginning or committing a Tx.
var (
// ErrTxNotWritable is returned when performing a write operation on a
// read-only transaction.
ErrTxNotWritable = errors.New("tx not writable")
// ErrTxClosed is returned when committing or rolling back a transaction
// that has already been committed or rolled back.
ErrTxClosed = errors.New("tx closed")
// ErrDatabaseReadOnly is returned when a mutating transaction is started on a
// read-only database.
ErrDatabaseReadOnly = errors.New("database is in read-only mode")
)
// These errors can occur when putting or deleting a value or a bucket.
var (
// ErrBucketNotFound is returned when trying to access a bucket that has
// not been created yet.
ErrBucketNotFound = errors.New("bucket not found")
// ErrBucketExists is returned when creating a bucket that already exists.
ErrBucketExists = errors.New("bucket already exists")
// ErrBucketNameRequired is returned when creating a bucket with a blank name.
ErrBucketNameRequired = errors.New("bucket name required")
// ErrKeyRequired is returned when inserting a zero-length key.
ErrKeyRequired = errors.New("key required")
// ErrKeyTooLarge is returned when inserting a key that is larger than MaxKeySize.
ErrKeyTooLarge = errors.New("key too large")
// ErrValueTooLarge is returned when inserting a value that is larger than MaxValueSize.
ErrValueTooLarge = errors.New("value too large")
// ErrIncompatibleValue is returned when trying create or delete a bucket
// on an existing non-bucket key or when trying to create or delete a
// non-bucket key on an existing bucket key.
ErrIncompatibleValue = errors.New("incompatible value")
)

View File

@ -0,0 +1,242 @@
package bolt
import (
"fmt"
"sort"
"unsafe"
)
// freelist represents a list of all pages that are available for allocation.
// It also tracks pages that have been freed but are still in use by open transactions.
type freelist struct {
ids []pgid // all free and available free page ids.
pending map[txid][]pgid // mapping of soon-to-be free page ids by tx.
cache map[pgid]bool // fast lookup of all free and pending page ids.
}
// newFreelist returns an empty, initialized freelist.
func newFreelist() *freelist {
return &freelist{
pending: make(map[txid][]pgid),
cache: make(map[pgid]bool),
}
}
// size returns the size of the page after serialization.
func (f *freelist) size() int {
return pageHeaderSize + (int(unsafe.Sizeof(pgid(0))) * f.count())
}
// count returns count of pages on the freelist
func (f *freelist) count() int {
return f.free_count() + f.pending_count()
}
// free_count returns count of free pages
func (f *freelist) free_count() int {
return len(f.ids)
}
// pending_count returns count of pending pages
func (f *freelist) pending_count() int {
var count int
for _, list := range f.pending {
count += len(list)
}
return count
}
// all returns a list of all free ids and all pending ids in one sorted list.
func (f *freelist) all() []pgid {
m := make(pgids, 0)
for _, list := range f.pending {
m = append(m, list...)
}
sort.Sort(m)
return pgids(f.ids).merge(m)
}
// allocate returns the starting page id of a contiguous list of pages of a given size.
// If a contiguous block cannot be found then 0 is returned.
func (f *freelist) allocate(n int) pgid {
if len(f.ids) == 0 {
return 0
}
var initial, previd pgid
for i, id := range f.ids {
if id <= 1 {
panic(fmt.Sprintf("invalid page allocation: %d", id))
}
// Reset initial page if this is not contiguous.
if previd == 0 || id-previd != 1 {
initial = id
}
// If we found a contiguous block then remove it and return it.
if (id-initial)+1 == pgid(n) {
// If we're allocating off the beginning then take the fast path
// and just adjust the existing slice. This will use extra memory
// temporarily but the append() in free() will realloc the slice
// as is necessary.
if (i + 1) == n {
f.ids = f.ids[i+1:]
} else {
copy(f.ids[i-n+1:], f.ids[i+1:])
f.ids = f.ids[:len(f.ids)-n]
}
// Remove from the free cache.
for i := pgid(0); i < pgid(n); i++ {
delete(f.cache, initial+i)
}
return initial
}
previd = id
}
return 0
}
// free releases a page and its overflow for a given transaction id.
// If the page is already free then a panic will occur.
func (f *freelist) free(txid txid, p *page) {
if p.id <= 1 {
panic(fmt.Sprintf("cannot free page 0 or 1: %d", p.id))
}
// Free page and all its overflow pages.
var ids = f.pending[txid]
for id := p.id; id <= p.id+pgid(p.overflow); id++ {
// Verify that page is not already free.
if f.cache[id] {
panic(fmt.Sprintf("page %d already freed", id))
}
// Add to the freelist and cache.
ids = append(ids, id)
f.cache[id] = true
}
f.pending[txid] = ids
}
// release moves all page ids for a transaction id (or older) to the freelist.
func (f *freelist) release(txid txid) {
m := make(pgids, 0)
for tid, ids := range f.pending {
if tid <= txid {
// Move transaction's pending pages to the available freelist.
// Don't remove from the cache since the page is still free.
m = append(m, ids...)
delete(f.pending, tid)
}
}
sort.Sort(m)
f.ids = pgids(f.ids).merge(m)
}
// rollback removes the pages from a given pending tx.
func (f *freelist) rollback(txid txid) {
// Remove page ids from cache.
for _, id := range f.pending[txid] {
delete(f.cache, id)
}
// Remove pages from pending list.
delete(f.pending, txid)
}
// freed returns whether a given page is in the free list.
func (f *freelist) freed(pgid pgid) bool {
return f.cache[pgid]
}
// read initializes the freelist from a freelist page.
func (f *freelist) read(p *page) {
// If the page.count is at the max uint16 value (64k) then it's considered
// an overflow and the size of the freelist is stored as the first element.
idx, count := 0, int(p.count)
if count == 0xFFFF {
idx = 1
count = int(((*[maxAllocSize]pgid)(unsafe.Pointer(&p.ptr)))[0])
}
// Copy the list of page ids from the freelist.
ids := ((*[maxAllocSize]pgid)(unsafe.Pointer(&p.ptr)))[idx:count]
f.ids = make([]pgid, len(ids))
copy(f.ids, ids)
// Make sure they're sorted.
sort.Sort(pgids(f.ids))
// Rebuild the page cache.
f.reindex()
}
// write writes the page ids onto a freelist page. All free and pending ids are
// saved to disk since in the event of a program crash, all pending ids will
// become free.
func (f *freelist) write(p *page) error {
// Combine the old free pgids and pgids waiting on an open transaction.
ids := f.all()
// Update the header flag.
p.flags |= freelistPageFlag
// The page.count can only hold up to 64k elements so if we overflow that
// number then we handle it by putting the size in the first element.
if len(ids) < 0xFFFF {
p.count = uint16(len(ids))
copy(((*[maxAllocSize]pgid)(unsafe.Pointer(&p.ptr)))[:], ids)
} else {
p.count = 0xFFFF
((*[maxAllocSize]pgid)(unsafe.Pointer(&p.ptr)))[0] = pgid(len(ids))
copy(((*[maxAllocSize]pgid)(unsafe.Pointer(&p.ptr)))[1:], ids)
}
return nil
}
// reload reads the freelist from a page and filters out pending items.
func (f *freelist) reload(p *page) {
f.read(p)
// Build a cache of only pending pages.
pcache := make(map[pgid]bool)
for _, pendingIDs := range f.pending {
for _, pendingID := range pendingIDs {
pcache[pendingID] = true
}
}
// Check each page in the freelist and build a new available freelist
// with any pages not in the pending lists.
var a []pgid
for _, id := range f.ids {
if !pcache[id] {
a = append(a, id)
}
}
f.ids = a
// Once the available list is rebuilt then rebuild the free cache so that
// it includes the available and pending free pages.
f.reindex()
}
// reindex rebuilds the free cache based on available and pending free lists.
func (f *freelist) reindex() {
f.cache = make(map[pgid]bool)
for _, id := range f.ids {
f.cache[id] = true
}
for _, pendingIDs := range f.pending {
for _, pendingID := range pendingIDs {
f.cache[pendingID] = true
}
}
}

View File

@ -0,0 +1,156 @@
package bolt
import (
"math/rand"
"reflect"
"sort"
"testing"
"unsafe"
)
// Ensure that a page is added to a transaction's freelist.
func TestFreelist_free(t *testing.T) {
f := newFreelist()
f.free(100, &page{id: 12})
if !reflect.DeepEqual([]pgid{12}, f.pending[100]) {
t.Fatalf("exp=%v; got=%v", []pgid{12}, f.pending[100])
}
}
// Ensure that a page and its overflow is added to a transaction's freelist.
func TestFreelist_free_overflow(t *testing.T) {
f := newFreelist()
f.free(100, &page{id: 12, overflow: 3})
if exp := []pgid{12, 13, 14, 15}; !reflect.DeepEqual(exp, f.pending[100]) {
t.Fatalf("exp=%v; got=%v", exp, f.pending[100])
}
}
// Ensure that a transaction's free pages can be released.
func TestFreelist_release(t *testing.T) {
f := newFreelist()
f.free(100, &page{id: 12, overflow: 1})
f.free(100, &page{id: 9})
f.free(102, &page{id: 39})
f.release(100)
f.release(101)
if exp := []pgid{9, 12, 13}; !reflect.DeepEqual(exp, f.ids) {
t.Fatalf("exp=%v; got=%v", exp, f.ids)
}
f.release(102)
if exp := []pgid{9, 12, 13, 39}; !reflect.DeepEqual(exp, f.ids) {
t.Fatalf("exp=%v; got=%v", exp, f.ids)
}
}
// Ensure that a freelist can find contiguous blocks of pages.
func TestFreelist_allocate(t *testing.T) {
f := &freelist{ids: []pgid{3, 4, 5, 6, 7, 9, 12, 13, 18}}
if id := int(f.allocate(3)); id != 3 {
t.Fatalf("exp=3; got=%v", id)
}
if id := int(f.allocate(1)); id != 6 {
t.Fatalf("exp=6; got=%v", id)
}
if id := int(f.allocate(3)); id != 0 {
t.Fatalf("exp=0; got=%v", id)
}
if id := int(f.allocate(2)); id != 12 {
t.Fatalf("exp=12; got=%v", id)
}
if id := int(f.allocate(1)); id != 7 {
t.Fatalf("exp=7; got=%v", id)
}
if id := int(f.allocate(0)); id != 0 {
t.Fatalf("exp=0; got=%v", id)
}
if id := int(f.allocate(0)); id != 0 {
t.Fatalf("exp=0; got=%v", id)
}
if exp := []pgid{9, 18}; !reflect.DeepEqual(exp, f.ids) {
t.Fatalf("exp=%v; got=%v", exp, f.ids)
}
if id := int(f.allocate(1)); id != 9 {
t.Fatalf("exp=9; got=%v", id)
}
if id := int(f.allocate(1)); id != 18 {
t.Fatalf("exp=18; got=%v", id)
}
if id := int(f.allocate(1)); id != 0 {
t.Fatalf("exp=0; got=%v", id)
}
if exp := []pgid{}; !reflect.DeepEqual(exp, f.ids) {
t.Fatalf("exp=%v; got=%v", exp, f.ids)
}
}
// Ensure that a freelist can deserialize from a freelist page.
func TestFreelist_read(t *testing.T) {
// Create a page.
var buf [4096]byte
page := (*page)(unsafe.Pointer(&buf[0]))
page.flags = freelistPageFlag
page.count = 2
// Insert 2 page ids.
ids := (*[3]pgid)(unsafe.Pointer(&page.ptr))
ids[0] = 23
ids[1] = 50
// Deserialize page into a freelist.
f := newFreelist()
f.read(page)
// Ensure that there are two page ids in the freelist.
if exp := []pgid{23, 50}; !reflect.DeepEqual(exp, f.ids) {
t.Fatalf("exp=%v; got=%v", exp, f.ids)
}
}
// Ensure that a freelist can serialize into a freelist page.
func TestFreelist_write(t *testing.T) {
// Create a freelist and write it to a page.
var buf [4096]byte
f := &freelist{ids: []pgid{12, 39}, pending: make(map[txid][]pgid)}
f.pending[100] = []pgid{28, 11}
f.pending[101] = []pgid{3}
p := (*page)(unsafe.Pointer(&buf[0]))
f.write(p)
// Read the page back out.
f2 := newFreelist()
f2.read(p)
// Ensure that the freelist is correct.
// All pages should be present and in reverse order.
if exp := []pgid{3, 11, 12, 28, 39}; !reflect.DeepEqual(exp, f2.ids) {
t.Fatalf("exp=%v; got=%v", exp, f2.ids)
}
}
func Benchmark_FreelistRelease10K(b *testing.B) { benchmark_FreelistRelease(b, 10000) }
func Benchmark_FreelistRelease100K(b *testing.B) { benchmark_FreelistRelease(b, 100000) }
func Benchmark_FreelistRelease1000K(b *testing.B) { benchmark_FreelistRelease(b, 1000000) }
func Benchmark_FreelistRelease10000K(b *testing.B) { benchmark_FreelistRelease(b, 10000000) }
func benchmark_FreelistRelease(b *testing.B, size int) {
ids := randomPgids(size)
pending := randomPgids(len(ids) / 400)
b.ResetTimer()
for i := 0; i < b.N; i++ {
f := &freelist{ids: ids, pending: map[txid][]pgid{1: pending}}
f.release(1)
}
}
func randomPgids(n int) []pgid {
rand.Seed(42)
pgids := make(pgids, n)
for i := range pgids {
pgids[i] = pgid(rand.Int63())
}
sort.Sort(pgids)
return pgids
}

636
Godeps/_workspace/src/github.com/boltdb/bolt/node.go generated vendored Normal file
View File

@ -0,0 +1,636 @@
package bolt
import (
"bytes"
"fmt"
"sort"
"unsafe"
)
// node represents an in-memory, deserialized page.
type node struct {
bucket *Bucket
isLeaf bool
unbalanced bool
spilled bool
key []byte
pgid pgid
parent *node
children nodes
inodes inodes
}
// root returns the top-level node this node is attached to.
func (n *node) root() *node {
if n.parent == nil {
return n
}
return n.parent.root()
}
// minKeys returns the minimum number of inodes this node should have.
func (n *node) minKeys() int {
if n.isLeaf {
return 1
}
return 2
}
// size returns the size of the node after serialization.
func (n *node) size() int {
sz, elsz := pageHeaderSize, n.pageElementSize()
for i := 0; i < len(n.inodes); i++ {
item := &n.inodes[i]
sz += elsz + len(item.key) + len(item.value)
}
return sz
}
// sizeLessThan returns true if the node is less than a given size.
// This is an optimization to avoid calculating a large node when we only need
// to know if it fits inside a certain page size.
func (n *node) sizeLessThan(v int) bool {
sz, elsz := pageHeaderSize, n.pageElementSize()
for i := 0; i < len(n.inodes); i++ {
item := &n.inodes[i]
sz += elsz + len(item.key) + len(item.value)
if sz >= v {
return false
}
}
return true
}
// pageElementSize returns the size of each page element based on the type of node.
func (n *node) pageElementSize() int {
if n.isLeaf {
return leafPageElementSize
}
return branchPageElementSize
}
// childAt returns the child node at a given index.
func (n *node) childAt(index int) *node {
if n.isLeaf {
panic(fmt.Sprintf("invalid childAt(%d) on a leaf node", index))
}
return n.bucket.node(n.inodes[index].pgid, n)
}
// childIndex returns the index of a given child node.
func (n *node) childIndex(child *node) int {
index := sort.Search(len(n.inodes), func(i int) bool { return bytes.Compare(n.inodes[i].key, child.key) != -1 })
return index
}
// numChildren returns the number of children.
func (n *node) numChildren() int {
return len(n.inodes)
}
// nextSibling returns the next node with the same parent.
func (n *node) nextSibling() *node {
if n.parent == nil {
return nil
}
index := n.parent.childIndex(n)
if index >= n.parent.numChildren()-1 {
return nil
}
return n.parent.childAt(index + 1)
}
// prevSibling returns the previous node with the same parent.
func (n *node) prevSibling() *node {
if n.parent == nil {
return nil
}
index := n.parent.childIndex(n)
if index == 0 {
return nil
}
return n.parent.childAt(index - 1)
}
// put inserts a key/value.
func (n *node) put(oldKey, newKey, value []byte, pgid pgid, flags uint32) {
if pgid >= n.bucket.tx.meta.pgid {
panic(fmt.Sprintf("pgid (%d) above high water mark (%d)", pgid, n.bucket.tx.meta.pgid))
} else if len(oldKey) <= 0 {
panic("put: zero-length old key")
} else if len(newKey) <= 0 {
panic("put: zero-length new key")
}
// Find insertion index.
index := sort.Search(len(n.inodes), func(i int) bool { return bytes.Compare(n.inodes[i].key, oldKey) != -1 })
// Add capacity and shift nodes if we don't have an exact match and need to insert.
exact := (len(n.inodes) > 0 && index < len(n.inodes) && bytes.Equal(n.inodes[index].key, oldKey))
if !exact {
n.inodes = append(n.inodes, inode{})
copy(n.inodes[index+1:], n.inodes[index:])
}
inode := &n.inodes[index]
inode.flags = flags
inode.key = newKey
inode.value = value
inode.pgid = pgid
_assert(len(inode.key) > 0, "put: zero-length inode key")
}
// del removes a key from the node.
func (n *node) del(key []byte) {
// Find index of key.
index := sort.Search(len(n.inodes), func(i int) bool { return bytes.Compare(n.inodes[i].key, key) != -1 })
// Exit if the key isn't found.
if index >= len(n.inodes) || !bytes.Equal(n.inodes[index].key, key) {
return
}
// Delete inode from the node.
n.inodes = append(n.inodes[:index], n.inodes[index+1:]...)
// Mark the node as needing rebalancing.
n.unbalanced = true
}
// read initializes the node from a page.
func (n *node) read(p *page) {
n.pgid = p.id
n.isLeaf = ((p.flags & leafPageFlag) != 0)
n.inodes = make(inodes, int(p.count))
for i := 0; i < int(p.count); i++ {
inode := &n.inodes[i]
if n.isLeaf {
elem := p.leafPageElement(uint16(i))
inode.flags = elem.flags
inode.key = elem.key()
inode.value = elem.value()
} else {
elem := p.branchPageElement(uint16(i))
inode.pgid = elem.pgid
inode.key = elem.key()
}
_assert(len(inode.key) > 0, "read: zero-length inode key")
}
// Save first key so we can find the node in the parent when we spill.
if len(n.inodes) > 0 {
n.key = n.inodes[0].key
_assert(len(n.key) > 0, "read: zero-length node key")
} else {
n.key = nil
}
}
// write writes the items onto one or more pages.
func (n *node) write(p *page) {
// Initialize page.
if n.isLeaf {
p.flags |= leafPageFlag
} else {
p.flags |= branchPageFlag
}
if len(n.inodes) >= 0xFFFF {
panic(fmt.Sprintf("inode overflow: %d (pgid=%d)", len(n.inodes), p.id))
}
p.count = uint16(len(n.inodes))
// Loop over each item and write it to the page.
b := (*[maxAllocSize]byte)(unsafe.Pointer(&p.ptr))[n.pageElementSize()*len(n.inodes):]
for i, item := range n.inodes {
_assert(len(item.key) > 0, "write: zero-length inode key")
// Write the page element.
if n.isLeaf {
elem := p.leafPageElement(uint16(i))
elem.pos = uint32(uintptr(unsafe.Pointer(&b[0])) - uintptr(unsafe.Pointer(elem)))
elem.flags = item.flags
elem.ksize = uint32(len(item.key))
elem.vsize = uint32(len(item.value))
} else {
elem := p.branchPageElement(uint16(i))
elem.pos = uint32(uintptr(unsafe.Pointer(&b[0])) - uintptr(unsafe.Pointer(elem)))
elem.ksize = uint32(len(item.key))
elem.pgid = item.pgid
_assert(elem.pgid != p.id, "write: circular dependency occurred")
}
// If the length of key+value is larger than the max allocation size
// then we need to reallocate the byte array pointer.
//
// See: https://github.com/boltdb/bolt/pull/335
klen, vlen := len(item.key), len(item.value)
if len(b) < klen+vlen {
b = (*[maxAllocSize]byte)(unsafe.Pointer(&b[0]))[:]
}
// Write data for the element to the end of the page.
copy(b[0:], item.key)
b = b[klen:]
copy(b[0:], item.value)
b = b[vlen:]
}
// DEBUG ONLY: n.dump()
}
// split breaks up a node into multiple smaller nodes, if appropriate.
// This should only be called from the spill() function.
func (n *node) split(pageSize int) []*node {
var nodes []*node
node := n
for {
// Split node into two.
a, b := node.splitTwo(pageSize)
nodes = append(nodes, a)
// If we can't split then exit the loop.
if b == nil {
break
}
// Set node to b so it gets split on the next iteration.
node = b
}
return nodes
}
// splitTwo breaks up a node into two smaller nodes, if appropriate.
// This should only be called from the split() function.
func (n *node) splitTwo(pageSize int) (*node, *node) {
// Ignore the split if the page doesn't have at least enough nodes for
// two pages or if the nodes can fit in a single page.
if len(n.inodes) <= (minKeysPerPage*2) || n.sizeLessThan(pageSize) {
return n, nil
}
// Determine the threshold before starting a new node.
var fillPercent = n.bucket.FillPercent
if fillPercent < minFillPercent {
fillPercent = minFillPercent
} else if fillPercent > maxFillPercent {
fillPercent = maxFillPercent
}
threshold := int(float64(pageSize) * fillPercent)
// Determine split position and sizes of the two pages.
splitIndex, _ := n.splitIndex(threshold)
// Split node into two separate nodes.
// If there's no parent then we'll need to create one.
if n.parent == nil {
n.parent = &node{bucket: n.bucket, children: []*node{n}}
}
// Create a new node and add it to the parent.
next := &node{bucket: n.bucket, isLeaf: n.isLeaf, parent: n.parent}
n.parent.children = append(n.parent.children, next)
// Split inodes across two nodes.
next.inodes = n.inodes[splitIndex:]
n.inodes = n.inodes[:splitIndex]
// Update the statistics.
n.bucket.tx.stats.Split++
return n, next
}
// splitIndex finds the position where a page will fill a given threshold.
// It returns the index as well as the size of the first page.
// This is only be called from split().
func (n *node) splitIndex(threshold int) (index, sz int) {
sz = pageHeaderSize
// Loop until we only have the minimum number of keys required for the second page.
for i := 0; i < len(n.inodes)-minKeysPerPage; i++ {
index = i
inode := n.inodes[i]
elsize := n.pageElementSize() + len(inode.key) + len(inode.value)
// If we have at least the minimum number of keys and adding another
// node would put us over the threshold then exit and return.
if i >= minKeysPerPage && sz+elsize > threshold {
break
}
// Add the element size to the total size.
sz += elsize
}
return
}
// spill writes the nodes to dirty pages and splits nodes as it goes.
// Returns an error if dirty pages cannot be allocated.
func (n *node) spill() error {
var tx = n.bucket.tx
if n.spilled {
return nil
}
// Spill child nodes first. Child nodes can materialize sibling nodes in
// the case of split-merge so we cannot use a range loop. We have to check
// the children size on every loop iteration.
sort.Sort(n.children)
for i := 0; i < len(n.children); i++ {
if err := n.children[i].spill(); err != nil {
return err
}
}
// We no longer need the child list because it's only used for spill tracking.
n.children = nil
// Split nodes into appropriate sizes. The first node will always be n.
var nodes = n.split(tx.db.pageSize)
for _, node := range nodes {
// Add node's page to the freelist if it's not new.
if node.pgid > 0 {
tx.db.freelist.free(tx.meta.txid, tx.page(node.pgid))
node.pgid = 0
}
// Allocate contiguous space for the node.
p, err := tx.allocate((node.size() / tx.db.pageSize) + 1)
if err != nil {
return err
}
// Write the node.
if p.id >= tx.meta.pgid {
panic(fmt.Sprintf("pgid (%d) above high water mark (%d)", p.id, tx.meta.pgid))
}
node.pgid = p.id
node.write(p)
node.spilled = true
// Insert into parent inodes.
if node.parent != nil {
var key = node.key
if key == nil {
key = node.inodes[0].key
}
node.parent.put(key, node.inodes[0].key, nil, node.pgid, 0)
node.key = node.inodes[0].key
_assert(len(node.key) > 0, "spill: zero-length node key")
}
// Update the statistics.
tx.stats.Spill++
}
// If the root node split and created a new root then we need to spill that
// as well. We'll clear out the children to make sure it doesn't try to respill.
if n.parent != nil && n.parent.pgid == 0 {
n.children = nil
return n.parent.spill()
}
return nil
}
// rebalance attempts to combine the node with sibling nodes if the node fill
// size is below a threshold or if there are not enough keys.
func (n *node) rebalance() {
if !n.unbalanced {
return
}
n.unbalanced = false
// Update statistics.
n.bucket.tx.stats.Rebalance++
// Ignore if node is above threshold (25%) and has enough keys.
var threshold = n.bucket.tx.db.pageSize / 4
if n.size() > threshold && len(n.inodes) > n.minKeys() {
return
}
// Root node has special handling.
if n.parent == nil {
// If root node is a branch and only has one node then collapse it.
if !n.isLeaf && len(n.inodes) == 1 {
// Move root's child up.
child := n.bucket.node(n.inodes[0].pgid, n)
n.isLeaf = child.isLeaf
n.inodes = child.inodes[:]
n.children = child.children
// Reparent all child nodes being moved.
for _, inode := range n.inodes {
if child, ok := n.bucket.nodes[inode.pgid]; ok {
child.parent = n
}
}
// Remove old child.
child.parent = nil
delete(n.bucket.nodes, child.pgid)
child.free()
}
return
}
// If node has no keys then just remove it.
if n.numChildren() == 0 {
n.parent.del(n.key)
n.parent.removeChild(n)
delete(n.bucket.nodes, n.pgid)
n.free()
n.parent.rebalance()
return
}
_assert(n.parent.numChildren() > 1, "parent must have at least 2 children")
// Destination node is right sibling if idx == 0, otherwise left sibling.
var target *node
var useNextSibling = (n.parent.childIndex(n) == 0)
if useNextSibling {
target = n.nextSibling()
} else {
target = n.prevSibling()
}
// If target node has extra nodes then just move one over.
if target.numChildren() > target.minKeys() {
if useNextSibling {
// Reparent and move node.
if child, ok := n.bucket.nodes[target.inodes[0].pgid]; ok {
child.parent.removeChild(child)
child.parent = n
child.parent.children = append(child.parent.children, child)
}
n.inodes = append(n.inodes, target.inodes[0])
target.inodes = target.inodes[1:]
// Update target key on parent.
target.parent.put(target.key, target.inodes[0].key, nil, target.pgid, 0)
target.key = target.inodes[0].key
_assert(len(target.key) > 0, "rebalance(1): zero-length node key")
} else {
// Reparent and move node.
if child, ok := n.bucket.nodes[target.inodes[len(target.inodes)-1].pgid]; ok {
child.parent.removeChild(child)
child.parent = n
child.parent.children = append(child.parent.children, child)
}
n.inodes = append(n.inodes, inode{})
copy(n.inodes[1:], n.inodes)
n.inodes[0] = target.inodes[len(target.inodes)-1]
target.inodes = target.inodes[:len(target.inodes)-1]
}
// Update parent key for node.
n.parent.put(n.key, n.inodes[0].key, nil, n.pgid, 0)
n.key = n.inodes[0].key
_assert(len(n.key) > 0, "rebalance(2): zero-length node key")
return
}
// If both this node and the target node are too small then merge them.
if useNextSibling {
// Reparent all child nodes being moved.
for _, inode := range target.inodes {
if child, ok := n.bucket.nodes[inode.pgid]; ok {
child.parent.removeChild(child)
child.parent = n
child.parent.children = append(child.parent.children, child)
}
}
// Copy over inodes from target and remove target.
n.inodes = append(n.inodes, target.inodes...)
n.parent.del(target.key)
n.parent.removeChild(target)
delete(n.bucket.nodes, target.pgid)
target.free()
} else {
// Reparent all child nodes being moved.
for _, inode := range n.inodes {
if child, ok := n.bucket.nodes[inode.pgid]; ok {
child.parent.removeChild(child)
child.parent = target
child.parent.children = append(child.parent.children, child)
}
}
// Copy over inodes to target and remove node.
target.inodes = append(target.inodes, n.inodes...)
n.parent.del(n.key)
n.parent.removeChild(n)
delete(n.bucket.nodes, n.pgid)
n.free()
}
// Either this node or the target node was deleted from the parent so rebalance it.
n.parent.rebalance()
}
// removes a node from the list of in-memory children.
// This does not affect the inodes.
func (n *node) removeChild(target *node) {
for i, child := range n.children {
if child == target {
n.children = append(n.children[:i], n.children[i+1:]...)
return
}
}
}
// dereference causes the node to copy all its inode key/value references to heap memory.
// This is required when the mmap is reallocated so inodes are not pointing to stale data.
func (n *node) dereference() {
if n.key != nil {
key := make([]byte, len(n.key))
copy(key, n.key)
n.key = key
_assert(n.pgid == 0 || len(n.key) > 0, "dereference: zero-length node key on existing node")
}
for i := range n.inodes {
inode := &n.inodes[i]
key := make([]byte, len(inode.key))
copy(key, inode.key)
inode.key = key
_assert(len(inode.key) > 0, "dereference: zero-length inode key")
value := make([]byte, len(inode.value))
copy(value, inode.value)
inode.value = value
}
// Recursively dereference children.
for _, child := range n.children {
child.dereference()
}
// Update statistics.
n.bucket.tx.stats.NodeDeref++
}
// free adds the node's underlying page to the freelist.
func (n *node) free() {
if n.pgid != 0 {
n.bucket.tx.db.freelist.free(n.bucket.tx.meta.txid, n.bucket.tx.page(n.pgid))
n.pgid = 0
}
}
// dump writes the contents of the node to STDERR for debugging purposes.
/*
func (n *node) dump() {
// Write node header.
var typ = "branch"
if n.isLeaf {
typ = "leaf"
}
warnf("[NODE %d {type=%s count=%d}]", n.pgid, typ, len(n.inodes))
// Write out abbreviated version of each item.
for _, item := range n.inodes {
if n.isLeaf {
if item.flags&bucketLeafFlag != 0 {
bucket := (*bucket)(unsafe.Pointer(&item.value[0]))
warnf("+L %08x -> (bucket root=%d)", trunc(item.key, 4), bucket.root)
} else {
warnf("+L %08x -> %08x", trunc(item.key, 4), trunc(item.value, 4))
}
} else {
warnf("+B %08x -> pgid=%d", trunc(item.key, 4), item.pgid)
}
}
warn("")
}
*/
type nodes []*node
func (s nodes) Len() int { return len(s) }
func (s nodes) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s nodes) Less(i, j int) bool { return bytes.Compare(s[i].inodes[0].key, s[j].inodes[0].key) == -1 }
// inode represents an internal node inside of a node.
// It can be used to point to elements in a page or point
// to an element which hasn't been added to a page yet.
type inode struct {
flags uint32
pgid pgid
key []byte
value []byte
}
type inodes []inode

View File

@ -0,0 +1,156 @@
package bolt
import (
"testing"
"unsafe"
)
// Ensure that a node can insert a key/value.
func TestNode_put(t *testing.T) {
n := &node{inodes: make(inodes, 0), bucket: &Bucket{tx: &Tx{meta: &meta{pgid: 1}}}}
n.put([]byte("baz"), []byte("baz"), []byte("2"), 0, 0)
n.put([]byte("foo"), []byte("foo"), []byte("0"), 0, 0)
n.put([]byte("bar"), []byte("bar"), []byte("1"), 0, 0)
n.put([]byte("foo"), []byte("foo"), []byte("3"), 0, leafPageFlag)
if len(n.inodes) != 3 {
t.Fatalf("exp=3; got=%d", len(n.inodes))
}
if k, v := n.inodes[0].key, n.inodes[0].value; string(k) != "bar" || string(v) != "1" {
t.Fatalf("exp=<bar,1>; got=<%s,%s>", k, v)
}
if k, v := n.inodes[1].key, n.inodes[1].value; string(k) != "baz" || string(v) != "2" {
t.Fatalf("exp=<baz,2>; got=<%s,%s>", k, v)
}
if k, v := n.inodes[2].key, n.inodes[2].value; string(k) != "foo" || string(v) != "3" {
t.Fatalf("exp=<foo,3>; got=<%s,%s>", k, v)
}
if n.inodes[2].flags != uint32(leafPageFlag) {
t.Fatalf("not a leaf: %d", n.inodes[2].flags)
}
}
// Ensure that a node can deserialize from a leaf page.
func TestNode_read_LeafPage(t *testing.T) {
// Create a page.
var buf [4096]byte
page := (*page)(unsafe.Pointer(&buf[0]))
page.flags = leafPageFlag
page.count = 2
// Insert 2 elements at the beginning. sizeof(leafPageElement) == 16
nodes := (*[3]leafPageElement)(unsafe.Pointer(&page.ptr))
nodes[0] = leafPageElement{flags: 0, pos: 32, ksize: 3, vsize: 4} // pos = sizeof(leafPageElement) * 2
nodes[1] = leafPageElement{flags: 0, pos: 23, ksize: 10, vsize: 3} // pos = sizeof(leafPageElement) + 3 + 4
// Write data for the nodes at the end.
data := (*[4096]byte)(unsafe.Pointer(&nodes[2]))
copy(data[:], []byte("barfooz"))
copy(data[7:], []byte("helloworldbye"))
// Deserialize page into a leaf.
n := &node{}
n.read(page)
// Check that there are two inodes with correct data.
if !n.isLeaf {
t.Fatal("expected leaf")
}
if len(n.inodes) != 2 {
t.Fatalf("exp=2; got=%d", len(n.inodes))
}
if k, v := n.inodes[0].key, n.inodes[0].value; string(k) != "bar" || string(v) != "fooz" {
t.Fatalf("exp=<bar,fooz>; got=<%s,%s>", k, v)
}
if k, v := n.inodes[1].key, n.inodes[1].value; string(k) != "helloworld" || string(v) != "bye" {
t.Fatalf("exp=<helloworld,bye>; got=<%s,%s>", k, v)
}
}
// Ensure that a node can serialize into a leaf page.
func TestNode_write_LeafPage(t *testing.T) {
// Create a node.
n := &node{isLeaf: true, inodes: make(inodes, 0), bucket: &Bucket{tx: &Tx{db: &DB{}, meta: &meta{pgid: 1}}}}
n.put([]byte("susy"), []byte("susy"), []byte("que"), 0, 0)
n.put([]byte("ricki"), []byte("ricki"), []byte("lake"), 0, 0)
n.put([]byte("john"), []byte("john"), []byte("johnson"), 0, 0)
// Write it to a page.
var buf [4096]byte
p := (*page)(unsafe.Pointer(&buf[0]))
n.write(p)
// Read the page back in.
n2 := &node{}
n2.read(p)
// Check that the two pages are the same.
if len(n2.inodes) != 3 {
t.Fatalf("exp=3; got=%d", len(n2.inodes))
}
if k, v := n2.inodes[0].key, n2.inodes[0].value; string(k) != "john" || string(v) != "johnson" {
t.Fatalf("exp=<john,johnson>; got=<%s,%s>", k, v)
}
if k, v := n2.inodes[1].key, n2.inodes[1].value; string(k) != "ricki" || string(v) != "lake" {
t.Fatalf("exp=<ricki,lake>; got=<%s,%s>", k, v)
}
if k, v := n2.inodes[2].key, n2.inodes[2].value; string(k) != "susy" || string(v) != "que" {
t.Fatalf("exp=<susy,que>; got=<%s,%s>", k, v)
}
}
// Ensure that a node can split into appropriate subgroups.
func TestNode_split(t *testing.T) {
// Create a node.
n := &node{inodes: make(inodes, 0), bucket: &Bucket{tx: &Tx{db: &DB{}, meta: &meta{pgid: 1}}}}
n.put([]byte("00000001"), []byte("00000001"), []byte("0123456701234567"), 0, 0)
n.put([]byte("00000002"), []byte("00000002"), []byte("0123456701234567"), 0, 0)
n.put([]byte("00000003"), []byte("00000003"), []byte("0123456701234567"), 0, 0)
n.put([]byte("00000004"), []byte("00000004"), []byte("0123456701234567"), 0, 0)
n.put([]byte("00000005"), []byte("00000005"), []byte("0123456701234567"), 0, 0)
// Split between 2 & 3.
n.split(100)
var parent = n.parent
if len(parent.children) != 2 {
t.Fatalf("exp=2; got=%d", len(parent.children))
}
if len(parent.children[0].inodes) != 2 {
t.Fatalf("exp=2; got=%d", len(parent.children[0].inodes))
}
if len(parent.children[1].inodes) != 3 {
t.Fatalf("exp=3; got=%d", len(parent.children[1].inodes))
}
}
// Ensure that a page with the minimum number of inodes just returns a single node.
func TestNode_split_MinKeys(t *testing.T) {
// Create a node.
n := &node{inodes: make(inodes, 0), bucket: &Bucket{tx: &Tx{db: &DB{}, meta: &meta{pgid: 1}}}}
n.put([]byte("00000001"), []byte("00000001"), []byte("0123456701234567"), 0, 0)
n.put([]byte("00000002"), []byte("00000002"), []byte("0123456701234567"), 0, 0)
// Split.
n.split(20)
if n.parent != nil {
t.Fatalf("expected nil parent")
}
}
// Ensure that a node that has keys that all fit on a page just returns one leaf.
func TestNode_split_SinglePage(t *testing.T) {
// Create a node.
n := &node{inodes: make(inodes, 0), bucket: &Bucket{tx: &Tx{db: &DB{}, meta: &meta{pgid: 1}}}}
n.put([]byte("00000001"), []byte("00000001"), []byte("0123456701234567"), 0, 0)
n.put([]byte("00000002"), []byte("00000002"), []byte("0123456701234567"), 0, 0)
n.put([]byte("00000003"), []byte("00000003"), []byte("0123456701234567"), 0, 0)
n.put([]byte("00000004"), []byte("00000004"), []byte("0123456701234567"), 0, 0)
n.put([]byte("00000005"), []byte("00000005"), []byte("0123456701234567"), 0, 0)
// Split.
n.split(4096)
if n.parent != nil {
t.Fatalf("expected nil parent")
}
}

172
Godeps/_workspace/src/github.com/boltdb/bolt/page.go generated vendored Normal file
View File

@ -0,0 +1,172 @@
package bolt
import (
"fmt"
"os"
"sort"
"unsafe"
)
const pageHeaderSize = int(unsafe.Offsetof(((*page)(nil)).ptr))
const minKeysPerPage = 2
const branchPageElementSize = int(unsafe.Sizeof(branchPageElement{}))
const leafPageElementSize = int(unsafe.Sizeof(leafPageElement{}))
const (
branchPageFlag = 0x01
leafPageFlag = 0x02
metaPageFlag = 0x04
freelistPageFlag = 0x10
)
const (
bucketLeafFlag = 0x01
)
type pgid uint64
type page struct {
id pgid
flags uint16
count uint16
overflow uint32
ptr uintptr
}
// typ returns a human readable page type string used for debugging.
func (p *page) typ() string {
if (p.flags & branchPageFlag) != 0 {
return "branch"
} else if (p.flags & leafPageFlag) != 0 {
return "leaf"
} else if (p.flags & metaPageFlag) != 0 {
return "meta"
} else if (p.flags & freelistPageFlag) != 0 {
return "freelist"
}
return fmt.Sprintf("unknown<%02x>", p.flags)
}
// meta returns a pointer to the metadata section of the page.
func (p *page) meta() *meta {
return (*meta)(unsafe.Pointer(&p.ptr))
}
// leafPageElement retrieves the leaf node by index
func (p *page) leafPageElement(index uint16) *leafPageElement {
n := &((*[0x7FFFFFF]leafPageElement)(unsafe.Pointer(&p.ptr)))[index]
return n
}
// leafPageElements retrieves a list of leaf nodes.
func (p *page) leafPageElements() []leafPageElement {
return ((*[0x7FFFFFF]leafPageElement)(unsafe.Pointer(&p.ptr)))[:]
}
// branchPageElement retrieves the branch node by index
func (p *page) branchPageElement(index uint16) *branchPageElement {
return &((*[0x7FFFFFF]branchPageElement)(unsafe.Pointer(&p.ptr)))[index]
}
// branchPageElements retrieves a list of branch nodes.
func (p *page) branchPageElements() []branchPageElement {
return ((*[0x7FFFFFF]branchPageElement)(unsafe.Pointer(&p.ptr)))[:]
}
// dump writes n bytes of the page to STDERR as hex output.
func (p *page) hexdump(n int) {
buf := (*[maxAllocSize]byte)(unsafe.Pointer(p))[:n]
fmt.Fprintf(os.Stderr, "%x\n", buf)
}
type pages []*page
func (s pages) Len() int { return len(s) }
func (s pages) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s pages) Less(i, j int) bool { return s[i].id < s[j].id }
// branchPageElement represents a node on a branch page.
type branchPageElement struct {
pos uint32
ksize uint32
pgid pgid
}
// key returns a byte slice of the node key.
func (n *branchPageElement) key() []byte {
buf := (*[maxAllocSize]byte)(unsafe.Pointer(n))
return (*[maxAllocSize]byte)(unsafe.Pointer(&buf[n.pos]))[:n.ksize]
}
// leafPageElement represents a node on a leaf page.
type leafPageElement struct {
flags uint32
pos uint32
ksize uint32
vsize uint32
}
// key returns a byte slice of the node key.
func (n *leafPageElement) key() []byte {
buf := (*[maxAllocSize]byte)(unsafe.Pointer(n))
return (*[maxAllocSize]byte)(unsafe.Pointer(&buf[n.pos]))[:n.ksize]
}
// value returns a byte slice of the node value.
func (n *leafPageElement) value() []byte {
buf := (*[maxAllocSize]byte)(unsafe.Pointer(n))
return (*[maxAllocSize]byte)(unsafe.Pointer(&buf[n.pos+n.ksize]))[:n.vsize]
}
// PageInfo represents human readable information about a page.
type PageInfo struct {
ID int
Type string
Count int
OverflowCount int
}
type pgids []pgid
func (s pgids) Len() int { return len(s) }
func (s pgids) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s pgids) Less(i, j int) bool { return s[i] < s[j] }
// merge returns the sorted union of a and b.
func (a pgids) merge(b pgids) pgids {
// Return the opposite slice if one is nil.
if len(a) == 0 {
return b
} else if len(b) == 0 {
return a
}
// Create a list to hold all elements from both lists.
merged := make(pgids, 0, len(a)+len(b))
// Assign lead to the slice with a lower starting value, follow to the higher value.
lead, follow := a, b
if b[0] < a[0] {
lead, follow = b, a
}
// Continue while there are elements in the lead.
for len(lead) > 0 {
// Merge largest prefix of lead that is ahead of follow[0].
n := sort.Search(len(lead), func(i int) bool { return lead[i] > follow[0] })
merged = append(merged, lead[:n]...)
if n >= len(lead) {
break
}
// Swap lead and follow.
lead, follow = follow, lead[n:]
}
// Append what's left in follow.
merged = append(merged, follow...)
return merged
}

View File

@ -0,0 +1,72 @@
package bolt
import (
"reflect"
"sort"
"testing"
"testing/quick"
)
// Ensure that the page type can be returned in human readable format.
func TestPage_typ(t *testing.T) {
if typ := (&page{flags: branchPageFlag}).typ(); typ != "branch" {
t.Fatalf("exp=branch; got=%v", typ)
}
if typ := (&page{flags: leafPageFlag}).typ(); typ != "leaf" {
t.Fatalf("exp=leaf; got=%v", typ)
}
if typ := (&page{flags: metaPageFlag}).typ(); typ != "meta" {
t.Fatalf("exp=meta; got=%v", typ)
}
if typ := (&page{flags: freelistPageFlag}).typ(); typ != "freelist" {
t.Fatalf("exp=freelist; got=%v", typ)
}
if typ := (&page{flags: 20000}).typ(); typ != "unknown<4e20>" {
t.Fatalf("exp=unknown<4e20>; got=%v", typ)
}
}
// Ensure that the hexdump debugging function doesn't blow up.
func TestPage_dump(t *testing.T) {
(&page{id: 256}).hexdump(16)
}
func TestPgids_merge(t *testing.T) {
a := pgids{4, 5, 6, 10, 11, 12, 13, 27}
b := pgids{1, 3, 8, 9, 25, 30}
c := a.merge(b)
if !reflect.DeepEqual(c, pgids{1, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 25, 27, 30}) {
t.Errorf("mismatch: %v", c)
}
a = pgids{4, 5, 6, 10, 11, 12, 13, 27, 35, 36}
b = pgids{8, 9, 25, 30}
c = a.merge(b)
if !reflect.DeepEqual(c, pgids{4, 5, 6, 8, 9, 10, 11, 12, 13, 25, 27, 30, 35, 36}) {
t.Errorf("mismatch: %v", c)
}
}
func TestPgids_merge_quick(t *testing.T) {
if err := quick.Check(func(a, b pgids) bool {
// Sort incoming lists.
sort.Sort(a)
sort.Sort(b)
// Merge the two lists together.
got := a.merge(b)
// The expected value should be the two lists combined and sorted.
exp := append(a, b...)
sort.Sort(exp)
if !reflect.DeepEqual(exp, got) {
t.Errorf("\nexp=%+v\ngot=%+v\n", exp, got)
return false
}
return true
}, nil); err != nil {
t.Fatal(err)
}
}

Some files were not shown because too many files have changed in this diff Show More