Compare commits

...

3033 Commits

Author SHA1 Message Date
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
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
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
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
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
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
1110 changed files with 91259 additions and 71214 deletions

1
.dockerignore Normal file
View File

@ -0,0 +1 @@
.git

5
.gitignore vendored
View File

@ -1,6 +1,11 @@
/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

33
.header
View File

@ -1,20 +1,13 @@
/*
Copyright 2013 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.
*/
package x
import (
)
// 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.

12
.travis.yml Normal file
View File

@ -0,0 +1,12 @@
language: go
sudo: false
go:
- 1.4
install:
- go get golang.org/x/tools/cmd/cover
- go get golang.org/x/tools/cmd/vet
- go get github.com/barakmich/go-nyet
script:
- INTEGRATION=y ./test

View File

@ -1,87 +0,0 @@
v0.4.6
* Fix long-term timer leak (#900, #875, #868, #904)
* Fix `Running` field in standby_info file (#881)
* Add `quorum=true` query parameter for GET requests (#866, #883)
* Add `Access-Control-Allow-Headers` header for CORS requests (#886)
* Various documentation improvements (#907, #882)
v0.4.5
* Flush headers immediatly on `wait=true` requests (#877)
* Add `ETCD_HTTP_READ_TIMEOUT` and `ETCD_HTTP_WRITE_TIMEOUT` (#880)
* Add `ETCDCTL_PEERS` configuration to etcdctl (#95)
* etcdctl takes stdin for mk (#91)
v0.4.4
* Fix `--no-sync` flag in etcdctl (#83)
* Improved logging for machine removal (#844)
* Various documentation improvements (#858, #851, #847)
v0.4.3
* Avoid panic() on truncated or unexpected log data (#834, #833)
* Fix missing stats field (#807)
* Lengthen default peer removal delay to 30mins (#835)
* Reduce logging on heartbeat timeouts (#836)
v0.4.2
* Improvements to the clustering documents
* Set content-type properly on errors (#469)
* Standbys re-join if they should be part of the cluster (#810, #815, #818)
v0.4.1
* Re-introduce DELETE on the machines endpoint
* Document the machines endpoint
v0.4.0
* Introduced standby mode
* Added HEAD requests
* Set logs NOCOW flag when BTRFS is detected to avoid fsync overhead
* Fix all known data races, and pass Go race detector (TODO: re-run race detector)
* Fixed timeouts when using HTTPS
* Improved snapshot stability
* Migration of machine names to new IPs
* Updated peer discovery ordering
v0.3.0
* Add Compare-and-Delete support.
* Added prevNode to response objects.
* Added Discovery API.
* Add tracing and debug endpoints (Documentation/debugging.md).
* Improved logging of cluster events.
* go get github.com/coreos/etcd works.
* info file is no longer used.
* Snapshots are on by default.
* Statistics APIs documented.
v0.2.0
* Support directory creation and removal.
* Add Compare-and-Swap (CAS) support.
* Support recursive GETs.
* Support fully consistent GETs.
* Allow clients to watch specific paths.
* Allow clients to watch for key expiration.
* Unique key generation.
* Support hidden paths.
* Refactor low-level data store.
* Modularize store, server and API code.
* Integrate Gorilla Web Toolkit.
* Add tiered configuration (command line args, env variables, config file).
* Add peer protocol versioning.
* Add rolling upgrade support for future versions.
* Sync key expiration across cluster.
* Significantly improve test coverage.
* Improve migration testing.
* Configurable snapshot count.
* Reduce TCP connection count.
* Fix TCP connection leak.
* Bug Fixes: https://github.com/coreos/etcd/issues?milestone=1&state=closed
Contributors:
* Xiang Li (@xiangli-cmu)
* Ben Johnson (@benbjohnson)
* Brandon Philips (@philips)
* Yifan (@yifan-gu)
* Rob Szumski
* Hongchao Deng (@fengjingchao)
* Kelsey Hightower (@kelseyhightower)
* Adrián (@adrianlzt)
* Antonio Terreno (@aterreno)

View File

@ -21,12 +21,13 @@ This is a rough outline of what a contributor's workflow looks like:
- 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.
- Your PR must receive a LGTM from two maintainers found in the MAINTAINERS file.
Thanks for your contributions!
### Code style
The coding style suggested by the Golang community is used in etcd. See [style doc](https://code.google.com/p/go-wiki/wiki/Style) for details.
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.

View File

@ -1,12 +1,2 @@
FROM ubuntu:12.04
# Let's install go just like Docker (from source).
RUN apt-get update -q
RUN DEBIAN_FRONTEND=noninteractive apt-get install -qy build-essential curl git
RUN curl -s https://storage.googleapis.com/golang/go1.3.src.tar.gz | tar -v -C /usr/local -xz
RUN cd /usr/local/go/src && ./make.bash --no-clean 2>&1
ENV PATH /usr/local/go/bin:$PATH
ADD . /opt/etcd
RUN cd /opt/etcd && ./build
EXPOSE 4001 7001
ENTRYPOINT ["/opt/etcd/bin/etcd"]
FROM golang:onbuild
EXPOSE 4001 7001 2379 2380

View File

@ -0,0 +1,209 @@
## 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.
If a members data directory is ever lost or corrupted then the user should remove the etcd member from the cluster via the [members API][members-api].
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.
[members-api]: other_apis.md#members-api
#### 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]
[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.
#### 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), 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 [member api] [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|
```
$ export ETCDCTL_PEERS=http://10.0.1.10:2379,http://10.0.1.11:2379,http://10.0.1.12:2379
```
```
$ 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
```
$ ssh core@10.0.1.11
```
```
$ sudo systemctl stop etcd
```
#### Copy the data directory of the now-idle member to the new machine
```
$ tar -cvzf node1.etcd.tar.gz /var/lib/etcd/node1.etcd
```
```
$ scp node1.etcd.tar.gz core@10.0.1.13:~/
```
#### Update the peer URLs for that member to reflect the new machine
```
$ curl http://10.0.1.10:2379/v2/members/b4db3bf5e495e255 -XPUT \
-H "Content-Type: application/json" -d '{"peerURLs":["http://10.0.1.13:2380"]}'
```
#### Start etcd on the new machine, using the same configuration and the copy of the data directory
```
$ ssh core@10.0.1.13
```
```
$ tar -xzvf node1.etcd.tar.gz -C /var/lib/etcd
```
```
etcd -name node1 \
-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]: other_apis.md#change-the-peer-urls-of-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/2)-1_ 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 /var/lib/etcd \
--backup-dir /tmp/etcd_backup
```
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=/tmp/etcd_backup \
-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 /var/lib/etcd
mv /tmp/etcd_backup /var/lib/etcd
etcd \
-data-dir=/var/lib/etcd \
...
```
#### Restoring the cluster
Now that the node is running successfully, you can add more nodes to the cluster and restore resiliency. See the [runtime configuration](runtime-configuration.md) guide for more details.
### 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.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,114 @@
# 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.
## Data Directory Migration
The disk format within the data directory changed with etcd 2.0.
If you run etcd 2.0 on an etcd 0.4 data directory it will automatically migrate the data and start.
You will want to coordinate this upgrade by walking through each of your machines in the cluster, stopping etcd 0.4 and then starting etcd 2.0.
If you would rather manually do the migration, to test it out first in another environment, you can use the [migration tool doc][migrationtooldoc].
[migrationtooldoc]: https://github.com/coreos/etcd/blob/master/tools/etcd-migrate/README.md
## Snapshot Migration
If you are only interested in the data in etcd you can migrate a snapshot of your data from a v0.4.9+ cluster into a new etcd 2.0 cluster using a snapshot migration.
The advantage of this method is that you are directly dumping only the etcd data so you can run your old and new cluster side-by-side, snapshot the data, import it and then point your applications at this cluster.
The disadvantage is that the etcd indexes of your data will change which may confuse applications that use etcd.
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 -C 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
```
## 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 linearizabilable 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 equests 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,5 @@
# Benchmarks
etcd benchmarks will be published regularly and tracked for each release below:
- [etcd v2.1.0](etcd-2-1-0-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
## etcd Cluster
3 etcd members, each runs on a single machine
## Testing
Bootstrap another machine and use benchmark tool to send requests to etcd cluster.
## 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,24 @@
## Branch Managemnt
### Guide
- New development occurs on the master branch
- Master branch should always have a green build!
- Backwards-compatible bug fixes should target the master branch and ported to stable
- Once the master branch is ready for release, it will be tagged and become the new stable branch.
The etcd team adopts a rolling release model and support one stable version of etcd going forward.
### Master branch
The master branch is our development branch. It is where all the new features go into first.
If you want to try new features, pull the master branch and play on it. But the branch is not really 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 stable branches.
After a 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 the olders. The bug fixes Patch release will be once every two weeks, given any patches.

View File

@ -1,46 +0,0 @@
# Client libraries support matrix for etcd
As etcd features support is really uneven between client libraries, a compatibility matrix can be important.
We will consider in detail only the features of clients supporting the v2 API. Clients still supporting the v1 API *only* are listed below.
## v1-only clients
Clients supporting only the API version 1
- [justinsb/jetcd](https://github.com/justinsb/jetcd) Java
- [transitorykris/etcd-py](https://github.com/transitorykris/etcd-py) Python
- [russellhaering/txetcd](https://github.com/russellhaering/txetcd) Python
- [iconara/etcd-rb](https://github.com/iconara/etcd-rb) Ruby
- [jpfuentes2/etcd-ruby](https://github.com/jpfuentes2/etcd-ruby) Ruby
- [aterreno/etcd-clojure](https://github.com/aterreno/etcd-clojure) Clojure
- [marshall-lee/etcd.erl](https://github.com/marshall-lee/etcd.erl) Erlang
## v2 clients
The v2 API has a lot of features, we will categorize them in a few categories:
- **HTTPS Auth**: Support for SSL-certificate based authentication
- **Reconnect**: If the client is able to reconnect automatically to another server if one fails.
- **Mod/Lock**: Support for the locking module
- **Mod/Leader**: Support for the leader election module
- **GET,PUT,POST,DEL Features**: Support for all the modifiers when calling the etcd server with said HTTP method.
### Supported features matrix
| Client| [go-etcd](https://github.com/coreos/go-etcd) | [jetcd](https://github.com/diwakergupta/jetcd) | [python-etcd](https://github.com/jplana/python-etcd) | [python-etcd-client](https://github.com/dsoprea/PythonEtcdClient) | [node-etcd](https://github.com/stianeikeland/node-etcd) | [nodejs-etcd](https://github.com/lavagetto/nodejs-etcd) | [etcd-ruby](https://github.com/ranjib/etcd-ruby) | [etcd-api](https://github.com/jdarcy/etcd-api) | [cetcd](https://github.com/dwwoelfel/cetcd) | [clj-etcd](https://github.com/rthomas/clj-etcd) | [etcetera](https://github.com/drusellers/etcetera)| [Etcd.jl](https://github.com/forio/Etcd.jl) | [p5-etcd](https://metacpan.org/release/Etcd)
| --- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| **HTTPS Auth** | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - |
| **Reconnect** | Y | - | Y | Y | - | - | - | Y | - | - | - | - | - |
| **Mod/Lock** | - | - | Y | Y | - | - | - | - | - | - | - | Y | - |
| **Mod/Leader** | - | - | - | Y | - | - | - | - | - | - | - | Y | - |
| **GET Features** | F | B | F | F | F | F | F | B | F | G | F | F | F |
| **PUT Features** | F | B | F | F | F | F | F | G | F | G | F | F | F |
| **POST Features** | F | - | F | F | - | F | F | - | - | - | F | F | F |
| **DEL Features** | F | B | F | F | F | F | F | B | G | B | F | F | F |
**Legend**
**F**: Full support **G**: Good support **B**: Basic support
**Y**: Feature supported **-**: Feature not supported

View File

@ -1,60 +0,0 @@
# Cluster Discovery
## Overview
Starting an etcd cluster requires that each node knows another in the cluster. If you are trying to bring up a cluster all at once, say using a cloud formation, you also need to coordinate who will be the initial cluster leader. The discovery protocol helps you by providing an automated way to discover other existing peers in a cluster.
For more information on how etcd can locate the cluster, see the [finding the cluster][cluster-finding] documentation.
Please note - at least 3 nodes are required for [cluster availability][optimal-cluster-size].
[cluster-finding]: https://github.com/coreos/etcd/blob/master/Documentation/design/cluster-finding.md
[optimal-cluster-size]: https://github.com/coreos/etcd/blob/master/Documentation/optimal-cluster-size.md
## Using discovery.etcd.io
### Create a Token
To use the discovery API, you must first create a token for your etcd cluster. Visit [https://discovery.etcd.io/new](https://discovery.etcd.io/new) to create a new token.
You can inspect the list of peers by viewing `https://discovery.etcd.io/<token>`.
### Start etcd With the Discovery Flag
Specify the `-discovery` flag when you start each etcd instance. The list of existing peers in the cluster will be downloaded and configured. If the instance is the first peer, it will start as the leader of the cluster.
Here's a full example:
```
TOKEN=$(curl https://discovery.etcd.io/new)
./etcd -name instance1 -peer-addr 10.1.2.3:7001 -addr 10.1.2.3:4001 -discovery $TOKEN
./etcd -name instance2 -peer-addr 10.1.2.4:7001 -addr 10.1.2.4:4001 -discovery $TOKEN
./etcd -name instance3 -peer-addr 10.1.2.5:7001 -addr 10.1.2.5:4001 -discovery $TOKEN
```
## Running Your Own Discovery Endpoint
The discovery API communicates with a separate etcd cluster to store and retrieve the list of peers. CoreOS provides [https://discovery.etcd.io](https://discovery.etcd.io) as a free service, but you can easily run your own etcd cluster for this purpose. Here's an example using an etcd cluster located at `10.10.10.10:4001`:
```
TOKEN="testcluster"
./etcd -name instance1 -peer-addr 10.1.2.3:7001 -addr 10.1.2.3:4001 -discovery http://10.10.10.10:4001/v2/keys/$TOKEN
./etcd -name instance2 -peer-addr 10.1.2.4:7001 -addr 10.1.2.4:4001 -discovery http://10.10.10.10:4001/v2/keys/$TOKEN
./etcd -name instance3 -peer-addr 10.1.2.5:7001 -addr 10.1.2.5:4001 -discovery http://10.10.10.10:4001/v2/keys/$TOKEN
```
If you're interested in how to discovery API works behind the scenes, read about the [Discovery Protocol](https://github.com/coreos/etcd/blob/master/Documentation/discovery-protocol.md).
## Setting Peer Addresses Correctly
The Discovery API submits the `-peer-addr` of each etcd instance to the configured Discovery endpoint. It's important to select an address that *all* peers in the cluster can communicate with. For example, if you're located in two regions of a cloud provider, configuring a private `10.x` address will not work between the two regions, and communication will not be possible between all peers.
## Stale Peers
The discovery API will automatically clean up the address of a stale peer that is no longer part of the cluster. The TTL for this process is a week, which should be long enough to handle any extremely long outage you may encounter. There is no harm in having stale peers in the list until they are cleaned up, since an etcd instance only needs to connect to one valid peer in the cluster to join.
## Lifetime of a Discovery URL
A discovery URL identifies a single etcd cluster. Do not re-use discovery URLs for new clusters.
When a machine starts with a new discovery URL the discovery URL will be activated and record the machine's metadata. If you destroy the whole cluster and attempt to bring the cluster back up with the same discovery URL it will fail. This is intentional because all of the registered machines are gone including their logs so there is nothing to recover the killed cluster.

View File

@ -1,169 +1,358 @@
## Clustering
# Clustering Guide
### Example cluster of three machines
## Overview
Let's explore the use of etcd clustering.
We use Raft as the underlying distributed protocol which provides consistency and persistence of the data across all of the etcd instances.
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.
Let start by creating 3 new etcd instances.
Once an etcd cluster is up and running, adding or removing members is done via [runtime reconfiguration](runtime-configuration.md).
We use `-peer-addr` to specify server port and `-addr` to specify client port and `-data-dir` to specify the directory to store the log and info of the machine in the cluster:
This guide will cover the following mechanisms for bootstrapping an etcd cluster:
```sh
./etcd -peer-addr 127.0.0.1:7001 -addr 127.0.0.1:4001 -data-dir machines/machine1 -name machine1
```
* [Static](#static)
* [etcd Discovery](#etcd-discovery)
* [DNS Discovery](#dns-discovery)
**Note:** If you want to run etcd on an external IP address and still have access locally, you'll need to add `-bind-addr 0.0.0.0` so that it will listen on both external and localhost addresses.
A similar argument `-peer-bind-addr` is used to setup the listening address for the server port.
Each of the bootstrapping mechanisms will be used to create a three machine etcd cluster with the following details:
Let's join two more machines to this cluster using the `-peers` argument. A single connection to any peer will allow a new machine to join, but multiple can be specified for greater resiliency.
|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|
```sh
./etcd -peer-addr 127.0.0.1:7002 -addr 127.0.0.1:4002 -peers 127.0.0.1:7001,127.0.0.1:7003 -data-dir machines/machine2 -name machine2
./etcd -peer-addr 127.0.0.1:7003 -addr 127.0.0.1:4003 -peers 127.0.0.1:7001,127.0.0.1:7002 -data-dir machines/machine3 -name machine3
```
## Static
We can retrieve a list of machines in the cluster using the HTTP API:
```sh
curl -L http://127.0.0.1:4001/v2/machines
```
We should see there are three machines in the cluster
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:
```
http://127.0.0.1:4001, http://127.0.0.1:4002, http://127.0.0.1:4003
```
The machine list is also available via the main key API:
```sh
curl -L http://127.0.0.1:4001/v2/keys/_etcd/machines
```
```json
{
"action": "get",
"node": {
"createdIndex": 1,
"dir": true,
"key": "/_etcd/machines",
"modifiedIndex": 1,
"nodes": [
{
"createdIndex": 1,
"key": "/_etcd/machines/machine1",
"modifiedIndex": 1,
"value": "raft=http://127.0.0.1:7001&etcd=http://127.0.0.1:4001"
},
{
"createdIndex": 2,
"key": "/_etcd/machines/machine2",
"modifiedIndex": 2,
"value": "raft=http://127.0.0.1:7002&etcd=http://127.0.0.1:4002"
},
{
"createdIndex": 3,
"key": "/_etcd/machines/machine3",
"modifiedIndex": 3,
"value": "raft=http://127.0.0.1:7003&etcd=http://127.0.0.1:4003"
}
]
}
}
```
We can also get the current leader in the cluster:
```
curl -L http://127.0.0.1:4001/v2/leader
```
The first server we set up should still be the leader unless it has died during these commands.
```
http://127.0.0.1:7001
```
Now we can do normal SET and GET operations on keys as we explored earlier.
```sh
curl -L http://127.0.0.1:4001/v2/keys/foo -XPUT -d value=bar
```
```json
{
"action": "set",
"node": {
"createdIndex": 4,
"key": "/foo",
"modifiedIndex": 4,
"value": "bar"
}
}
```
### Rejoining to the Cluster
If one machine disconnects from the cluster, it could rejoin the cluster automatically when the communication is recovered.
If one machine is killed, it could rejoin the cluster when started with old name. If the peer address is changed, etcd will treat the new peer address as the refreshed one, which benefits instance migration, or virtual machine boot with different IP. The peer-address-changing functionality is only supported when the majority of the cluster is alive, because this behavior needs the consensus of the etcd cluster.
**Note:** For now, it is user responsibility to ensure that the machine doesn't join the cluster that has the member with the same name. Or unexpected error will happen. It would be improved sooner or later.
### Killing Nodes in the Cluster
Now if we kill the leader of the cluster, we can get the value from one of the other two machines:
```sh
curl -L http://127.0.0.1:4002/v2/keys/foo
```
We can also see that a new leader has been elected:
```
curl -L http://127.0.0.1:4002/v2/leader
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
```
```
http://127.0.0.1:7002
-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
```
or
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.
On each machine you would start etcd with these flags:
```
http://127.0.0.1:7003
$ etcd -name infra0 -initial-advertise-peer-urls http://10.0.1.10:2380 \
-listen-peer-urls http://10.0.1.10:2380 \
-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 \
-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 \
-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.
### Testing Persistence
### Error Cases
Next we'll kill all the machines to test persistence.
Type `CTRL-C` on each terminal and then rerun the same command you used to start each machine.
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.
Your request for the `foo` key will return the correct value:
```sh
curl -L http://127.0.0.1:4002/v2/keys/foo
```
$ etcd -name infra1 -initial-advertise-peer-urls http://10.0.1.11:2380 \
-listen-peer-urls https://10.0.1.11:2380 \
-initial-cluster infra0=http://10.0.1.10:2380 \
-initial-cluster-state new
etcd: infra1 not listed in the initial cluster config
exit 1
```
```json
{
"action": "get",
"node": {
"createdIndex": 4,
"key": "/foo",
"modifiedIndex": 4,
"value": "bar"
}
}
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 \
-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.
### Using HTTPS between servers
```
$ etcd -name infra3 -initial-advertise-peer-urls http://10.0.1.13:2380 \
-listen-peer-urls http://10.0.1.13:2380 \
-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
```
In the previous example we showed how to use SSL client certs for client-to-server communication.
Etcd can also do internal server-to-server communication using SSL client certs.
To do this just change the `-*-file` flags to `-peer-*-file`.
## Discovery
If you are using SSL for server-to-server communication, you must use it on all instances of etcd.
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
#### 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.
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 \
-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 \
-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 \
-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
```
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 \
-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 \
-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 \
-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 \
-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 \
-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 \
-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 memebers can listen on domain names or IP address, the bootstrap process will resolve DNS A 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
```
# 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

@ -1,135 +1,173 @@
# Etcd Configuration
## Configuration Flags
## Node Configuration
etcd is configurable through command-line flags and environment variables. Options set on the command line take precedence over those from the environment.
Individual node configuration options can be set in three places:
The format of environment variable for flag `-my-flag` is `ETCD_MY_FLAG`. It applies to all flags.
1. Command line flags
2. Environment variables
3. Configuration file
To start etcd automatically using custom settings at startup in Linux, using a [systemd][systemd-intro] unit is highly recommended.
Options set on the command line take precedence over all other sources.
Options set in environment variables take precedence over options set in
configuration files.
[systemd-intro]: http://freedesktop.org/wiki/Software/systemd/
## Cluster Configuration
### Member Flags
Cluster-wide settings are configured via the `/config` admin endpoint and additionally in the configuration file. Values contained in the configuration file will seed the cluster setting with the provided value. After the cluster is running, only the admin endpoint is used.
##### -name
+ Human-readable name for this member.
+ default: "default"
The full documentation is contained in the [API docs](https://github.com/coreos/etcd/blob/master/Documentation/api.md#cluster-config).
##### -data-dir
+ Path to the data directory.
+ default: "${name}.etcd"
* `activeSize` - the maximum number of peers that can participate in the consensus protocol. Other peers will join as standbys.
* `removeDelay` - the minimum time in seconds that a machine has been observed to be unresponsive before it is removed from the cluster.
* `syncInterval` - the amount of time in seconds between cluster sync when it runs in standby mode.
##### -snapshot-count
+ Number of committed transactions to trigger a snapshot to disk.
+ default: "10000"
## Command Line Flags
##### -heartbeat-interval
+ Time (in milliseconds) of a heartbeat interval.
+ default: "100"
### Required
##### -election-timeout
+ Time (in milliseconds) for an election to timeout.
+ default: "1000"
* `-name` - The node name. Defaults to a UUID.
##### -listen-peer-urls
+ List of URLs to listen on for peer traffic.
+ default: "http://localhost:2380,http://localhost:7001"
### Optional
##### -listen-client-urls
+ List of URLs to listen on for client traffic.
+ default: "http://localhost:2379,http://localhost:4001"
* `-addr` - The advertised public hostname:port for client communication. Defaults to `127.0.0.1:4001`.
* `-discovery` - A URL to use for discovering the peer list. (i.e `"https://discovery.etcd.io/your-unique-key"`).
* `-http-read-timeout` - The number of seconds before an HTTP read operation is timed out.
* `-http-write-timeout` - The number of seconds before an HTTP write operation is timed out.
* `-bind-addr` - The listening hostname for client communication. Defaults to advertised IP.
* `-peers` - A comma separated list of peers in the cluster (i.e `"203.0.113.101:7001,203.0.113.102:7001"`).
* `-peers-file` - The file path containing a comma separated list of peers in the cluster.
* `-ca-file` - The path of the client CAFile. Enables client cert authentication when present.
* `-cert-file` - The cert file of the client.
* `-key-file` - The key file of the client.
* `-config` - The path of the etcd configuration file. Defaults to `/etc/etcd/etcd.conf`.
* `-cors` - A comma separated white list of origins for cross-origin resource sharing.
* `-cpuprofile` - The path to a file to output CPU profile data. Enables CPU profiling when present.
* `-data-dir` - The directory to store log and snapshot. Defaults to the current working directory.
* `-max-result-buffer` - The max size of result buffer. Defaults to `1024`.
* `-max-retry-attempts` - The max retry attempts when trying to join a cluster. Defaults to `3`.
* `-peer-addr` - The advertised public hostname:port for server communication. Defaults to `127.0.0.1:7001`.
* `-peer-bind-addr` - The listening hostname for server communication. Defaults to advertised IP.
* `-peer-ca-file` - The path of the CAFile. Enables client/peer cert authentication when present.
* `-peer-cert-file` - The cert file of the server.
* `-peer-key-file` - The key file of the server.
* `-peer-election-timeout` - The number of milliseconds to wait before the leader is declared unhealthy.
* `-peer-heartbeat-interval` - The number of milliseconds in between heartbeat requests
* `-snapshot=false` - Disable log snapshots. Defaults to `true`.
* `-cluster-active-size` - The expected number of instances participating in the consensus protocol. Only applied if the etcd instance is the first peer in the cluster.
* `-cluster-remove-delay` - The number of seconds before one node is removed from the cluster since it cannot be connected at all. Only applied if the etcd instance is the first peer in the cluster.
* `-cluster-sync-interval` - The number of seconds between synchronization for standby-mode instance with the cluster. Only applied if the etcd instance is the first peer in the cluster.
* `-v` - Enable verbose logging. Defaults to `false`.
* `-vv` - Enable very verbose logging. Defaults to `false`.
* `-version` - Print the version and exit.
##### -max-snapshots
+ Maximum number of snapshot files to retain (0 is unlimited)
+ default: 5
+ The default for users on Windows is unlimited, and manual purging down to 5 (or your preference for safety) is recommended.
## Configuration File
##### -max-wals
+ Maximum number of wal files to retain (0 is unlimited)
+ default: 5
+ The default for users on Windows is unlimited, and manual purging down to 5 (or your preference for safety) is recommended.
The etcd configuration file is written in [TOML](https://github.com/mojombo/toml)
and read from `/etc/etcd/etcd.conf` by default.
##### -cors
+ Comma-separated white list of origins for CORS (cross-origin resource sharing).
+ default: none
```TOML
addr = "127.0.0.1:4001"
bind_addr = "127.0.0.1:4001"
ca_file = ""
cert_file = ""
cors = []
cpu_profile_file = ""
data_dir = "."
discovery = "http://etcd.local:4001/v2/keys/_etcd/registry/examplecluster"
http_read_timeout = 10
http_write_timeout = 10
key_file = ""
peers = []
peers_file = ""
max_cluster_size = 9
max_result_buffer = 1024
max_retry_attempts = 3
name = "default-name"
snapshot = false
verbose = false
very_verbose = false
### Clustering Flags
[peer]
addr = "127.0.0.1:7001"
bind_addr = "127.0.0.1:7001"
ca_file = ""
cert_file = ""
key_file = ""
`-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.
[cluster]
active_size = 9
remove_delay = 1800.0
sync_interval = 5.0
```
`-discovery` prefix flags need to be set when using [discovery service][discovery].
## Environment Variables
##### -initial-advertise-peer-urls
* `ETCD_ADDR`
* `ETCD_BIND_ADDR`
* `ETCD_CA_FILE`
* `ETCD_CERT_FILE`
* `ETCD_CORS_ORIGINS`
* `ETCD_CONFIG`
* `ETCD_CPU_PROFILE_FILE`
* `ETCD_DATA_DIR`
* `ETCD_DISCOVERY`
* `ETCD_CLUSTER_HTTP_READ_TIMEOUT`
* `ETCD_CLUSTER_HTTP_WRITE_TIMEOUT`
* `ETCD_KEY_FILE`
* `ETCD_PEERS`
* `ETCD_PEERS_FILE`
* `ETCD_MAX_CLUSTER_SIZE`
* `ETCD_MAX_RESULT_BUFFER`
* `ETCD_MAX_RETRY_ATTEMPTS`
* `ETCD_NAME`
* `ETCD_SNAPSHOT`
* `ETCD_VERBOSE`
* `ETCD_VERY_VERBOSE`
* `ETCD_PEER_ADDR`
* `ETCD_PEER_BIND_ADDR`
* `ETCD_PEER_CA_FILE`
* `ETCD_PEER_CERT_FILE`
* `ETCD_PEER_KEY_FILE`
* `ETCD_PEER_ELECTION_TIMEOUT`
* `ETCD_CLUSTER_ACTIVE_SIZE`
* `ETCD_CLUSTER_REMOVE_DELAY`
* `ETCD_CLUSTER_SYNC_INTERVAL`
+ 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.
+ default: "http://localhost:2380,http://localhost:7001"
##### -initial-cluster
+ Initial cluster configuration for bootstrapping.
+ default: "default=http://localhost:2380,default=http://localhost:7001"
##### -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"
[static bootstrap]: clustering.md#static
##### -initial-cluster-token
+ Initial cluster token for the etcd cluster during bootstrap.
+ default: "etcd-cluster"
##### -advertise-client-urls
+ List of this member's client URLs to advertise to the rest of the cluster.
+ default: "http://localhost:2379,http://localhost:4001"
##### -discovery
+ Discovery URL used to bootstrap the cluster.
+ default: none
##### -discovery-srv
+ DNS srv domain used to bootstrap the cluster.
+ default: none
##### -discovery-fallback
+ Expected behavior ("exit" or "proxy") when discovery services fails.
+ default: "proxy"
##### -discovery-proxy
+ HTTP proxy to use for traffic to discovery service.
+ default: none
### Proxy Flags
`-proxy` prefix flags configures etcd to run in [proxy mode][proxy].
##### -proxy
+ Proxy mode setting ("off", "readonly" or "on").
+ default: "off"
### Security Flags
The security flags help to [build a secure etcd cluster][security].
##### -ca-file [DEPRECATED]
+ Path to the client server TLS CA file.
+ default: none
##### -cert-file
+ Path to the client server TLS cert file.
+ default: none
##### -key-file
+ Path to the client server TLS key file.
+ default: none
##### -client-cert-auth
+ Enable client cert authentication.
+ default: false
##### -trusted-ca-file
+ Path to the client server TLS trusted CA key file.
+ default: none
##### -peer-ca-file [DEPRECATED]
+ Path to the peer server TLS CA file.
+ default: none
##### -peer-cert-file
+ Path to the peer server TLS cert file.
+ default: none
##### -peer-key-file
+ Path to the peer server TLS key file.
+ default: none
##### -peer-client-cert-auth
+ Enable peer client cert authentication.
+ default: false
##### -peer-trusted-ca-file
+ Path to the peer server TLS trusted CA file.
+ default: none
### 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
### 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

@ -1,69 +0,0 @@
# Debugging etcd
Diagnosing issues in a distributed application is hard.
etcd will help as much as it can - just enable these debug features using the CLI flag `-trace=*` or the config option `trace=*`.
## Logging
Log verbosity can be increased to the max using either the `-vvv` CLI flag or the `very_very_verbose=true` config option.
The only supported logging mode is to stdout.
## Metrics
etcd itself can generate a set of metrics.
These metrics represent many different internal data points that can be helpful when debugging etcd servers.
#### Metrics reference
Each individual metric name is prefixed with `etcd.<NAME>`, where \<NAME\> is the configured name of the etcd server.
* `timer.appendentries.handle`: amount of time a peer takes to process an AppendEntriesRequest from the POV of the peer itself
* `timer.peer.<PEER>.heartbeat`: amount of time a peer heartbeat operation takes from the POV of the leader that initiated that operation for peer \<PEER\>
* `timer.command.<COMMAND>`: amount of time a given command took to be processed through the local server's raft state machine. This does not include time waiting on locks.
#### Fetching metrics over HTTP
Once tracing has been enabled on a given etcd server, all metric data is available at the server's `/debug/metrics` HTTP endpoint (i.e. `http://127.0.0.1:4001/debug/metrics`).
Executing a GET HTTP command against the metrics endpoint will yield the current state of all metrics in the etcd server.
#### Sending metrics to Graphite
etcd supports [Graphite's Carbon plaintext protocol](https://graphite.readthedocs.org/en/latest/feeding-carbon.html#the-plaintext-protocol) - a TCP wire protocol designed for shipping metric data to an aggregator.
To send metrics to a Graphite endpoint using this protocol, use of the `-graphite-host` CLI flag or the `graphite_host` config option (i.e. `graphite_host=172.17.0.19:2003`).
See an [example graphite deploy script](https://github.com/coreos/etcd/contrib/graphite).
#### Generating additional metrics with Collectd
[Collectd](http://collectd.org/documentation.shtml) gathers metrics from the host running etcd.
While these aren't metrics generated by etcd itself, it can be invaluable to compare etcd's view of the world to that of a separate process running next to etcd.
See an [example collectd deploy script](https://github.com/coreos/etcd/contrib/collectd).
## Profiling
etcd exposes profiling information from the Go pprof package over HTTP.
The basic browsable interface is served by etcd at the `/debug/pprof` HTTP endpoint (i.e. `http://127.0.0.1:4001/debug/pprof`).
For more information on using profiling tools, see http://blog.golang.org/profiling-go-programs.
**NOTE**: In the following examples you need to ensure that the `./bin/etcd` is identical to the `./bin/etcd` that you are targeting (same git hash, arch, platform, etc).
#### Heap memory profile
```
go tool pprof ./bin/etcd http://127.0.0.1:4001/debug/pprof/heap
```
#### CPU profile
```
go tool pprof ./bin/etcd http://127.0.0.1:4001/debug/pprof/profile
```
#### Blocked goroutine profile
```
go tool pprof ./bin/etcd http://127.0.0.1:4001/debug/pprof/block
```

View File

@ -1,34 +0,0 @@
## Cluster Finding Process
Peer discovery uses the following sources in this order: log data in `-data-dir`, `-discovery` and `-peers`.
If log data is provided, etcd will concatenate possible peers from three sources: the log data, the `-discovery` option, and `-peers`. Then it tries to join cluster through them one by one. If all connection attempts fail (which indicates that the majority of the cluster is currently down), it will restart itself based on the log data, which helps the cluster to recover from a full outage.
Without log data, the instance is assumed to be a brand new one. If possible targets are provided by `-discovery` and `-peers`, etcd will make a best effort attempt to join them, and if none is reachable it will exit. Otherwise, if no `-discovery` or `-peers` option is provided, a new cluster will always be started.
This ensures that users can always restart the node safely with the same command (without --force), and etcd will either reconnect to the old cluster if it is still running or recover its cluster from a outage.
## Logical Workflow
Start an etcd machine:
```
If log data is given:
Try to join via peers in previous cluster
Try to join via peers found in discover URL
Try to join via peers in peer list
Restart the previous cluster which is down
return
If discover URL is given:
Fetch peers through discover URL
If Success:
Join via peers found
return
If peer list is given:
Join as follower via peers in peer list
return
Start as the leader of a new cluster
```

View File

@ -1,232 +0,0 @@
## Standbys
Adding peers in an etcd cluster adds network, CPU, and disk overhead to the leader since each one requires replication.
Peers primarily provide resiliency in the event of a leader failure but the benefit of more failover nodes decreases as the cluster size increases.
A lightweight alternative is the standby.
Standbys are a way for an etcd node to forward requests along to the cluster but the standbys are not part of the Raft cluster themselves.
This provides an easier API for local applications while reducing the overhead required by a regular peer node.
Standbys also act as standby nodes in the event that a peer node in the cluster has not recovered after a long duration.
## Configuration Parameters
There are three configuration parameters used by standbys: active size, remove delay and standby sync interval.
The active size specifies a target size for the number of peers in the cluster.
If there are not enough peers to meet the active size, standbys will send join requests until the peer count is equal to the active size.
If there are more peers than the target active size then peers are removed by the leader and will become standbys.
The remove delay specifies how long the cluster should wait before removing a dead peer.
By default this is 30 minutes.
If a peer is inactive for 30 minutes then the peer is removed.
The standby sync interval specifies the synchronization interval of standbys with the cluster.
By default this is 5 seconds.
After each interval, standbys synchronize information with cluster.
## Logical Workflow
### Start a etcd machine
#### Main logic
```
If find existing standby cluster info:
Goto standby loop
Find cluster as required
If determine to start peer server:
Goto peer loop
Else:
Goto standby loop
Peer loop:
Start peer mode
If running:
Wait for stop
Goto standby loop
Standby loop:
Start standby mode
If running:
Wait for stop
Goto peer loop
```
#### [Cluster finding logic][cluster-finding.md]
#### Join request logic:
```
Fetch machine info
If cannot match version:
return false
If active size <= peer count:
return false
If it has existed in the cluster:
return true
If join request fails:
return false
return true
```
**Note**
1. [TODO] The running mode cannot be determined by log, because the log may be outdated. But the log could be used to estimate its state.
2. Even if sync cluster fails, it will restart still for recovery from full outage.
#### Peer mode start logic
```
Start raft server
Start other helper routines
```
#### Peer mode auto stop logic
```
When removed from the cluster:
Stop raft server
Stop other helper routines
```
#### Standby mode run logic
```
Loop:
Sleep for some time
Sync cluster, and write cluster info into disk
Check active size and send join request if needed
If succeed:
Clear cluster info from disk
Return
```
#### Serve Requests as Standby
Return '404 Page Not Found' always on peer address. This is because peer address is used for raft communication and cluster management, which should not be used in standby mode.
Serve requests from client:
```
Redirect all requests to client URL of leader
```
**Note**
1. The leader here implies the one in raft cluster when doing the latest successful synchronization.
2. [IDEA] We could extend HTTP Redirect to multiple possible targets.
### Join Request Handling
```
If machine has existed in the cluster:
Return
If peer count < active size:
Add peer
Increase peer count
```
### Remove Request Handling
```
If machine exists in the cluster:
Remove peer
Decrease peer count
```
## Cluster Monitor Logic
### Active Size Monitor:
This is only run by current cluster leader.
```
Loop:
Sleep for some time
If peer count > active size:
Remove randomly selected peer
```
### Peer Activity Monitor
This is only run by current cluster leader.
```
Loop:
Sleep for some time
For each peer:
If peer last activity time > remove delay:
Remove the peer
Goto Loop
```
## Cluster Cases
### Create Cluster with Thousands of Instances
First few machines run in peer mode.
All the others check the status of the cluster and run in standby mode.
### Recover from full outage
Machines with log data restart with join failure.
Machines in peer mode recover heartbeat between each other.
Machines in standby mode always sync the cluster. If sync fails, it uses the first address from data log as redirect target.
### Kill one peer machine
Leader of the cluster lose the connection with the peer.
When the time exceeds remove delay, it removes the peer from the cluster.
Machine in standby mode finds one available place of the cluster. It sends join request and joins the cluster.
**Note**
1. [TODO] Machine which was divided from majority and was removed from the cluster will distribute running of the cluster if the new node uses the same name.
### Kill one standby machine
No change for the cluster.
## Cons
1. New instance cannot join immediately after one peer is kicked out of the cluster, because the leader doesn't know the info about the standby instances.
2. It may introduce join collision
3. Cluster needs a good interval setting to balance the join delay and join collision.
## Future Attack Plans
1. Based on heartbeat miss and remove delay, standby could adjust its next check time.
2. Preregister the promotion target when heartbeat miss happens.
3. Get the estimated cluster size from the check happened in the sync interval, and adjust sync interval dynamically.
4. Accept join requests based on active size and alive peers.

View File

@ -1,12 +0,0 @@
# Development tools
## Vagrant
For fast start you can use Vagrant. `vagrant up` will make etcd build and running on virtual machine. Required Vagrant version is 1.5.0.
Next lets set a single key and then retrieve it:
```
curl -L http://127.0.0.1:4001/v2/keys/mykey -XPUT -d value="this is awesome"
curl -L http://127.0.0.1:4001/v2/keys/mykey
```

View File

@ -1,87 +0,0 @@
# Discovery Protocol
Starting a new etcd cluster can be painful since each machine needs to know of at least one live machine in the cluster. If you are trying to bring up a new cluster all at once, say using an AWS cloud formation, you also need to coordinate who will be the initial cluster leader. The discovery protocol uses an existing running etcd cluster to start a second etcd cluster.
To use this feature you add the command line flag `-discovery` to your etcd args. In this example we will use `http://example.com/v2/keys/_etcd/registry` as the URL prefix.
## The Protocol
By convention the etcd discovery protocol uses the key prefix `_etcd/registry`. A full URL to the keyspace will be `http://example.com/v2/keys/_etcd/registry`.
### Creating a New Cluster
Generate a unique token that will identify the new cluster. This will be used as a key prefix in the following steps. An easy way to do this is to use uuidgen:
```
UUID=$(uuidgen)
```
### Bringing up Machines
Now that you have your cluster ID you can start bringing up machines. Every machine will follow this protocol internally in etcd if given a `-discovery`.
### Registering your Machine
The first thing etcd must do is register your machine. This is done by using the machine name (from the `-name` arg) and posting it with a long TTL to the given key.
```
curl -X PUT "http://example.com/v2/keys/_etcd/registry/${UUID}/${etcd_machine_name}?ttl=604800" -d value=${peer_addr}
```
### Discovering Peers
Now that this etcd machine is registered it must discover its peers.
But, the tricky bit of starting a new cluster is that one machine needs to assume the initial role of leader and will have no peers. To figure out if another machine has already started the cluster etcd needs to create the `_state` key and set its value to "started":
```
curl -X PUT "http://example.com/v2/keys/_etcd/registry/${UUID}/_state?prevExist=false" -d value=started
```
If this returns a `200 OK` response then this machine is the initial leader and should start with no peers configured. If, however, this returns a `412 Precondition Failed` then you need to find all of the registered peers:
```
curl -X GET "http://example.com/v2/keys/_etcd/registry/${UUID}?recursive=true"
```
```
{
"action": "get",
"node": {
"createdIndex": 11,
"dir": true,
"key": "/_etcd/registry/9D4258A5-A1D3-4074-8837-31C1E091131D",
"modifiedIndex": 11,
"nodes": [
{
"createdIndex": 16,
"expiration": "2014-02-03T13:19:57.631253589-08:00",
"key": "/_etcd/registry/9D4258A5-A1D3-4074-8837-31C1E091131D/peer1",
"modifiedIndex": 16,
"ttl": 604765,
"value": "127.0.0.1:7001"
},
{
"createdIndex": 17,
"expiration": "2014-02-03T13:19:57.631253589-08:00",
"key": "/_etcd/registry/9D4258A5-A1D3-4074-8837-31C1E091131D/peer2",
"modifiedIndex": 17,
"ttl": 604765,
"value": "127.0.0.1:7002"
}
]
}
}
```
Using this information you can connect to the rest of the peers in the cluster.
### Heartbeating
At this point etcd will start heart beating to your registration URL. The
protocol uses a heartbeat so permanently deleted nodes get slowly removed from
the discovery information cluster.
The heartbeat interval is about once per day and the TTL is one week. This
should give a sufficiently wide window to protect against a discovery service
taking a temporary outage yet provide adequate cleanup.

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,60 +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
EcodeNoMorePeer = 103
EcodeNotDir = 104
EcodeNodeExist = 105
EcodeKeyIsPreserved = 106
EcodeRootROnly = 107
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 peers 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"
errors[107] = "Root is read only"
// 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 base from which the filesystem is constructed.
**etcd**'s file system is Unix-like with two kinds of nodes: file and directories.
- A **file node** has data associated with it.
- A **directory node** has child nodes associated with it.
All nodes, regardless of type, have the following attributes and operations:
### Attributes:
- **Expiration Time** [optional]
The node will be deleted when it expires.
- **ACL**
The path to the node's access control list.
### 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 the 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 referring 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]

31
Documentation/glossary.md Normal file
View File

@ -0,0 +1,31 @@
## 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.
### 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

@ -3,8 +3,12 @@
**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
**Go libraries**
@ -12,14 +16,18 @@
**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**
@ -36,6 +44,9 @@
- [jdarcy/etcd-api](https://github.com/jdarcy/etcd-api) - Supports v2
**C++ libraries**
- [edwardcapriolo/etcdcpp](https://github.com/edwardcapriolo/etcdcpp) - Supports v2
**Clojure libraries**
- [aterreno/etcd-clojure](https://github.com/aterreno/etcd-clojure)
@ -57,6 +68,10 @@
**Haskell libraries**
- [wereHamster/etcd-hs](https://github.com/wereHamster/etcd-hs)
**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].
@ -92,3 +107,6 @@ A detailed recap of client functionalities can be found in the [clients compatib
- [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

View File

@ -1,118 +0,0 @@
## Modules
etcd has a number of modules that are built on top of the core etcd API.
These modules provide things like dashboards, locks and leader election (removed).
**Warning**: Modules are deprecated from v0.4 until we have a solid base we can apply them back onto.
For now, we are choosing to focus on raft algorithm and core etcd to make sure that it works correctly and fast.
And it is time consuming to maintain these modules in this period, given that etcd's API changes from time to time.
Moreover, the lock module has some unfixed bugs, which may mislead users.
But we also notice that these modules are popular and useful, and plan to add them back with full functionality as soon as possible.
### Dashboard
An HTML dashboard can be found at `http://127.0.0.1:4001/mod/dashboard/`.
This dashboard is compiled into the etcd binary and uses the same API as regular etcd clients.
Use the `-cors='*'` flag to allow your browser to request information from the current master as it changes.
### Lock
The Lock module implements a fair lock that can be used when lots of clients want access to a single resource.
A lock can be associated with a value.
The value is unique so if a lock tries to request a value that is already queued for a lock then it will find it and watch until that value obtains the lock.
You may supply a `timeout` which will cancel the lock request if it is not obtained within `timeout` seconds. If `timeout` is not supplied, it is presumed to be infinite. If `timeout` is `0`, the lock request will fail if it is not immediately acquired.
If you lock the same value on a key from two separate curl sessions they'll both return at the same time.
Here's the API:
**Acquire a lock (with no value) for "customer1"**
```sh
curl -X POST http://127.0.0.1:4001/mod/v2/lock/customer1?ttl=60
```
**Acquire a lock for "customer1" that is associated with the value "bar"**
```sh
curl -X POST http://127.0.0.1:4001/mod/v2/lock/customer1?ttl=60 -d value=bar
```
**Acquire a lock for "customer1" that is associated with the value "bar" only if it is done within 2 seconds**
```sh
curl -X POST http://127.0.0.1:4001/mod/v2/lock/customer1?ttl=60 -d value=bar -d timeout=2
```
**Renew the TTL on the "customer1" lock for index 2**
```sh
curl -X PUT http://127.0.0.1:4001/mod/v2/lock/customer1?ttl=60 -d index=2
```
**Renew the TTL on the "customer1" lock for value "bar"**
```sh
curl -X PUT http://127.0.0.1:4001/mod/v2/lock/customer1?ttl=60 -d value=bar
```
**Retrieve the current value for the "customer1" lock.**
```sh
curl http://127.0.0.1:4001/mod/v2/lock/customer1
```
**Retrieve the current index for the "customer1" lock**
```sh
curl http://127.0.0.1:4001/mod/v2/lock/customer1?field=index
```
**Delete the "customer1" lock with the index 2**
```sh
curl -X DELETE http://127.0.0.1:4001/mod/v2/lock/customer1?index=2
```
**Delete the "customer1" lock with the value "bar"**
```sh
curl -X DELETE http://127.0.0.1:4001/mod/v2/lock/customer1?value=bar
```
### Leader Election (Deprecated and Removed in 0.4)
The Leader Election module wraps the Lock module to allow clients to come to consensus on a single value.
This is useful when you want one server to process at a time but allow other servers to fail over.
The API is similar to the Lock module but is limited to simple strings values.
Here's the API:
**Attempt to set a value for the "order_processing" leader key:**
```sh
curl -X PUT http://127.0.0.1:4001/mod/v2/leader/order_processing?ttl=60 -d name=myserver1.foo.com
```
**Retrieve the current value for the "order_processing" leader key:**
```sh
curl http://127.0.0.1:4001/mod/v2/leader/order_processing
myserver1.foo.com
```
**Remove a value from the "order_processing" leader key:**
```sh
curl -X DELETE http://127.0.0.1:4001/mod/v2/leader/order_processing?name=myserver1.foo.com
```
If multiple clients attempt to set the value for a key then only one will succeed.
The other clients will hang until the current value is removed because of TTL or because of a `DELETE` operation.
Multiple clients can submit the same value and will all be notified when that value succeeds.
To update the TTL of a value simply reissue the same `PUT` command that you used to set the value.

View File

@ -1,38 +0,0 @@
# Optimal etcd Cluster Size
etcd's Raft consensus algorithm is most efficient in small clusters between 3 and 9 peers. For clusters larger than 9, etcd will select a subset of instances to participate in the algorithm in order to keep it efficient. The end of this document briefly explores how etcd works internally and why these choices have been made.
## Cluster Management
You can manage the active cluster size through the [cluster config API](https://github.com/coreos/etcd/blob/master/Documentation/api.md#cluster-config). `activeSize` represents the etcd peers allowed to actively participate in the consensus algorithm.
If the total number of etcd instances exceeds this number, additional peers are started as [standbys](https://github.com/coreos/etcd/blob/master/Documentation/design/standbys.md), which can be promoted to active participation if one of the existing active instances has failed or been removed.
## Internals of etcd
### Writing to etcd
Writes to an etcd peer are always redirected to the leader of the cluster and distributed to all of the peers immediately. A write is only considered successful when a majority of the peers acknowledge the write.
For example, in a cluster with 5 peers, a write operation is only as fast as the 3rd fastest machine. This is the main reason for keeping the number of active peers below 9. In practice, you only need to worry about write performance in high latency environments such as a cluster spanning multiple data centers.
### Leader Election
The leader election process is similar to writing a key &mdash; a majority of the active peers must acknowledge the new leader before cluster operations can continue. The longer each peer takes to elect a new leader means you have to wait longer before you can write to the cluster again. In low latency environments this process takes milliseconds.
### Odd Active Cluster Size
The other important cluster optimization is to always have an odd active cluster size (i.e. `activeSize`). Adding an odd node to the number of peers doesn't change the size of the majority and therefore doesn't increase the total latency of the majority as described above. But, you gain a higher tolerance for peer failure by adding the extra machine. You can see this in practice when comparing two even and odd sized clusters:
| Active Peers | Majority | Failure Tolerance |
|--------------|------------|-------------------|
| 1 peers | 1 peers | None |
| 3 peers | 2 peers | 1 peer |
| 4 peers | 3 peers | 1 peer |
| 5 peers | 3 peers | **2 peers** |
| 6 peers | 4 peers | 2 peers |
| 7 peers | 4 peers | **3 peers** |
| 8 peers | 5 peers | 3 peers |
| 9 peers | 5 peers | **4 peers** |
As you can see, adding another peer to bring the number of active peers up to an odd size is always worth it. During a network partition, an odd number of active peers 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.

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

@ -2,6 +2,3 @@ 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.
When the etcd team feels confident removing this warning we will release etcd
1.0.

34
Documentation/proxy.md Normal file
View File

@ -0,0 +1,34 @@
## 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 participant 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.
### 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 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 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,151 @@
## 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].
[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, 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 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).
### Remove a Member
First, we need to find the target member's ID. You can list all members with `etcdctl`:
```
$ etcdctl member list
6e3bd23ae5f1eae0: name=node2 peerURLs=http://localhost:7002 clientURLs=http://127.0.0.1:4002
924e2e83e93f2560: name=node3 peerURLs=http://localhost:7003 clientURLs=http://127.0.0.1:4003
a8266ecf031671f3: name=node1 peerURLs=http://localhost:7001 clientURLs=http://127.0.0.1:4001
```
Let us say the member ID we want to remove is a8266ecf031671f3.
We then use the `remove` command to perform the removal:
```
$ 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 specifing its [name](configuration.md#-name) and [advertised peer URLs](configuration.md#-initial-advertise-peer-urls):
```
$ 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:
```
$ 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
```
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.
```
$ 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).
```
$ 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:
```
$ etcd
etcd: this member has been permanently removed from the cluster. Exiting.
exit 1
```

View File

@ -1,34 +1,60 @@
# Reading and Writing over HTTPS
# security model
## Transport Security with HTTPS
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.
Etcd supports SSL/TLS and client cert authentication for clients to server, as well as server to server 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 [etcd-ca](https://github.com/coreos/etcd-ca) tool provides an easy interface to certificate generation, alternatively this site provides a good reference on how to generate self-signed key pairs:
First, you need to have a CA cert `clientCA.crt` and signed key pair `client.crt`, `client.key`.
This site has a good reference for how to generate self-signed key pairs:
http://www.g-loaded.eu/2005/11/10/be-your-own-ca/
Or you could use [etcd-ca](https://github.com/coreos/etcd-ca) to generate certs and keys.
For testing you can use the certificates in the `fixtures/ca` directory.
## Basic setup
Let's configure etcd to use this keypair:
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 -f -name machine0 -data-dir machine0 -cert-file=./fixtures/ca/server.crt -key-file=./fixtures/ca/server.key.insecure
$ 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
```
There are a few new options we're using:
* `-f` - forces a new machine configuration, even if an existing configuration is found. (WARNING: data loss!)
* `-cert-file` and `-key-file` specify the location of the cert and key files to be used for for transport layer security between the client and server.
You can now test the configuration using HTTPS:
This should start up fine and you can now test the configuration by speaking HTTPS to etcd:
```sh
curl --cacert ./fixtures/ca/server-chain.pem https://127.0.0.1:4001/v2/keys/foo -XPUT -d value=bar -v
$ 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.
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.
@ -36,42 +62,27 @@ If you want to test without the `-k` flag run `open ./fixtures/ca/ca.crt` and fo
Please remove this certificate after you are done testing!
If you know of a workaround let us know.
```
...
SSLv3, TLS handshake, Finished (20):
...
```
## Example 2: Client-to-server authentication with HTTPS client certificates
And also the response from the etcd server:
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.
```json
{
"action": "set",
"key": "/foo",
"modifiedIndex": 3,
"value": "bar"
}
```
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.
## Authentication with HTTPS Client Certificates
We can also do authentication using CA certs.
The clients will provide their cert to the server and the server will check whether the cert is signed by the 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 -f -name machine0 -data-dir machine0 -ca-file=./fixtures/ca/ca.crt -cert-file=./fixtures/ca/server.crt -key-file=./fixtures/ca/server.key.insecure
$ 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
```
```-ca-file``` is the path to the CA cert.
Try the same request to this server:
Now try the same request as above to this server:
```sh
curl --cacert ./fixtures/ca/server-chain.pem https://127.0.0.1:4001/v2/keys/foo -XPUT -d value=bar -v
$ 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.
The request should be rejected by the server:
```
...
@ -79,10 +90,11 @@ routines:SSL3_READ_BYTES:sslv3 alert bad certificate
...
```
We need to give the CA signed cert to the server.
To make it succeed, we need to give the CA signed client certificate to the server:
```sh
curl --key ./fixtures/ca/server2.key.insecure --cert ./fixtures/ca/server2.crt --cacert ./fixtures/ca/server-chain.pem -L https://127.0.0.1:4001/v2/keys/foo -XPUT -d value=bar -v
$ 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:
@ -108,7 +120,34 @@ And also the response from the server:
}
```
### Why SSLv3 alert handshake failure when using SSL client auth?
## 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
### 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.
@ -127,5 +166,10 @@ Add the following section to your openssl.cnf:
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
$ 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.

View File

@ -0,0 +1,409 @@
# 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 security 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 when security is enabled, unless it already exists, 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.
#### 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 security, 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/security
Add code 403 Forbidden 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 possiblity)
* 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."
}
#### Users
The User JSON object is formed as follows:
```
{
"user": "userName"
"password": "password"
"roles": [
"role1",
"role2"
],
"grant": [],
"revoke": [],
}
```
Password is only passed when necessary. Last Modified is set by the server and ignored in all client posts.
**Get a list of users**
GET/HEAD /v2/security/user
Sent Headers:
Authorization: Basic <BasicAuthString>
Possible Status Codes:
200 OK
403 Forbidden
200 Headers:
Content-type: application/json
200 Body:
{
"users": ["alice", "bob", "eve"]
}
**Get User Details**
GET/HEAD /v2/security/users/alice
Sent Headers:
Authorization: Basic <BasicAuthString>
Possible Status Codes:
200 OK
403 Forbidden
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/security/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
403 Forbidden
409 Conflict (if exists)
200 Body: (empty)
**Remove A User**
DELETE /v2/security/users/charlie
Sent Headers:
Authorization: Basic <BasicAuthString>
Possible Status Codes:
200 OK
403 Forbidden
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": {...}},
"members" : ["alice", "bob"]
}
```
**Get a list of Roles**
GET/HEAD /v2/security/roles
Sent Headers:
Authorization: Basic <BasicAuthString>
Possible Status Codes:
200 OK
403 Forbidden
200 Headers:
ETag: "<hash of list of roles>"
Content-type: application/json
200 Body:
{
"roles": ["fleet", "etcd", "quay"]
}
**Get Role Details**
GET/HEAD /v2/security/roles/fleet
Sent Headers:
Authorization: Basic <BasicAuthString>
Possible Status Codes:
200 OK
403 Forbidden
404 Not Found
200 Headers:
ETag: "roles/fleet:<lastModified>"
Content-type: application/json
200 Body:
{
"role" : "fleet",
"read": {
"prefixesAllowed": ["/fleet/"],
},
"write": {
"prefixesAllowed": ["/fleet/"],
},
}
**Create Or Update A Role**
PUT /v2/security/roles/rocket
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:
201 Created
403 Forbidden
404 Not Found
409 Conflict (if exists)
200 Body:
JSON state of the role
**Remove A Role**
DELETE /v2/security/roles/rocket
Sent Headers:
Authorization: Basic <BasicAuthString>
Possible Status Codes:
200 OK
403 Forbidden
404 Not Found
200 Headers:
200 Body: (empty)
#### Enable and Disable Security
**Get security status**
GET /v2/security/enable
Sent Headers:
Possible Status Codes:
200 OK
200 Body:
{
"enabled": true
}
**Enable security**
PUT /v2/security/enable
Sent Headers:
Put Body: (empty)
Possible Status Codes:
200 OK
400 Bad Request (if not a root user)
200 Body: (empty)
**Disable security**
DELETE /v2/security/enable
Sent Headers:
Authorization: Basic <RootAuthString>
Possible Status Codes:
200 OK
403 Forbidden (if not a root user)
200 Body: (empty)
## Example Workflow
Let's walk through an example to show two tenants (applications, in our case) using etcd permissions.
### Enable security
```
PUT /v2/security/enable
Headers:
Put Body:
{"user" : "root", "password": "root"}
```
### Change root's password
```
PUT /v2/security/users/root
Headers:
Authorization: Basic <root:root>
Put Body:
{"user" : "root", "password": "betterRootPW!"}
```
### Create Roles for the Applications
Create the rocket role fully specified:
```
PUT /v2/security/roles/rocket
Headers:
Authorization: Basic <root:betterRootPW!>
Body:
{
"role" : "rocket",
"permissions" : {
"kv": {
"read": [
"/rocket/*"
],
"write": [
"/rocket/*"
]
}
}
}
```
But let's make fleet just a basic role for now:
```
PUT /v2/security/roles/fleet
Headers:
Authorization: Basic <root:betterRootPW!>
Body:
{
"role" : "fleet",
}
```
### Optional: Add 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 rocket case. So this step is optional.)
```
PUT /v2/security/roles/fleet
Headers:
Authorization: Basic <root:betterRootPW!>
Put Body:
{
"role" : "fleet",
"grant" : {
"kv" : {
"read": [
"/rocket/fleet",
"/fleet/*"
]
}
}
}
```
### Create Users
Same as before, let's use rocket all at once and fleet separately
```
PUT /v2/security/users/rocketuser
Headers:
Authorization: Basic <root:betterRootPW!>
Body:
{"user" : "rocketuser", "password" : "rocketpw", "roles" : ["rocket"]}
```
```
PUT /v2/security/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/security/users/fleetuser
Headers:
Authorization: Basic <root:betterRootPW!>
Body:
{"user": "fleetuser", "grant": ["fleet"]}
```
#### Start to use fleetuser and rocketuser
For example:
```
PUT /v2/keys/rocket/RocketData
Headers:
Authorization: Basic <rocketuser:rocketpw>
```
Reads and writes outside the prefixes granted will fail with a 403 Forbidden.

View File

@ -3,17 +3,19 @@
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.
etcd batches commands together for higher throughput so this heartbeat interval is also a delay for how long it takes for commands to be committed.
By default, etcd uses a `50ms` heartbeat interval.
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 `200ms` election timeout.
By default, etcd uses a `1000ms` election timeout.
Adjusting these values is a trade off.
Lowering the heartbeat interval will cause individual commands to be committed faster but it will lower the overall throughput of etcd.
@ -30,23 +32,14 @@ You can override the default values on the command line:
```sh
# Command line arguments:
$ etcd -peer-heartbeat-interval=100 -peer-election-timeout=500
$ etcd -heartbeat-interval=100 -election-timeout=500
# Environment variables:
$ ETCD_PEER_HEARTBEAT_INTERVAL=100 ETCD_PEER_ELECTION_TIMEOUT=500 etcd
```
Or you can set the values within the configuration file:
```toml
[peer]
heartbeat_interval = 100
election_timeout = 100
$ 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.
@ -70,12 +63,6 @@ $ etcd -snapshot-count=5000
$ ETCD_SNAPSHOT_COUNT=5000 etcd
```
Or you can change the setting in the configuration file:
```toml
snapshot_count = 5000
```
You can also disable snapshotting by adding the following to your command line:
```sh
@ -85,9 +72,3 @@ $ etcd -snapshot false
# Environment variables:
$ ETCD_SNAPSHOT=false etcd
```
You can also disable snapshotting within the configuration file:
```toml
snapshot = false
```

View File

@ -1,17 +0,0 @@
# Upgrading an Existing Cluster
etcd clusters can be upgraded by doing a rolling upgrade or all at once. We make every effort to test this process, but please be sure to backup your data [by etcd-dump](https://github.com/AaronO/etcd-dump), or make a copy of data directory beforehand.
## Upgrade Process
- Stop the old etcd processes
- Upgrade the etcd binary
- Restart the etcd instance using the original --name, --address, --peer-address and --data-dir.
## Rolling Upgrade
During an upgrade, etcd clusters are designed to continue working in a mix of old and new versions. It's recommended to converge on the new version quickly. Using new API features before the entire cluster has been upgraded is only supported as a best effort. Each instance's version can be found with `curl http://127.0.0.1:4001/version`.
## All at Once
If downtime is not an issue, the easiest way to upgrade your cluster is to shutdown all of the etcd instances and restart them with the new binary. The current state of the cluster is saved to disk and will be loaded into the cluster when it restarts.

90
Godeps/Godeps.json generated Normal file
View File

@ -0,0 +1,90 @@
{
"ImportPath": "github.com/coreos/etcd",
"GoVersion": "go1.4.1",
"Packages": [
"./..."
],
"Deps": [
{
"ImportPath": "code.google.com/p/goprotobuf/proto",
"Comment": "go.r60-163",
"Rev": "9352842ae63ee1d7e74e074ce7bb10370c4b6b9e"
},
{
"ImportPath": "github.com/codegangsta/cli",
"Comment": "1.2.0-26-gf7ebb76",
"Rev": "f7ebb761e83e21225d1d8954fde853bf8edd46c4"
},
{
"ImportPath": "github.com/coreos/go-etcd/etcd",
"Comment": "v0.2.0-rc1-130-g6aa2da5",
"Rev": "6aa2da5a7a905609c93036b9307185a04a5a84a5"
},
{
"ImportPath": "github.com/gogo/protobuf/proto",
"Rev": "bc946d07d1016848dfd2507f90f0859c9471681e"
},
{
"ImportPath": "github.com/golang/protobuf/proto",
"Rev": "5677a0e3d5e89854c9974e1256839ee23f8233ca"
},
{
"ImportPath": "github.com/jonboulle/clockwork",
"Rev": "72f9bd7c4e0c2a40055ab3d0f09654f730cce982"
},
{
"ImportPath": "github.com/matttproud/golang_protobuf_extensions/ext",
"Rev": "7a864a042e844af638df17ebbabf8183dace556a"
},
{
"ImportPath": "github.com/prometheus/client_golang/_vendor/goautoneg",
"Comment": "0.1.0-22-g70f5497",
"Rev": "70f54973fb9187e8773d738cb6ef6881333f5f25"
},
{
"ImportPath": "github.com/prometheus/client_golang/_vendor/perks/quantile",
"Comment": "0.1.0-22-g70f5497",
"Rev": "70f54973fb9187e8773d738cb6ef6881333f5f25"
},
{
"ImportPath": "github.com/prometheus/client_golang/model",
"Comment": "0.1.0-22-g70f5497",
"Rev": "70f54973fb9187e8773d738cb6ef6881333f5f25"
},
{
"ImportPath": "github.com/prometheus/client_golang/prometheus",
"Comment": "0.1.0-22-g70f5497",
"Rev": "70f54973fb9187e8773d738cb6ef6881333f5f25"
},
{
"ImportPath": "github.com/prometheus/client_golang/text",
"Comment": "0.1.0-22-g70f5497",
"Rev": "70f54973fb9187e8773d738cb6ef6881333f5f25"
},
{
"ImportPath": "github.com/prometheus/client_model/go",
"Comment": "model-0.0.2-12-gfa8ad6f",
"Rev": "fa8ad6fec33561be4280a8f0514318c79d7f6cb6"
},
{
"ImportPath": "github.com/prometheus/procfs",
"Rev": "92faa308558161acab0ada1db048e9996ecec160"
},
{
"ImportPath": "github.com/stretchr/testify/assert",
"Rev": "9cc77fa25329013ce07362c7742952ff887361f2"
},
{
"ImportPath": "golang.org/x/crypto/bcrypt",
"Rev": "1351f936d976c60a0a48d728281922cf63eafb8d"
},
{
"ImportPath": "golang.org/x/crypto/blowfish",
"Rev": "1351f936d976c60a0a48d728281922cf63eafb8d"
},
{
"ImportPath": "golang.org/x/net/context",
"Rev": "7dbad50ab5b31073856416cdcfeb2796d682f844"
}
]
}

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

@ -34,6 +34,7 @@ package proto_test
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"math"
"math/rand"
@ -44,7 +45,7 @@ import (
"time"
. "./testdata"
. "github.com/coreos/etcd/third_party/code.google.com/p/gogoprotobuf/proto"
. "github.com/coreos/etcd/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
)
var globalO *Buffer
@ -394,6 +395,63 @@ func TestNumericPrimitives(t *testing.T) {
}
}
// fakeMarshaler is a simple struct implementing Marshaler and Message interfaces.
type fakeMarshaler struct {
b []byte
err error
}
func (f fakeMarshaler) Marshal() ([]byte, error) {
return f.b, f.err
}
func (f fakeMarshaler) String() string {
return fmt.Sprintf("Bytes: %v Error: %v", f.b, f.err)
}
func (f fakeMarshaler) ProtoMessage() {}
func (f fakeMarshaler) Reset() {}
// Simple tests for proto messages that implement the Marshaler interface.
func TestMarshalerEncoding(t *testing.T) {
tests := []struct {
name string
m Message
want []byte
wantErr error
}{
{
name: "Marshaler that fails",
m: fakeMarshaler{
err: errors.New("some marshal err"),
b: []byte{5, 6, 7},
},
// Since there's an error, nothing should be written to buffer.
want: nil,
wantErr: errors.New("some marshal err"),
},
{
name: "Marshaler that succeeds",
m: fakeMarshaler{
b: []byte{0, 1, 2, 3, 4, 127, 255},
},
want: []byte{0, 1, 2, 3, 4, 127, 255},
wantErr: nil,
},
}
for _, test := range tests {
b := NewBuffer(nil)
err := b.Marshal(test.m)
if !reflect.DeepEqual(test.wantErr, err) {
t.Errorf("%s: got err %v wanted %v", test.name, err, test.wantErr)
}
if !reflect.DeepEqual(test.want, b.Bytes()) {
t.Errorf("%s: got bytes %v wanted %v", test.name, b.Bytes(), test.want)
}
}
}
// Simple tests for bytes
func TestBytesPrimitives(t *testing.T) {
o := old()
@ -989,6 +1047,35 @@ func TestSubmessageUnrecognizedFields(t *testing.T) {
}
}
// Check that an int32 field can be upgraded to an int64 field.
func TestNegativeInt32(t *testing.T) {
om := &OldMessage{
Num: Int32(-1),
}
b, err := Marshal(om)
if err != nil {
t.Fatalf("Marshal of OldMessage: %v", err)
}
// Check the size. It should be 11 bytes;
// 1 for the field/wire type, and 10 for the negative number.
if len(b) != 11 {
t.Errorf("%v marshaled as %q, wanted 11 bytes", om, b)
}
// Unmarshal into a NewMessage.
nm := new(NewMessage)
if err := Unmarshal(b, nm); err != nil {
t.Fatalf("Unmarshal to NewMessage: %v", err)
}
want := &NewMessage{
Num: Int64(-1),
}
if !Equal(nm, want) {
t.Errorf("nm = %v, want %v", nm, want)
}
}
// Check that we can grow an array (repeated field) to have many elements.
// This test doesn't depend only on our encoding; for variety, it makes sure
// we create, encode, and decode the correct contents explicitly. It's therefore
@ -1116,13 +1203,10 @@ func TestTypeMismatch(t *testing.T) {
// Now Unmarshal it to the wrong type.
pb2 := initGoTestField()
err := o.Unmarshal(pb2)
switch err {
case ErrWrongType:
// fine
case nil:
t.Error("expected wrong type error, got no error")
default:
t.Error("expected wrong type error, got", err)
if err == nil {
t.Error("expected error, got no error")
} else if !strings.Contains(err.Error(), "bad wiretype") {
t.Error("expected bad wiretype error, got", err)
}
}
@ -1303,10 +1387,11 @@ func TestAllSetDefaults(t *testing.T) {
F_Pinf: Float32(float32(math.Inf(1))),
F_Ninf: Float32(float32(math.Inf(-1))),
F_Nan: Float32(1.7),
StrZero: String(""),
}
SetDefaults(m)
if !Equal(m, expected) {
t.Errorf(" got %v\nwant %v", m, expected)
t.Errorf("SetDefaults failed\n got %v\nwant %v", m, expected)
}
}
@ -1655,7 +1740,8 @@ func TestEncodingSizes(t *testing.T) {
n int
}{
{&Defaults{F_Int32: Int32(math.MaxInt32)}, 6},
{&Defaults{F_Int32: Int32(math.MinInt32)}, 6},
{&Defaults{F_Int32: Int32(math.MinInt32)}, 11},
{&Defaults{F_Uint32: Uint32(uint32(math.MaxInt32) + 1)}, 6},
{&Defaults{F_Uint32: Uint32(math.MaxUint32)}, 6},
}
for _, test := range tests {

View File

@ -125,13 +125,21 @@ func mergeAny(out, in reflect.Value) {
if in.IsNil() {
return
}
if in.Type().Elem().Kind() == reflect.Uint8 {
// []byte is a scalar bytes field, not a repeated field.
// Make a deep copy.
// Append to []byte{} instead of []byte(nil) so that we never end up
// with a nil result.
out.SetBytes(append([]byte{}, in.Bytes()...))
return
}
n := in.Len()
if out.IsNil() {
out.Set(reflect.MakeSlice(in.Type(), 0, n))
}
switch in.Type().Elem().Kind() {
case reflect.Bool, reflect.Float32, reflect.Float64, reflect.Int32, reflect.Int64,
reflect.String, reflect.Uint32, reflect.Uint64, reflect.Uint8:
reflect.String, reflect.Uint32, reflect.Uint64:
out.Set(reflect.AppendSlice(out, in))
default:
for i := 0; i < n; i++ {

View File

@ -34,9 +34,8 @@ package proto_test
import (
"testing"
"github.com/coreos/etcd/third_party/code.google.com/p/gogoprotobuf/proto"
pb "./testdata"
"github.com/coreos/etcd/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
)
var cloneTestMessage = &pb.MyMessage{
@ -79,6 +78,22 @@ func TestClone(t *testing.T) {
if proto.Equal(m, cloneTestMessage) {
t.Error("Mutating clone changed the original")
}
// Byte fields and repeated fields should be copied.
if &m.Pet[0] == &cloneTestMessage.Pet[0] {
t.Error("Pet: repeated field not copied")
}
if &m.Others[0] == &cloneTestMessage.Others[0] {
t.Error("Others: repeated field not copied")
}
if &m.Others[0].Value[0] == &cloneTestMessage.Others[0].Value[0] {
t.Error("Others[0].Value: bytes field not copied")
}
if &m.RepBytes[0] == &cloneTestMessage.RepBytes[0] {
t.Error("RepBytes: repeated field not copied")
}
if &m.RepBytes[0][0] == &cloneTestMessage.RepBytes[0][0] {
t.Error("RepBytes[0]: bytes field not copied")
}
}
func TestCloneNil(t *testing.T) {
@ -167,6 +182,12 @@ var mergeTests = []struct {
RepBytes: [][]byte{[]byte("sham"), []byte("wow")},
},
},
// Check that a scalar bytes field replaces rather than appends.
{
src: &pb.OtherMessage{Value: []byte("foo")},
dst: &pb.OtherMessage{Value: []byte("bar")},
want: &pb.OtherMessage{Value: []byte("foo")},
},
}
func TestMerge(t *testing.T) {

View File

@ -43,11 +43,6 @@ import (
"reflect"
)
// ErrWrongType occurs when the wire encoding for the field disagrees with
// that specified in the type being decoded. This is usually caused by attempting
// to convert an encoded protocol buffer into a struct of the wrong type.
var ErrWrongType = errors.New("proto: field/encoding mismatch: wrong type for field")
// errOverflow is returned when an integer is too large to be represented.
var errOverflow = errors.New("proto: integer overflow")
@ -235,12 +230,6 @@ func (o *Buffer) skipAndSave(t reflect.Type, tag, wire int, base structPointer,
ptr := structPointer_Bytes(base, unrecField)
if *ptr == nil {
// This is the first skipped element,
// allocate a new buffer.
*ptr = o.bufalloc()
}
// Add the skipped field to struct field
obuf := o.buf
@ -369,11 +358,11 @@ func (o *Buffer) unmarshalType(st reflect.Type, prop *StructProperties, is_group
if is_group {
return nil // input is satisfied
}
return ErrWrongType
return fmt.Errorf("proto: %s: wiretype end group for non-group", st)
}
tag := int(u >> 3)
if tag <= 0 {
return fmt.Errorf("proto: illegal tag %d", tag)
return fmt.Errorf("proto: %s: illegal tag %d (wire type %d)", st, tag, wire)
}
fieldnum, ok := prop.decoderTags.get(tag)
if !ok {
@ -403,7 +392,7 @@ func (o *Buffer) unmarshalType(st reflect.Type, prop *StructProperties, is_group
// a packable field
dec = p.packedDec
} else {
err = ErrWrongType
err = fmt.Errorf("proto: bad wiretype for field %s.%s: got wiretype %d, want %d", st, st.Field(fieldnum).Name, wire, p.WireType)
continue
}
}

View File

@ -247,7 +247,7 @@ func (p *Buffer) Marshal(pb Message) error {
return ErrNil
}
if err == nil {
err = p.enc_struct(t.Elem(), GetProperties(t.Elem()), base)
err = p.enc_struct(GetProperties(t.Elem()), base)
}
if collectStats {
@ -271,7 +271,7 @@ func Size(pb Message) (n int) {
return 0
}
if err == nil {
n = size_struct(t.Elem(), GetProperties(t.Elem()), base)
n = size_struct(GetProperties(t.Elem()), base)
}
if collectStats {
@ -312,13 +312,37 @@ func (o *Buffer) enc_int32(p *Properties, base structPointer) error {
if word32_IsNil(v) {
return ErrNil
}
x := word32_Get(v)
x := int32(word32_Get(v)) // permit sign extension to use full 64-bit range
o.buf = append(o.buf, p.tagcode...)
p.valEnc(o, uint64(x))
return nil
}
func size_int32(p *Properties, base structPointer) (n int) {
v := structPointer_Word32(base, p.field)
if word32_IsNil(v) {
return 0
}
x := int32(word32_Get(v)) // permit sign extension to use full 64-bit range
n += len(p.tagcode)
n += p.valSize(uint64(x))
return
}
// Encode a uint32.
// Exactly the same as int32, except for no sign extension.
func (o *Buffer) enc_uint32(p *Properties, base structPointer) error {
v := structPointer_Word32(base, p.field)
if word32_IsNil(v) {
return ErrNil
}
x := word32_Get(v)
o.buf = append(o.buf, p.tagcode...)
p.valEnc(o, uint64(x))
return nil
}
func size_uint32(p *Properties, base structPointer) (n int) {
v := structPointer_Word32(base, p.field)
if word32_IsNil(v) {
return 0
@ -405,7 +429,7 @@ func (o *Buffer) enc_struct_message(p *Properties, base structPointer) error {
}
o.buf = append(o.buf, p.tagcode...)
return o.enc_len_struct(p.stype, p.sprop, structp, &state)
return o.enc_len_struct(p.sprop, structp, &state)
}
func size_struct_message(p *Properties, base structPointer) int {
@ -424,7 +448,7 @@ func size_struct_message(p *Properties, base structPointer) int {
}
n0 := len(p.tagcode)
n1 := size_struct(p.stype, p.sprop, structp)
n1 := size_struct(p.sprop, structp)
n2 := sizeVarint(uint64(n1)) // size of encoded length
return n0 + n1 + n2
}
@ -438,7 +462,7 @@ func (o *Buffer) enc_struct_group(p *Properties, base structPointer) error {
}
o.EncodeVarint(uint64((p.Tag << 3) | WireStartGroup))
err := o.enc_struct(p.stype, p.sprop, b)
err := o.enc_struct(p.sprop, b)
if err != nil && !state.shouldContinue(err, nil) {
return err
}
@ -453,7 +477,7 @@ func size_struct_group(p *Properties, base structPointer) (n int) {
}
n += sizeVarint(uint64((p.Tag << 3) | WireStartGroup))
n += size_struct(p.stype, p.sprop, b)
n += size_struct(p.sprop, b)
n += sizeVarint(uint64((p.Tag << 3) | WireEndGroup))
return
}
@ -546,7 +570,7 @@ func (o *Buffer) enc_slice_int32(p *Properties, base structPointer) error {
}
for i := 0; i < l; i++ {
o.buf = append(o.buf, p.tagcode...)
x := s.Index(i)
x := int32(s.Index(i)) // permit sign extension to use full 64-bit range
p.valEnc(o, uint64(x))
}
return nil
@ -560,7 +584,7 @@ func size_slice_int32(p *Properties, base structPointer) (n int) {
}
for i := 0; i < l; i++ {
n += len(p.tagcode)
x := s.Index(i)
x := int32(s.Index(i)) // permit sign extension to use full 64-bit range
n += p.valSize(uint64(x))
}
return
@ -568,6 +592,75 @@ func size_slice_int32(p *Properties, base structPointer) (n int) {
// Encode a slice of int32s ([]int32) in packed format.
func (o *Buffer) enc_slice_packed_int32(p *Properties, base structPointer) error {
s := structPointer_Word32Slice(base, p.field)
l := s.Len()
if l == 0 {
return ErrNil
}
// TODO: Reuse a Buffer.
buf := NewBuffer(nil)
for i := 0; i < l; i++ {
x := int32(s.Index(i)) // permit sign extension to use full 64-bit range
p.valEnc(buf, uint64(x))
}
o.buf = append(o.buf, p.tagcode...)
o.EncodeVarint(uint64(len(buf.buf)))
o.buf = append(o.buf, buf.buf...)
return nil
}
func size_slice_packed_int32(p *Properties, base structPointer) (n int) {
s := structPointer_Word32Slice(base, p.field)
l := s.Len()
if l == 0 {
return 0
}
var bufSize int
for i := 0; i < l; i++ {
x := int32(s.Index(i)) // permit sign extension to use full 64-bit range
bufSize += p.valSize(uint64(x))
}
n += len(p.tagcode)
n += sizeVarint(uint64(bufSize))
n += bufSize
return
}
// Encode a slice of uint32s ([]uint32).
// Exactly the same as int32, except for no sign extension.
func (o *Buffer) enc_slice_uint32(p *Properties, base structPointer) error {
s := structPointer_Word32Slice(base, p.field)
l := s.Len()
if l == 0 {
return ErrNil
}
for i := 0; i < l; i++ {
o.buf = append(o.buf, p.tagcode...)
x := s.Index(i)
p.valEnc(o, uint64(x))
}
return nil
}
func size_slice_uint32(p *Properties, base structPointer) (n int) {
s := structPointer_Word32Slice(base, p.field)
l := s.Len()
if l == 0 {
return 0
}
for i := 0; i < l; i++ {
n += len(p.tagcode)
x := s.Index(i)
n += p.valSize(uint64(x))
}
return
}
// Encode a slice of uint32s ([]uint32) in packed format.
// Exactly the same as int32, except for no sign extension.
func (o *Buffer) enc_slice_packed_uint32(p *Properties, base structPointer) error {
s := structPointer_Word32Slice(base, p.field)
l := s.Len()
if l == 0 {
@ -585,7 +678,7 @@ func (o *Buffer) enc_slice_packed_int32(p *Properties, base structPointer) error
return nil
}
func size_slice_packed_int32(p *Properties, base structPointer) (n int) {
func size_slice_packed_uint32(p *Properties, base structPointer) (n int) {
s := structPointer_Word32Slice(base, p.field)
l := s.Len()
if l == 0 {
@ -738,7 +831,7 @@ func (o *Buffer) enc_slice_struct_message(p *Properties, base structPointer) err
}
o.buf = append(o.buf, p.tagcode...)
err := o.enc_len_struct(p.stype, p.sprop, structp, &state)
err := o.enc_len_struct(p.sprop, structp, &state)
if err != nil && !state.shouldContinue(err, nil) {
if err == ErrNil {
return ErrRepeatedHasNil
@ -768,7 +861,7 @@ func size_slice_struct_message(p *Properties, base structPointer) (n int) {
continue
}
n0 := size_struct(p.stype, p.sprop, structp)
n0 := size_struct(p.sprop, structp)
n1 := sizeVarint(uint64(n0)) // size of encoded length
n += n0 + n1
}
@ -789,7 +882,7 @@ func (o *Buffer) enc_slice_struct_group(p *Properties, base structPointer) error
o.EncodeVarint(uint64((p.Tag << 3) | WireStartGroup))
err := o.enc_struct(p.stype, p.sprop, b)
err := o.enc_struct(p.sprop, b)
if err != nil && !state.shouldContinue(err, nil) {
if err == ErrNil {
@ -815,7 +908,7 @@ func size_slice_struct_group(p *Properties, base structPointer) (n int) {
return // return size up to this point
}
n += size_struct(p.stype, p.sprop, b)
n += size_struct(p.sprop, b)
}
return
}
@ -853,7 +946,7 @@ func size_map(p *Properties, base structPointer) int {
}
// Encode a struct.
func (o *Buffer) enc_struct(t reflect.Type, prop *StructProperties, base structPointer) error {
func (o *Buffer) enc_struct(prop *StructProperties, base structPointer) error {
var state errorState
// Encode fields in tag order so that decoders may use optimizations
// that depend on the ordering.
@ -885,7 +978,7 @@ func (o *Buffer) enc_struct(t reflect.Type, prop *StructProperties, base structP
return state.err
}
func size_struct(t reflect.Type, prop *StructProperties, base structPointer) (n int) {
func size_struct(prop *StructProperties, base structPointer) (n int) {
for _, i := range prop.order {
p := prop.Prop[i]
if p.size != nil {
@ -905,11 +998,11 @@ func size_struct(t reflect.Type, prop *StructProperties, base structPointer) (n
var zeroes [20]byte // longer than any conceivable sizeVarint
// Encode a struct, preceded by its encoded length (as a varint).
func (o *Buffer) enc_len_struct(t reflect.Type, prop *StructProperties, base structPointer, state *errorState) error {
func (o *Buffer) enc_len_struct(prop *StructProperties, base structPointer, state *errorState) error {
iLen := len(o.buf)
o.buf = append(o.buf, 0, 0, 0, 0) // reserve four bytes for length
iMsg := len(o.buf)
err := o.enc_struct(t, prop, base)
err := o.enc_struct(prop, base)
if err != nil && !state.shouldContinue(err, nil) {
return err
}

View File

@ -57,7 +57,7 @@ Equality is defined in this way:
although represented by []byte, is not a repeated field)
- Two unset fields are equal.
- Two unknown field sets are equal if their current
encoded state is equal. (TODO)
encoded state is equal.
- Two extension sets are equal iff they have corresponding
elements that are pairwise equal.
- Every other combination of things are not equal.

View File

@ -35,7 +35,7 @@ import (
"testing"
pb "./testdata"
. "github.com/coreos/etcd/third_party/code.google.com/p/gogoprotobuf/proto"
. "github.com/coreos/etcd/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
)
// Four identical base messages.

View File

@ -222,14 +222,13 @@ func ClearExtension(pb extendableProto, extension *ExtensionDesc) {
// GetExtension parses and returns the given extension of pb.
// If the extension is not present it returns ErrMissingExtension.
// If the returned extension is modified, SetExtension must be called
// for the modifications to be reflected in pb.
func GetExtension(pb extendableProto, extension *ExtensionDesc) (interface{}, error) {
if err := checkExtensionTypes(pb, extension); err != nil {
return nil, err
}
e, ok := pb.ExtensionMap()[extension.Field]
emap := pb.ExtensionMap()
e, ok := emap[extension.Field]
if !ok {
return nil, ErrMissingExtension
}
@ -254,6 +253,7 @@ func GetExtension(pb extendableProto, extension *ExtensionDesc) (interface{}, er
e.value = v
e.desc = extension
e.enc = nil
emap[extension.Field] = e
return e.value, nil
}
@ -302,6 +302,9 @@ func GetExtensions(pb Message, es []*ExtensionDesc) (extensions []interface{}, e
extensions = make([]interface{}, len(es))
for i, e := range es {
extensions[i], err = GetExtension(epb, e)
if err == ErrMissingExtension {
err = nil
}
if err != nil {
return
}

View File

@ -0,0 +1,94 @@
// Go support for Protocol Buffers - Google's data interchange format
//
// Copyright 2014 The Go Authors. All rights reserved.
// http://code.google.com/p/goprotobuf/
//
// 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 Google Inc. 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
// OWNER 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 proto_test
import (
"testing"
pb "./testdata"
"github.com/coreos/etcd/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
)
func TestGetExtensionsWithMissingExtensions(t *testing.T) {
msg := &pb.MyMessage{}
ext1 := &pb.Ext{}
if err := proto.SetExtension(msg, pb.E_Ext_More, ext1); err != nil {
t.Fatalf("Could not set ext1: %s", ext1)
}
exts, err := proto.GetExtensions(msg, []*proto.ExtensionDesc{
pb.E_Ext_More,
pb.E_Ext_Text,
})
if err != nil {
t.Fatalf("GetExtensions() failed: %s", err)
}
if exts[0] != ext1 {
t.Errorf("ext1 not in returned extensions: %T %v", exts[0], exts[0])
}
if exts[1] != nil {
t.Errorf("ext2 in returned extensions: %T %v", exts[1], exts[1])
}
}
func TestGetExtensionStability(t *testing.T) {
check := func(m *pb.MyMessage) bool {
ext1, err := proto.GetExtension(m, pb.E_Ext_More)
if err != nil {
t.Fatalf("GetExtension() failed: %s", err)
}
ext2, err := proto.GetExtension(m, pb.E_Ext_More)
if err != nil {
t.Fatalf("GetExtension() failed: %s", err)
}
return ext1 == ext2
}
msg := &pb.MyMessage{Count: proto.Int32(4)}
ext0 := &pb.Ext{}
if err := proto.SetExtension(msg, pb.E_Ext_More, ext0); err != nil {
t.Fatalf("Could not set ext1: %s", ext0)
}
if !check(msg) {
t.Errorf("GetExtension() not stable before marshaling")
}
bb, err := proto.Marshal(msg)
if err != nil {
t.Fatalf("Marshal() failed: %s", err)
}
msg1 := &pb.MyMessage{}
err = proto.Unmarshal(bb, msg1)
if err != nil {
t.Fatalf("Unmarshal() failed: %s", err)
}
if !check(msg1) {
t.Errorf("GetExtension() not stable after unmarshaling")
}
}

View File

@ -89,7 +89,7 @@
package example
import "github.com/coreos/etcd/third_party/code.google.com/p/gogoprotobuf/proto"
import "code.google.com/p/goprotobuf/proto"
type FOO int32
const (
@ -168,7 +168,7 @@
import (
"log"
"github.com/coreos/etcd/third_party/code.google.com/p/gogoprotobuf/proto"
"code.google.com/p/goprotobuf/proto"
"./example.pb"
)
@ -667,7 +667,7 @@ func buildDefaultMessage(t reflect.Type) (dm defaultMessage) {
}
// scalar fields without defaults
if prop.Default == "" {
if !prop.HasDefault {
dm.scalars = append(dm.scalars, sf)
continue
}

View File

@ -36,7 +36,10 @@ package proto
*/
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"reflect"
"sort"
)
@ -127,7 +130,7 @@ func (ms *MessageSet) Marshal(pb Message) error {
mti, ok := pb.(messageTypeIder)
if !ok {
return ErrWrongType // TODO: custom error?
return ErrNoMessageTypeId
}
mtid := mti.MessageTypeId()
@ -188,16 +191,84 @@ func UnmarshalMessageSet(buf []byte, m map[int32]Extension) error {
return err
}
for _, item := range ms.Item {
// restore wire type and field number varint, plus length varint.
b := EncodeVarint(uint64(*item.TypeId)<<3 | WireBytes)
b = append(b, EncodeVarint(uint64(len(item.Message)))...)
b = append(b, item.Message...)
id := *item.TypeId
msg := item.Message
m[*item.TypeId] = Extension{enc: b}
// Restore wire type and field number varint, plus length varint.
// Be careful to preserve duplicate items.
b := EncodeVarint(uint64(id)<<3 | WireBytes)
if ext, ok := m[id]; ok {
// Existing data; rip off the tag and length varint
// so we join the new data correctly.
// We can assume that ext.enc is set because we are unmarshaling.
o := ext.enc[len(b):] // skip wire type and field number
_, n := DecodeVarint(o) // calculate length of length varint
o = o[n:] // skip length varint
msg = append(o, msg...) // join old data and new data
}
b = append(b, EncodeVarint(uint64(len(msg)))...)
b = append(b, msg...)
m[id] = Extension{enc: b}
}
return nil
}
// MarshalMessageSetJSON encodes the extension map represented by m in JSON format.
// It is called by generated MarshalJSON methods on protocol buffer messages with the message_set_wire_format option.
func MarshalMessageSetJSON(m map[int32]Extension) ([]byte, error) {
var b bytes.Buffer
b.WriteByte('{')
// Process the map in key order for deterministic output.
ids := make([]int32, 0, len(m))
for id := range m {
ids = append(ids, id)
}
sort.Sort(int32Slice(ids)) // int32Slice defined in text.go
for i, id := range ids {
ext := m[id]
if i > 0 {
b.WriteByte(',')
}
msd, ok := messageSetMap[id]
if !ok {
// Unknown type; we can't render it, so skip it.
continue
}
fmt.Fprintf(&b, `"[%s]":`, msd.name)
x := ext.value
if x == nil {
x = reflect.New(msd.t.Elem()).Interface()
if err := Unmarshal(ext.enc, x.(Message)); err != nil {
return nil, err
}
}
d, err := json.Marshal(x)
if err != nil {
return nil, err
}
b.Write(d)
}
b.WriteByte('}')
return b.Bytes(), nil
}
// UnmarshalMessageSetJSON decodes the extension map encoded in buf in JSON format.
// It is called by generated UnmarshalJSON methods on protocol buffer messages with the message_set_wire_format option.
func UnmarshalMessageSetJSON(buf []byte, m map[int32]Extension) error {
// Common-case fast path.
if len(buf) == 0 || bytes.Equal(buf, []byte("{}")) {
return nil
}
// This is fairly tricky, and it's not clear that it is needed.
return errors.New("TODO: UnmarshalMessageSetJSON not yet implemented")
}
// A global registry of types that can be used in a MessageSet.
var messageSetMap = make(map[int32]messageSetDesc)
@ -208,9 +279,9 @@ type messageSetDesc struct {
}
// RegisterMessageSetType is called from the generated code.
func RegisterMessageSetType(i messageTypeIder, name string) {
messageSetMap[i.MessageTypeId()] = messageSetDesc{
t: reflect.TypeOf(i),
func RegisterMessageSetType(m Message, fieldNum int32, name string) {
messageSetMap[fieldNum] = messageSetDesc{
t: reflect.TypeOf(m),
name: name,
}
}

View File

@ -0,0 +1,66 @@
// Go support for Protocol Buffers - Google's data interchange format
//
// Copyright 2014 The Go Authors. All rights reserved.
// http://code.google.com/p/goprotobuf/
//
// 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 Google Inc. 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
// OWNER 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 proto
import (
"bytes"
"testing"
)
func TestUnmarshalMessageSetWithDuplicate(t *testing.T) {
// Check that a repeated message set entry will be concatenated.
in := &MessageSet{
Item: []*_MessageSet_Item{
{TypeId: Int32(12345), Message: []byte("hoo")},
{TypeId: Int32(12345), Message: []byte("hah")},
},
}
b, err := Marshal(in)
if err != nil {
t.Fatalf("Marshal: %v", err)
}
t.Logf("Marshaled bytes: %q", b)
m := make(map[int32]Extension)
if err := UnmarshalMessageSet(b, m); err != nil {
t.Fatalf("UnmarshalMessageSet: %v", err)
}
ext, ok := m[12345]
if !ok {
t.Fatalf("Didn't retrieve extension 12345; map is %v", m)
}
// Skip wire type/field number and length varints.
got := skipVarint(skipVarint(ext.enc))
if want := []byte("hoohah"); !bytes.Equal(got, want) {
t.Errorf("Combined extension is %q, want %q", got, want)
}
}

View File

@ -29,7 +29,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// +build appengine
// +build appengine,!appenginevm
// This file contains an implementation of proto field accesses using package reflect.
// It is slower than the code in pointer_unsafe.go but it avoids package unsafe and can

View File

@ -29,7 +29,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// +build !appengine
// +build !appengine appenginevm
// This file contains the implementation of the proto field accesses using package unsafe.

View File

@ -145,17 +145,19 @@ func (sp *StructProperties) Swap(i, j int) { sp.order[i], sp.order[j] = sp.order
// Properties represents the protocol-specific behavior of a single struct field.
type Properties struct {
Name string // name of the field, for error messages
OrigName string // original name before protocol compiler (always set)
Wire string
WireType int
Tag int
Required bool
Optional bool
Repeated bool
Packed bool // relevant for repeated primitives only
Enum string // set for enum types only
Name string // name of the field, for error messages
OrigName string // original name before protocol compiler (always set)
Wire string
WireType int
Tag int
Required bool
Optional bool
Repeated bool
Packed bool // relevant for repeated primitives only
Enum string // set for enum types only
Default string // default value
HasDefault bool // whether an explicit default was provided
def_uint64 uint64
enc encoder
@ -201,7 +203,7 @@ func (p *Properties) String() string {
if len(p.Enum) > 0 {
s += ",enum=" + p.Enum
}
if len(p.Default) > 0 {
if p.HasDefault {
s += ",def=" + p.Default
}
return s
@ -273,6 +275,7 @@ func (p *Properties) Parse(s string) {
case strings.HasPrefix(f, "enum="):
p.Enum = f[5:]
case strings.HasPrefix(f, "def="):
p.HasDefault = true
p.Default = f[4:] // rest of string
if i+1 < len(fields) {
// Commas aren't escaped, and def is always last.
@ -297,7 +300,7 @@ func (p *Properties) setEncAndDec(typ reflect.Type, lockGetProp bool) {
switch t1 := typ; t1.Kind() {
default:
fmt.Fprintf(os.Stderr, "proto: no coders for %T\n", t1)
fmt.Fprintf(os.Stderr, "proto: no coders for %v\n", t1)
case reflect.Ptr:
switch t2 := t1.Elem(); t2.Kind() {
@ -308,18 +311,22 @@ func (p *Properties) setEncAndDec(typ reflect.Type, lockGetProp bool) {
p.enc = (*Buffer).enc_bool
p.dec = (*Buffer).dec_bool
p.size = size_bool
case reflect.Int32, reflect.Uint32:
case reflect.Int32:
p.enc = (*Buffer).enc_int32
p.dec = (*Buffer).dec_int32
p.size = size_int32
case reflect.Uint32:
p.enc = (*Buffer).enc_uint32
p.dec = (*Buffer).dec_int32 // can reuse
p.size = size_uint32
case reflect.Int64, reflect.Uint64:
p.enc = (*Buffer).enc_int64
p.dec = (*Buffer).dec_int64
p.size = size_int64
case reflect.Float32:
p.enc = (*Buffer).enc_int32 // can just treat them as bits
p.enc = (*Buffer).enc_uint32 // can just treat them as bits
p.dec = (*Buffer).dec_int32
p.size = size_int32
p.size = size_uint32
case reflect.Float64:
p.enc = (*Buffer).enc_int64 // can just treat them as bits
p.dec = (*Buffer).dec_int64
@ -358,48 +365,50 @@ func (p *Properties) setEncAndDec(typ reflect.Type, lockGetProp bool) {
}
p.dec = (*Buffer).dec_slice_bool
p.packedDec = (*Buffer).dec_slice_packed_bool
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
switch t2.Bits() {
case 32:
if p.Packed {
p.enc = (*Buffer).enc_slice_packed_int32
p.size = size_slice_packed_int32
} else {
p.enc = (*Buffer).enc_slice_int32
p.size = size_slice_int32
}
p.dec = (*Buffer).dec_slice_int32
p.packedDec = (*Buffer).dec_slice_packed_int32
case 64:
if p.Packed {
p.enc = (*Buffer).enc_slice_packed_int64
p.size = size_slice_packed_int64
} else {
p.enc = (*Buffer).enc_slice_int64
p.size = size_slice_int64
}
p.dec = (*Buffer).dec_slice_int64
p.packedDec = (*Buffer).dec_slice_packed_int64
case 8:
if t2.Kind() == reflect.Uint8 {
p.enc = (*Buffer).enc_slice_byte
p.dec = (*Buffer).dec_slice_byte
p.size = size_slice_byte
}
default:
logNoSliceEnc(t1, t2)
break
case reflect.Int32:
if p.Packed {
p.enc = (*Buffer).enc_slice_packed_int32
p.size = size_slice_packed_int32
} else {
p.enc = (*Buffer).enc_slice_int32
p.size = size_slice_int32
}
p.dec = (*Buffer).dec_slice_int32
p.packedDec = (*Buffer).dec_slice_packed_int32
case reflect.Uint32:
if p.Packed {
p.enc = (*Buffer).enc_slice_packed_uint32
p.size = size_slice_packed_uint32
} else {
p.enc = (*Buffer).enc_slice_uint32
p.size = size_slice_uint32
}
p.dec = (*Buffer).dec_slice_int32
p.packedDec = (*Buffer).dec_slice_packed_int32
case reflect.Int64, reflect.Uint64:
if p.Packed {
p.enc = (*Buffer).enc_slice_packed_int64
p.size = size_slice_packed_int64
} else {
p.enc = (*Buffer).enc_slice_int64
p.size = size_slice_int64
}
p.dec = (*Buffer).dec_slice_int64
p.packedDec = (*Buffer).dec_slice_packed_int64
case reflect.Uint8:
p.enc = (*Buffer).enc_slice_byte
p.dec = (*Buffer).dec_slice_byte
p.size = size_slice_byte
case reflect.Float32, reflect.Float64:
switch t2.Bits() {
case 32:
// can just treat them as bits
if p.Packed {
p.enc = (*Buffer).enc_slice_packed_int32
p.size = size_slice_packed_int32
p.enc = (*Buffer).enc_slice_packed_uint32
p.size = size_slice_packed_uint32
} else {
p.enc = (*Buffer).enc_slice_int32
p.size = size_slice_int32
p.enc = (*Buffer).enc_slice_uint32
p.size = size_slice_uint32
}
p.dec = (*Buffer).dec_slice_int32
p.packedDec = (*Buffer).dec_slice_packed_int32
@ -529,7 +538,11 @@ var (
)
// GetProperties returns the list of properties for the type represented by t.
// t must represent a generated struct type of a protocol message.
func GetProperties(t reflect.Type) *StructProperties {
if t.Kind() != reflect.Struct {
panic("proto: type must have kind struct")
}
mutex.Lock()
sprop := getPropertiesLocked(t)
mutex.Unlock()

View File

@ -36,7 +36,7 @@ import (
"testing"
pb "./testdata"
. "github.com/coreos/etcd/third_party/code.google.com/p/gogoprotobuf/proto"
. "github.com/coreos/etcd/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
)
var messageWithExtension1 = &pb.MyMessage{Count: Int32(7)}
@ -65,8 +65,10 @@ var SizeTests = []struct {
// Basic types.
{"bool", &pb.Defaults{F_Bool: Bool(true)}},
{"int32", &pb.Defaults{F_Int32: Int32(12)}},
{"negative int32", &pb.Defaults{F_Int32: Int32(-1)}},
{"small int64", &pb.Defaults{F_Int64: Int64(1)}},
{"big int64", &pb.Defaults{F_Int64: Int64(1 << 20)}},
{"negative int64", &pb.Defaults{F_Int64: Int64(-1)}},
{"fixed32", &pb.Defaults{F_Fixed32: Uint32(71)}},
{"fixed64", &pb.Defaults{F_Fixed64: Uint64(72)}},
{"uint32", &pb.Defaults{F_Uint32: Uint32(123)}},
@ -83,7 +85,7 @@ var SizeTests = []struct {
{"empty repeated bool", &pb.MoreRepeated{Bools: []bool{}}},
{"repeated bool", &pb.MoreRepeated{Bools: []bool{false, true, true, false}}},
{"packed repeated bool", &pb.MoreRepeated{BoolsPacked: []bool{false, true, true, false, true, true, true}}},
{"repeated int32", &pb.MoreRepeated{Ints: []int32{1, 12203, 1729}}},
{"repeated int32", &pb.MoreRepeated{Ints: []int32{1, 12203, 1729, -1}}},
{"repeated int32 packed", &pb.MoreRepeated{IntsPacked: []int32{1, 12203, 1729}}},
{"repeated int64 packed", &pb.MoreRepeated{Int64SPacked: []int64{
// Need enough large numbers to verify that the header is counting the number of bytes

File diff suppressed because it is too large Load Diff

View File

@ -203,6 +203,8 @@ message OldMessage {
optional string name = 1;
}
optional Nested nested = 1;
optional int32 num = 2;
}
// NewMessage is wire compatible with OldMessage;
@ -213,6 +215,9 @@ message NewMessage {
optional string food_group = 2;
}
optional Nested nested = 1;
// This is an int32 in OldMessage.
optional int64 num = 2;
}
// Smaller tests for ASCII formatting.
@ -376,6 +381,9 @@ message Defaults {
// Sub-message.
optional SubDefaults sub = 18;
// Redundant but explicit defaults.
optional string str_zero = 19 [default=""];
}
message SubDefaults {

View File

@ -36,6 +36,7 @@ package proto
import (
"bufio"
"bytes"
"encoding"
"fmt"
"io"
"log"
@ -225,7 +226,16 @@ func writeStruct(w *textWriter, sv reflect.Value) error {
return err
}
}
if err := writeAny(w, fv.Index(j), props); err != nil {
v := fv.Index(j)
if v.Kind() == reflect.Ptr && v.IsNil() {
// A nil message in a repeated field is not valid,
// but we can handle that more gracefully than panicking.
if _, err := w.Write([]byte("<nil>\n")); err != nil {
return err
}
continue
}
if err := writeAny(w, v, props); err != nil {
return err
}
if err := w.WriteByte('\n'); err != nil {
@ -342,7 +352,15 @@ func writeAny(w *textWriter, v reflect.Value, props *Properties) error {
}
}
w.indent()
if err := writeStruct(w, v); err != nil {
if tm, ok := v.Interface().(encoding.TextMarshaler); ok {
text, err := tm.MarshalText()
if err != nil {
return err
}
if _, err = w.Write(text); err != nil {
return err
}
} else if err := writeStruct(w, v); err != nil {
return err
}
w.unindent()
@ -629,6 +647,19 @@ func marshalText(w io.Writer, pb Message, compact bool) error {
compact: compact,
}
if tm, ok := pb.(encoding.TextMarshaler); ok {
text, err := tm.MarshalText()
if err != nil {
return err
}
if _, err = aw.Write(text); err != nil {
return err
}
if bw != nil {
return bw.Flush()
}
return nil
}
// Dereference the received pointer so we don't have outer < and >.
v := reflect.Indirect(val)
if err := writeStruct(aw, v); err != nil {
@ -642,7 +673,9 @@ func marshalText(w io.Writer, pb Message, compact bool) error {
// MarshalText writes a given protocol buffer in text format.
// The only errors returned are from w.
func MarshalText(w io.Writer, pb Message) error { return marshalText(w, pb, false) }
func MarshalText(w io.Writer, pb Message) error {
return marshalText(w, pb, false)
}
// MarshalTextString is the same as MarshalText, but returns the string directly.
func MarshalTextString(pb Message) string {

View File

@ -35,6 +35,7 @@ package proto
// TODO: message sets.
import (
"encoding"
"errors"
"fmt"
"reflect"
@ -354,8 +355,8 @@ func (p *textParser) next() *token {
return &p.cur
}
// Return an error indicating which required field was not set.
func (p *textParser) missingRequiredFieldError(sv reflect.Value) *ParseError {
// Return a RequiredNotSetError indicating which required field was not set.
func (p *textParser) missingRequiredFieldError(sv reflect.Value) *RequiredNotSetError {
st := sv.Type()
sprops := GetProperties(st)
for i := 0; i < st.NumField(); i++ {
@ -365,10 +366,10 @@ func (p *textParser) missingRequiredFieldError(sv reflect.Value) *ParseError {
props := sprops.Prop[i]
if props.Required {
return p.errorf("message %v missing required field %q", st, props.OrigName)
return &RequiredNotSetError{fmt.Sprintf("%v.%v", st, props.OrigName)}
}
}
return p.errorf("message %v missing required field", st) // should not happen
return &RequiredNotSetError{fmt.Sprintf("%v.<unknown field name>", st)} // should not happen
}
// Returns the index in the struct for the named field, as well as the parsed tag properties.
@ -419,9 +420,11 @@ func (p *textParser) checkForColon(props *Properties, typ reflect.Type) *ParseEr
return nil
}
func (p *textParser) readStruct(sv reflect.Value, terminator string) *ParseError {
func (p *textParser) readStruct(sv reflect.Value, terminator string) error {
st := sv.Type()
reqCount := GetProperties(st).reqCount
var reqFieldErr error
fieldSet := make(map[string]bool)
// A struct is a sequence of "name: value", terminated by one of
// '>' or '}', or the end of the input. A name may also be
// "[extension]".
@ -482,7 +485,10 @@ func (p *textParser) readStruct(sv reflect.Value, terminator string) *ParseError
ext = reflect.New(typ.Elem()).Elem()
}
if err := p.readAny(ext, props); err != nil {
return err
if _, ok := err.(*RequiredNotSetError); !ok {
return err
}
reqFieldErr = err
}
ep := sv.Addr().Interface().(extendableProto)
if !rep {
@ -500,17 +506,17 @@ func (p *textParser) readStruct(sv reflect.Value, terminator string) *ParseError
}
} else {
// This is a normal, non-extension field.
fi, props, ok := structFieldByName(st, tok.value)
name := tok.value
fi, props, ok := structFieldByName(st, name)
if !ok {
return p.errorf("unknown field name %q in %v", tok.value, st)
return p.errorf("unknown field name %q in %v", name, st)
}
dst := sv.Field(fi)
isDstNil := isNil(dst)
// Check that it's not already set if it's not a repeated field.
if !props.Repeated && !isDstNil {
return p.errorf("non-repeated field %q was repeated", tok.value)
if !props.Repeated && fieldSet[name] {
return p.errorf("non-repeated field %q was repeated", name)
}
if err := p.checkForColon(props, st.Field(fi).Type); err != nil {
@ -518,11 +524,13 @@ func (p *textParser) readStruct(sv reflect.Value, terminator string) *ParseError
}
// Parse into the field.
fieldSet[name] = true
if err := p.readAny(dst, props); err != nil {
return err
}
if props.Required {
if _, ok := err.(*RequiredNotSetError); !ok {
return err
}
reqFieldErr = err
} else if props.Required {
reqCount--
}
}
@ -540,10 +548,10 @@ func (p *textParser) readStruct(sv reflect.Value, terminator string) *ParseError
if reqCount > 0 {
return p.missingRequiredFieldError(sv)
}
return nil
return reqFieldErr
}
func (p *textParser) readAny(v reflect.Value, props *Properties) *ParseError {
func (p *textParser) readAny(v reflect.Value, props *Properties) error {
tok := p.next()
if tok.err != nil {
return tok.err
@ -605,6 +613,7 @@ func (p *textParser) readAny(v reflect.Value, props *Properties) *ParseError {
fv.SetInt(x)
return nil
}
if len(props.Enum) == 0 {
break
}
@ -623,6 +632,7 @@ func (p *textParser) readAny(v reflect.Value, props *Properties) *ParseError {
fv.SetInt(x)
return nil
}
case reflect.Ptr:
// A basic field (indirected through pointer), or a repeated message/group
p.back()
@ -643,6 +653,7 @@ func (p *textParser) readAny(v reflect.Value, props *Properties) *ParseError {
default:
return p.errorf("expected '{' or '<', found %q", tok.value)
}
// TODO: Handle nested messages which implement encoding.TextUnmarshaler.
return p.readStruct(fv, terminator)
case reflect.Uint32:
if x, err := strconv.ParseUint(tok.value, 0, 32); err == nil {
@ -660,7 +671,13 @@ func (p *textParser) readAny(v reflect.Value, props *Properties) *ParseError {
// UnmarshalText reads a protocol buffer in Text format. UnmarshalText resets pb
// before starting to unmarshal, so any existing data in pb is always removed.
// If a required field is not set and no other error occurs,
// UnmarshalText returns *RequiredNotSetError.
func UnmarshalText(s string, pb Message) error {
if um, ok := pb.(encoding.TextUnmarshaler); ok {
err := um.UnmarshalText([]byte(s))
return err
}
pb.Reset()
v := reflect.ValueOf(pb)
if pe := newTextParser(s).readStruct(v.Elem(), ""); pe != nil {

View File

@ -37,7 +37,7 @@ import (
"testing"
. "./testdata"
. "github.com/coreos/etcd/third_party/code.google.com/p/gogoprotobuf/proto"
. "github.com/coreos/etcd/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
)
type UnmarshalTextTest struct {
@ -156,8 +156,8 @@ var unMarshalTextTests = []UnmarshalTextTest{
// Number too large for int64
{
in: "count: 123456789012345678901",
err: "line 1.7: invalid int32: 123456789012345678901",
in: "count: 1 others { key: 123456789012345678901 }",
err: "line 1.23: invalid int64: 123456789012345678901",
},
// Number too large for int32
@ -294,8 +294,11 @@ var unMarshalTextTests = []UnmarshalTextTest{
// Missing required field
{
in: ``,
err: `line 1.0: message testdata.MyMessage missing required field "count"`,
in: `name: "Pawel"`,
err: `proto: required field "testdata.MyMessage.count" not set`,
out: &MyMessage{
Name: String("Pawel"),
},
},
// Repeated non-repeated field
@ -408,6 +411,9 @@ func TestUnmarshalText(t *testing.T) {
} else if err.Error() != test.err {
t.Errorf("Test %d: Incorrect error.\nHave: %v\nWant: %v",
i, err.Error(), test.err)
} else if _, ok := err.(*RequiredNotSetError); ok && test.out != nil && !reflect.DeepEqual(pb, test.out) {
t.Errorf("Test %d: Incorrect populated \nHave: %v\nWant: %v",
i, pb, test.out)
}
}
}

View File

@ -39,9 +39,8 @@ import (
"strings"
"testing"
"github.com/coreos/etcd/third_party/code.google.com/p/gogoprotobuf/proto"
pb "./testdata"
"github.com/coreos/etcd/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
)
// textMessage implements the methods that allow it to marshal and unmarshal
@ -385,3 +384,24 @@ func TestFloats(t *testing.T) {
}
}
}
func TestRepeatedNilText(t *testing.T) {
m := &pb.MessageList{
Message: []*pb.MessageList_Message{
nil,
&pb.MessageList_Message{
Name: proto.String("Horse"),
},
nil,
},
}
want := `Message <nil>
Message {
name: "Horse"
}
Message <nil>
`
if s := proto.MarshalTextString(m); s != want {
t.Errorf(" got: %s\nwant: %s", s, want)
}
}

View File

@ -0,0 +1,6 @@
language: go
go: 1.1
script:
- go vet ./...
- go test -v ./...

View File

@ -0,0 +1,21 @@
Copyright (C) 2013 Jeremy Saenz
All Rights Reserved.
MIT LICENSE
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.

View File

@ -0,0 +1,287 @@
[![Build Status](https://travis-ci.org/codegangsta/cli.png?branch=master)](https://travis-ci.org/codegangsta/cli)
# cli.go
cli.go is simple, fast, and fun package for building command line apps in Go. The goal is to enable developers to write fast and distributable command line applications in an expressive way.
You can view the API docs here:
http://godoc.org/github.com/codegangsta/cli
## Overview
Command line apps are usually so tiny that there is absolutely no reason why your code should *not* be self-documenting. Things like generating help text and parsing command flags/options should not hinder productivity when writing a command line app.
**This is where cli.go comes into play.** cli.go makes command line programming fun, organized, and expressive!
## Installation
Make sure you have a working Go environment (go 1.1 is *required*). [See the install instructions](http://golang.org/doc/install.html).
To install `cli.go`, simply run:
```
$ go get github.com/codegangsta/cli
```
Make sure your `PATH` includes to the `$GOPATH/bin` directory so your commands can be easily used:
```
export PATH=$PATH:$GOPATH/bin
```
## Getting Started
One of the philosophies behind cli.go is that an API should be playful and full of discovery. So a cli.go app can be as little as one line of code in `main()`.
``` go
package main
import (
"os"
"github.com/codegangsta/cli"
)
func main() {
cli.NewApp().Run(os.Args)
}
```
This app will run and show help text, but is not very useful. Let's give an action to execute and some help documentation:
``` go
package main
import (
"os"
"github.com/codegangsta/cli"
)
func main() {
app := cli.NewApp()
app.Name = "boom"
app.Usage = "make an explosive entrance"
app.Action = func(c *cli.Context) {
println("boom! I say!")
}
app.Run(os.Args)
}
```
Running this already gives you a ton of functionality, plus support for things like subcommands and flags, which are covered below.
## Example
Being a programmer can be a lonely job. Thankfully by the power of automation that is not the case! Let's create a greeter app to fend off our demons of loneliness!
``` go
/* greet.go */
package main
import (
"os"
"github.com/codegangsta/cli"
)
func main() {
app := cli.NewApp()
app.Name = "greet"
app.Usage = "fight the loneliness!"
app.Action = func(c *cli.Context) {
println("Hello friend!")
}
app.Run(os.Args)
}
```
Install our command to the `$GOPATH/bin` directory:
```
$ go install
```
Finally run our new command:
```
$ greet
Hello friend!
```
cli.go also generates some bitchass help text:
```
$ greet help
NAME:
greet - fight the loneliness!
USAGE:
greet [global options] command [command options] [arguments...]
VERSION:
0.0.0
COMMANDS:
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS
--version Shows version information
```
### Arguments
You can lookup arguments by calling the `Args` function on `cli.Context`.
``` go
...
app.Action = func(c *cli.Context) {
println("Hello", c.Args()[0])
}
...
```
### Flags
Setting and querying flags is simple.
``` go
...
app.Flags = []cli.Flag {
cli.StringFlag{
Name: "lang",
Value: "english",
Usage: "language for the greeting",
},
}
app.Action = func(c *cli.Context) {
name := "someone"
if len(c.Args()) > 0 {
name = c.Args()[0]
}
if c.String("lang") == "spanish" {
println("Hola", name)
} else {
println("Hello", name)
}
}
...
```
#### Alternate Names
You can set alternate (or short) names for flags by providing a comma-delimited list for the `Name`. e.g.
``` go
app.Flags = []cli.Flag {
cli.StringFlag{
Name: "lang, l",
Value: "english",
Usage: "language for the greeting",
},
}
```
#### Values from the Environment
You can also have the default value set from the environment via `EnvVar`. e.g.
``` go
app.Flags = []cli.Flag {
cli.StringFlag{
Name: "lang, l",
Value: "english",
Usage: "language for the greeting",
EnvVar: "APP_LANG",
},
}
```
That flag can then be set with `--lang spanish` or `-l spanish`. Note that giving two different forms of the same flag in the same command invocation is an error.
### Subcommands
Subcommands can be defined for a more git-like command line app.
```go
...
app.Commands = []cli.Command{
{
Name: "add",
ShortName: "a",
Usage: "add a task to the list",
Action: func(c *cli.Context) {
println("added task: ", c.Args().First())
},
},
{
Name: "complete",
ShortName: "c",
Usage: "complete a task on the list",
Action: func(c *cli.Context) {
println("completed task: ", c.Args().First())
},
},
{
Name: "template",
ShortName: "r",
Usage: "options for task templates",
Subcommands: []cli.Command{
{
Name: "add",
Usage: "add a new template",
Action: func(c *cli.Context) {
println("new task template: ", c.Args().First())
},
},
{
Name: "remove",
Usage: "remove an existing template",
Action: func(c *cli.Context) {
println("removed task template: ", c.Args().First())
},
},
},
},
}
...
```
### Bash Completion
You can enable completion commands by setting the `EnableBashCompletion`
flag on the `App` object. By default, this setting will only auto-complete to
show an app's subcommands, but you can write your own completion methods for
the App or its subcommands.
```go
...
var tasks = []string{"cook", "clean", "laundry", "eat", "sleep", "code"}
app := cli.NewApp()
app.EnableBashCompletion = true
app.Commands = []cli.Command{
{
Name: "complete",
ShortName: "c",
Usage: "complete a task on the list",
Action: func(c *cli.Context) {
println("completed task: ", c.Args().First())
},
BashComplete: func(c *cli.Context) {
// This will complete if no args are passed
if len(c.Args()) > 0 {
return
}
for _, t := range tasks {
fmt.Println(t)
}
},
}
}
...
```
#### To Enable
Source the `autocomplete/bash_autocomplete` file in your `.bashrc` file while
setting the `PROG` variable to the name of your program:
`PROG=myprogram source /.../cli/autocomplete/bash_autocomplete`
## Contribution Guidelines
Feel free to put up a pull request to fix a bug or maybe add a feature. I will give it a code review and make sure that it does not break backwards compatibility. If I or any other collaborators agree that it is in line with the vision of the project, we will work with you to get the code into a mergeable state and merge it into the master branch.
If you are have contributed something significant to the project, I will most likely add you as a collaborator. As a collaborator you are given the ability to merge others pull requests. It is very important that new code does not break existing code, so be careful about what code you do choose to merge. If you have any questions feel free to link @codegangsta to the issue in question and we can review it together.
If you feel like you have contributed to the project but have not yet been added as a collaborator, I probably forgot to add you. Hit @codegangsta up over email and we will get it figured out.
## About
cli.go is written by none other than the [Code Gangsta](http://codegangsta.io)

246
Godeps/_workspace/src/github.com/codegangsta/cli/app.go generated vendored Normal file
View File

@ -0,0 +1,246 @@
package cli
import (
"fmt"
"io/ioutil"
"os"
"time"
)
// App is the main structure of a cli application. It is recomended that
// and app be created with the cli.NewApp() function
type App struct {
// The name of the program. Defaults to os.Args[0]
Name string
// Description of the program.
Usage string
// Version of the program
Version string
// List of commands to execute
Commands []Command
// List of flags to parse
Flags []Flag
// Boolean to enable bash completion commands
EnableBashCompletion bool
// Boolean to hide built-in help command
HideHelp bool
// An action to execute when the bash-completion flag is set
BashComplete func(context *Context)
// An action to execute before any subcommands are run, but after the context is ready
// If a non-nil error is returned, no subcommands are run
Before func(context *Context) error
// The action to execute when no subcommands are specified
Action func(context *Context)
// Execute this function if the proper command cannot be found
CommandNotFound func(context *Context, command string)
// Compilation date
Compiled time.Time
// Author
Author string
// Author e-mail
Email string
}
// Tries to find out when this binary was compiled.
// Returns the current time if it fails to find it.
func compileTime() time.Time {
info, err := os.Stat(os.Args[0])
if err != nil {
return time.Now()
}
return info.ModTime()
}
// Creates a new cli Application with some reasonable defaults for Name, Usage, Version and Action.
func NewApp() *App {
return &App{
Name: os.Args[0],
Usage: "A new cli application",
Version: "0.0.0",
BashComplete: DefaultAppComplete,
Action: helpCommand.Action,
Compiled: compileTime(),
}
}
// Entry point to the cli app. Parses the arguments slice and routes to the proper flag/args combination
func (a *App) Run(arguments []string) error {
// append help to commands
if a.Command(helpCommand.Name) == nil && !a.HideHelp {
a.Commands = append(a.Commands, helpCommand)
a.appendFlag(HelpFlag)
}
//append version/help flags
if a.EnableBashCompletion {
a.appendFlag(BashCompletionFlag)
}
a.appendFlag(VersionFlag)
// parse flags
set := flagSet(a.Name, a.Flags)
set.SetOutput(ioutil.Discard)
err := set.Parse(arguments[1:])
nerr := normalizeFlags(a.Flags, set)
if nerr != nil {
fmt.Println(nerr)
context := NewContext(a, set, set)
ShowAppHelp(context)
fmt.Println("")
return nerr
}
context := NewContext(a, set, set)
if err != nil {
fmt.Printf("Incorrect Usage.\n\n")
ShowAppHelp(context)
fmt.Println("")
return err
}
if checkCompletions(context) {
return nil
}
if checkHelp(context) {
return nil
}
if checkVersion(context) {
return nil
}
if a.Before != nil {
err := a.Before(context)
if err != nil {
return err
}
}
args := context.Args()
if args.Present() {
name := args.First()
c := a.Command(name)
if c != nil {
return c.Run(context)
}
}
// Run default Action
a.Action(context)
return nil
}
// Another entry point to the cli app, takes care of passing arguments and error handling
func (a *App) RunAndExitOnError() {
if err := a.Run(os.Args); err != nil {
os.Stderr.WriteString(fmt.Sprintln(err))
os.Exit(1)
}
}
// Invokes the subcommand given the context, parses ctx.Args() to generate command-specific flags
func (a *App) RunAsSubcommand(ctx *Context) error {
// append help to commands
if len(a.Commands) > 0 {
if a.Command(helpCommand.Name) == nil && !a.HideHelp {
a.Commands = append(a.Commands, helpCommand)
a.appendFlag(HelpFlag)
}
}
// append flags
if a.EnableBashCompletion {
a.appendFlag(BashCompletionFlag)
}
// parse flags
set := flagSet(a.Name, a.Flags)
set.SetOutput(ioutil.Discard)
err := set.Parse(ctx.Args().Tail())
nerr := normalizeFlags(a.Flags, set)
context := NewContext(a, set, ctx.globalSet)
if nerr != nil {
fmt.Println(nerr)
if len(a.Commands) > 0 {
ShowSubcommandHelp(context)
} else {
ShowCommandHelp(ctx, context.Args().First())
}
fmt.Println("")
return nerr
}
if err != nil {
fmt.Printf("Incorrect Usage.\n\n")
ShowSubcommandHelp(context)
return err
}
if checkCompletions(context) {
return nil
}
if len(a.Commands) > 0 {
if checkSubcommandHelp(context) {
return nil
}
} else {
if checkCommandHelp(ctx, context.Args().First()) {
return nil
}
}
if a.Before != nil {
err := a.Before(context)
if err != nil {
return err
}
}
args := context.Args()
if args.Present() {
name := args.First()
c := a.Command(name)
if c != nil {
return c.Run(context)
}
}
// Run default Action
if len(a.Commands) > 0 {
a.Action(context)
} else {
a.Action(ctx)
}
return nil
}
// Returns the named command on App. Returns nil if the command does not exist
func (a *App) Command(name string) *Command {
for _, c := range a.Commands {
if c.HasName(name) {
return &c
}
}
return nil
}
func (a *App) hasFlag(flag Flag) bool {
for _, f := range a.Flags {
if flag == f {
return true
}
}
return false
}
func (a *App) appendFlag(flag Flag) {
if !a.hasFlag(flag) {
a.Flags = append(a.Flags, flag)
}
}

View File

@ -0,0 +1,423 @@
package cli_test
import (
"fmt"
"os"
"testing"
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/codegangsta/cli"
)
func ExampleApp() {
// set args for examples sake
os.Args = []string{"greet", "--name", "Jeremy"}
app := cli.NewApp()
app.Name = "greet"
app.Flags = []cli.Flag{
cli.StringFlag{Name: "name", Value: "bob", Usage: "a name to say"},
}
app.Action = func(c *cli.Context) {
fmt.Printf("Hello %v\n", c.String("name"))
}
app.Run(os.Args)
// Output:
// Hello Jeremy
}
func ExampleAppSubcommand() {
// set args for examples sake
os.Args = []string{"say", "hi", "english", "--name", "Jeremy"}
app := cli.NewApp()
app.Name = "say"
app.Commands = []cli.Command{
{
Name: "hello",
ShortName: "hi",
Usage: "use it to see a description",
Description: "This is how we describe hello the function",
Subcommands: []cli.Command{
{
Name: "english",
ShortName: "en",
Usage: "sends a greeting in english",
Description: "greets someone in english",
Flags: []cli.Flag{
cli.StringFlag{
Name: "name",
Value: "Bob",
Usage: "Name of the person to greet",
},
},
Action: func(c *cli.Context) {
fmt.Println("Hello,", c.String("name"))
},
},
},
},
}
app.Run(os.Args)
// Output:
// Hello, Jeremy
}
func ExampleAppHelp() {
// set args for examples sake
os.Args = []string{"greet", "h", "describeit"}
app := cli.NewApp()
app.Name = "greet"
app.Flags = []cli.Flag{
cli.StringFlag{Name: "name", Value: "bob", Usage: "a name to say"},
}
app.Commands = []cli.Command{
{
Name: "describeit",
ShortName: "d",
Usage: "use it to see a description",
Description: "This is how we describe describeit the function",
Action: func(c *cli.Context) {
fmt.Printf("i like to describe things")
},
},
}
app.Run(os.Args)
// Output:
// NAME:
// describeit - use it to see a description
//
// USAGE:
// command describeit [arguments...]
//
// DESCRIPTION:
// This is how we describe describeit the function
}
func ExampleAppBashComplete() {
// set args for examples sake
os.Args = []string{"greet", "--generate-bash-completion"}
app := cli.NewApp()
app.Name = "greet"
app.EnableBashCompletion = true
app.Commands = []cli.Command{
{
Name: "describeit",
ShortName: "d",
Usage: "use it to see a description",
Description: "This is how we describe describeit the function",
Action: func(c *cli.Context) {
fmt.Printf("i like to describe things")
},
}, {
Name: "next",
Usage: "next example",
Description: "more stuff to see when generating bash completion",
Action: func(c *cli.Context) {
fmt.Printf("the next example")
},
},
}
app.Run(os.Args)
// Output:
// describeit
// d
// next
// help
// h
}
func TestApp_Run(t *testing.T) {
s := ""
app := cli.NewApp()
app.Action = func(c *cli.Context) {
s = s + c.Args().First()
}
err := app.Run([]string{"command", "foo"})
expect(t, err, nil)
err = app.Run([]string{"command", "bar"})
expect(t, err, nil)
expect(t, s, "foobar")
}
var commandAppTests = []struct {
name string
expected bool
}{
{"foobar", true},
{"batbaz", true},
{"b", true},
{"f", true},
{"bat", false},
{"nothing", false},
}
func TestApp_Command(t *testing.T) {
app := cli.NewApp()
fooCommand := cli.Command{Name: "foobar", ShortName: "f"}
batCommand := cli.Command{Name: "batbaz", ShortName: "b"}
app.Commands = []cli.Command{
fooCommand,
batCommand,
}
for _, test := range commandAppTests {
expect(t, app.Command(test.name) != nil, test.expected)
}
}
func TestApp_CommandWithArgBeforeFlags(t *testing.T) {
var parsedOption, firstArg string
app := cli.NewApp()
command := cli.Command{
Name: "cmd",
Flags: []cli.Flag{
cli.StringFlag{Name: "option", Value: "", Usage: "some option"},
},
Action: func(c *cli.Context) {
parsedOption = c.String("option")
firstArg = c.Args().First()
},
}
app.Commands = []cli.Command{command}
app.Run([]string{"", "cmd", "my-arg", "--option", "my-option"})
expect(t, parsedOption, "my-option")
expect(t, firstArg, "my-arg")
}
func TestApp_Float64Flag(t *testing.T) {
var meters float64
app := cli.NewApp()
app.Flags = []cli.Flag{
cli.Float64Flag{Name: "height", Value: 1.5, Usage: "Set the height, in meters"},
}
app.Action = func(c *cli.Context) {
meters = c.Float64("height")
}
app.Run([]string{"", "--height", "1.93"})
expect(t, meters, 1.93)
}
func TestApp_ParseSliceFlags(t *testing.T) {
var parsedOption, firstArg string
var parsedIntSlice []int
var parsedStringSlice []string
app := cli.NewApp()
command := cli.Command{
Name: "cmd",
Flags: []cli.Flag{
cli.IntSliceFlag{Name: "p", Value: &cli.IntSlice{}, Usage: "set one or more ip addr"},
cli.StringSliceFlag{Name: "ip", Value: &cli.StringSlice{}, Usage: "set one or more ports to open"},
},
Action: func(c *cli.Context) {
parsedIntSlice = c.IntSlice("p")
parsedStringSlice = c.StringSlice("ip")
parsedOption = c.String("option")
firstArg = c.Args().First()
},
}
app.Commands = []cli.Command{command}
app.Run([]string{"", "cmd", "my-arg", "-p", "22", "-p", "80", "-ip", "8.8.8.8", "-ip", "8.8.4.4"})
IntsEquals := func(a, b []int) bool {
if len(a) != len(b) {
return false
}
for i, v := range a {
if v != b[i] {
return false
}
}
return true
}
StrsEquals := func(a, b []string) bool {
if len(a) != len(b) {
return false
}
for i, v := range a {
if v != b[i] {
return false
}
}
return true
}
var expectedIntSlice = []int{22, 80}
var expectedStringSlice = []string{"8.8.8.8", "8.8.4.4"}
if !IntsEquals(parsedIntSlice, expectedIntSlice) {
t.Errorf("%v does not match %v", parsedIntSlice, expectedIntSlice)
}
if !StrsEquals(parsedStringSlice, expectedStringSlice) {
t.Errorf("%v does not match %v", parsedStringSlice, expectedStringSlice)
}
}
func TestApp_BeforeFunc(t *testing.T) {
beforeRun, subcommandRun := false, false
beforeError := fmt.Errorf("fail")
var err error
app := cli.NewApp()
app.Before = func(c *cli.Context) error {
beforeRun = true
s := c.String("opt")
if s == "fail" {
return beforeError
}
return nil
}
app.Commands = []cli.Command{
cli.Command{
Name: "sub",
Action: func(c *cli.Context) {
subcommandRun = true
},
},
}
app.Flags = []cli.Flag{
cli.StringFlag{Name: "opt"},
}
// run with the Before() func succeeding
err = app.Run([]string{"command", "--opt", "succeed", "sub"})
if err != nil {
t.Fatalf("Run error: %s", err)
}
if beforeRun == false {
t.Errorf("Before() not executed when expected")
}
if subcommandRun == false {
t.Errorf("Subcommand not executed when expected")
}
// reset
beforeRun, subcommandRun = false, false
// run with the Before() func failing
err = app.Run([]string{"command", "--opt", "fail", "sub"})
// should be the same error produced by the Before func
if err != beforeError {
t.Errorf("Run error expected, but not received")
}
if beforeRun == false {
t.Errorf("Before() not executed when expected")
}
if subcommandRun == true {
t.Errorf("Subcommand executed when NOT expected")
}
}
func TestAppHelpPrinter(t *testing.T) {
oldPrinter := cli.HelpPrinter
defer func() {
cli.HelpPrinter = oldPrinter
}()
var wasCalled = false
cli.HelpPrinter = func(template string, data interface{}) {
wasCalled = true
}
app := cli.NewApp()
app.Run([]string{"-h"})
if wasCalled == false {
t.Errorf("Help printer expected to be called, but was not")
}
}
func TestAppVersionPrinter(t *testing.T) {
oldPrinter := cli.VersionPrinter
defer func() {
cli.VersionPrinter = oldPrinter
}()
var wasCalled = false
cli.VersionPrinter = func(c *cli.Context) {
wasCalled = true
}
app := cli.NewApp()
ctx := cli.NewContext(app, nil, nil)
cli.ShowVersion(ctx)
if wasCalled == false {
t.Errorf("Version printer expected to be called, but was not")
}
}
func TestAppCommandNotFound(t *testing.T) {
beforeRun, subcommandRun := false, false
app := cli.NewApp()
app.CommandNotFound = func(c *cli.Context, command string) {
beforeRun = true
}
app.Commands = []cli.Command{
cli.Command{
Name: "bar",
Action: func(c *cli.Context) {
subcommandRun = true
},
},
}
app.Run([]string{"command", "foo"})
expect(t, beforeRun, true)
expect(t, subcommandRun, false)
}
func TestGlobalFlagsInSubcommands(t *testing.T) {
subcommandRun := false
app := cli.NewApp()
app.Flags = []cli.Flag{
cli.BoolFlag{Name: "debug, d", Usage: "Enable debugging"},
}
app.Commands = []cli.Command{
cli.Command{
Name: "foo",
Subcommands: []cli.Command{
{
Name: "bar",
Action: func(c *cli.Context) {
if c.GlobalBool("debug") {
subcommandRun = true
}
},
},
},
},
}
app.Run([]string{"command", "-d", "foo", "bar"})
expect(t, subcommandRun, true)
}

View File

@ -0,0 +1,13 @@
#! /bin/bash
_cli_bash_autocomplete() {
local cur prev opts base
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion )
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
}
complete -F _cli_bash_autocomplete $PROG

View File

@ -0,0 +1,5 @@
autoload -U compinit && compinit
autoload -U bashcompinit && bashcompinit
script_dir=$(dirname $0)
source ${script_dir}/bash_autocomplete

View File

@ -0,0 +1,19 @@
// Package cli provides a minimal framework for creating and organizing command line
// Go applications. cli is designed to be easy to understand and write, the most simple
// cli application can be written as follows:
// func main() {
// cli.NewApp().Run(os.Args)
// }
//
// Of course this application does not do much, so let's make this an actual application:
// func main() {
// app := cli.NewApp()
// app.Name = "greet"
// app.Usage = "say a greeting"
// app.Action = func(c *cli.Context) {
// println("Greetings")
// }
//
// app.Run(os.Args)
// }
package cli

View File

@ -0,0 +1,100 @@
package cli_test
import (
"os"
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/codegangsta/cli"
)
func Example() {
app := cli.NewApp()
app.Name = "todo"
app.Usage = "task list on the command line"
app.Commands = []cli.Command{
{
Name: "add",
ShortName: "a",
Usage: "add a task to the list",
Action: func(c *cli.Context) {
println("added task: ", c.Args().First())
},
},
{
Name: "complete",
ShortName: "c",
Usage: "complete a task on the list",
Action: func(c *cli.Context) {
println("completed task: ", c.Args().First())
},
},
}
app.Run(os.Args)
}
func ExampleSubcommand() {
app := cli.NewApp()
app.Name = "say"
app.Commands = []cli.Command{
{
Name: "hello",
ShortName: "hi",
Usage: "use it to see a description",
Description: "This is how we describe hello the function",
Subcommands: []cli.Command{
{
Name: "english",
ShortName: "en",
Usage: "sends a greeting in english",
Description: "greets someone in english",
Flags: []cli.Flag{
cli.StringFlag{
Name: "name",
Value: "Bob",
Usage: "Name of the person to greet",
},
},
Action: func(c *cli.Context) {
println("Hello, ", c.String("name"))
},
}, {
Name: "spanish",
ShortName: "sp",
Usage: "sends a greeting in spanish",
Flags: []cli.Flag{
cli.StringFlag{
Name: "surname",
Value: "Jones",
Usage: "Surname of the person to greet",
},
},
Action: func(c *cli.Context) {
println("Hola, ", c.String("surname"))
},
}, {
Name: "french",
ShortName: "fr",
Usage: "sends a greeting in french",
Flags: []cli.Flag{
cli.StringFlag{
Name: "nickname",
Value: "Stevie",
Usage: "Nickname of the person to greet",
},
},
Action: func(c *cli.Context) {
println("Bonjour, ", c.String("nickname"))
},
},
},
}, {
Name: "bye",
Usage: "says goodbye",
Action: func(c *cli.Context) {
println("bye")
},
},
}
app.Run(os.Args)
}

View File

@ -0,0 +1,144 @@
package cli
import (
"fmt"
"io/ioutil"
"strings"
)
// Command is a subcommand for a cli.App.
type Command struct {
// The name of the command
Name string
// short name of the command. Typically one character
ShortName string
// A short description of the usage of this command
Usage string
// A longer explanation of how the command works
Description string
// The function to call when checking for bash command completions
BashComplete func(context *Context)
// An action to execute before any sub-subcommands are run, but after the context is ready
// If a non-nil error is returned, no sub-subcommands are run
Before func(context *Context) error
// The function to call when this command is invoked
Action func(context *Context)
// List of child commands
Subcommands []Command
// List of flags to parse
Flags []Flag
// Treat all flags as normal arguments if true
SkipFlagParsing bool
// Boolean to hide built-in help command
HideHelp bool
}
// Invokes the command given the context, parses ctx.Args() to generate command-specific flags
func (c Command) Run(ctx *Context) error {
if len(c.Subcommands) > 0 || c.Before != nil {
return c.startApp(ctx)
}
if !c.HideHelp {
// append help to flags
c.Flags = append(
c.Flags,
HelpFlag,
)
}
if ctx.App.EnableBashCompletion {
c.Flags = append(c.Flags, BashCompletionFlag)
}
set := flagSet(c.Name, c.Flags)
set.SetOutput(ioutil.Discard)
firstFlagIndex := -1
for index, arg := range ctx.Args() {
if strings.HasPrefix(arg, "-") {
firstFlagIndex = index
break
}
}
var err error
if firstFlagIndex > -1 && !c.SkipFlagParsing {
args := ctx.Args()
regularArgs := args[1:firstFlagIndex]
flagArgs := args[firstFlagIndex:]
err = set.Parse(append(flagArgs, regularArgs...))
} else {
err = set.Parse(ctx.Args().Tail())
}
if err != nil {
fmt.Printf("Incorrect Usage.\n\n")
ShowCommandHelp(ctx, c.Name)
fmt.Println("")
return err
}
nerr := normalizeFlags(c.Flags, set)
if nerr != nil {
fmt.Println(nerr)
fmt.Println("")
ShowCommandHelp(ctx, c.Name)
fmt.Println("")
return nerr
}
context := NewContext(ctx.App, set, ctx.globalSet)
if checkCommandCompletions(context, c.Name) {
return nil
}
if checkCommandHelp(context, c.Name) {
return nil
}
context.Command = c
c.Action(context)
return nil
}
// Returns true if Command.Name or Command.ShortName matches given name
func (c Command) HasName(name string) bool {
return c.Name == name || c.ShortName == name
}
func (c Command) startApp(ctx *Context) error {
app := NewApp()
// set the name and usage
app.Name = fmt.Sprintf("%s %s", ctx.App.Name, c.Name)
if c.Description != "" {
app.Usage = c.Description
} else {
app.Usage = c.Usage
}
// set CommandNotFound
app.CommandNotFound = ctx.App.CommandNotFound
// set the flags and commands
app.Commands = c.Subcommands
app.Flags = c.Flags
app.HideHelp = c.HideHelp
// bash completion
app.EnableBashCompletion = ctx.App.EnableBashCompletion
if c.BashComplete != nil {
app.BashComplete = c.BashComplete
}
// set the actions
app.Before = c.Before
if c.Action != nil {
app.Action = c.Action
} else {
app.Action = helpSubcommand.Action
}
return app.RunAsSubcommand(ctx)
}

View File

@ -0,0 +1,49 @@
package cli_test
import (
"flag"
"testing"
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/codegangsta/cli"
)
func TestCommandDoNotIgnoreFlags(t *testing.T) {
app := cli.NewApp()
set := flag.NewFlagSet("test", 0)
test := []string{"blah", "blah", "-break"}
set.Parse(test)
c := cli.NewContext(app, set, set)
command := cli.Command{
Name: "test-cmd",
ShortName: "tc",
Usage: "this is for testing",
Description: "testing",
Action: func(_ *cli.Context) {},
}
err := command.Run(c)
expect(t, err.Error(), "flag provided but not defined: -break")
}
func TestCommandIgnoreFlags(t *testing.T) {
app := cli.NewApp()
set := flag.NewFlagSet("test", 0)
test := []string{"blah", "blah"}
set.Parse(test)
c := cli.NewContext(app, set, set)
command := cli.Command{
Name: "test-cmd",
ShortName: "tc",
Usage: "this is for testing",
Description: "testing",
Action: func(_ *cli.Context) {},
SkipFlagParsing: true,
}
err := command.Run(c)
expect(t, err, nil)
}

View File

@ -0,0 +1,315 @@
package cli
import (
"errors"
"flag"
"strconv"
"strings"
"time"
)
// Context is a type that is passed through to
// each Handler action in a cli application. Context
// can be used to retrieve context-specific Args and
// parsed command-line options.
type Context struct {
App *App
Command Command
flagSet *flag.FlagSet
globalSet *flag.FlagSet
setFlags map[string]bool
}
// Creates a new context. For use in when invoking an App or Command action.
func NewContext(app *App, set *flag.FlagSet, globalSet *flag.FlagSet) *Context {
return &Context{App: app, flagSet: set, globalSet: globalSet}
}
// Looks up the value of a local int flag, returns 0 if no int flag exists
func (c *Context) Int(name string) int {
return lookupInt(name, c.flagSet)
}
// Looks up the value of a local time.Duration flag, returns 0 if no time.Duration flag exists
func (c *Context) Duration(name string) time.Duration {
return lookupDuration(name, c.flagSet)
}
// Looks up the value of a local float64 flag, returns 0 if no float64 flag exists
func (c *Context) Float64(name string) float64 {
return lookupFloat64(name, c.flagSet)
}
// Looks up the value of a local bool flag, returns false if no bool flag exists
func (c *Context) Bool(name string) bool {
return lookupBool(name, c.flagSet)
}
// Looks up the value of a local boolT flag, returns false if no bool flag exists
func (c *Context) BoolT(name string) bool {
return lookupBoolT(name, c.flagSet)
}
// Looks up the value of a local string flag, returns "" if no string flag exists
func (c *Context) String(name string) string {
return lookupString(name, c.flagSet)
}
// Looks up the value of a local string slice flag, returns nil if no string slice flag exists
func (c *Context) StringSlice(name string) []string {
return lookupStringSlice(name, c.flagSet)
}
// Looks up the value of a local int slice flag, returns nil if no int slice flag exists
func (c *Context) IntSlice(name string) []int {
return lookupIntSlice(name, c.flagSet)
}
// Looks up the value of a local generic flag, returns nil if no generic flag exists
func (c *Context) Generic(name string) interface{} {
return lookupGeneric(name, c.flagSet)
}
// Looks up the value of a global int flag, returns 0 if no int flag exists
func (c *Context) GlobalInt(name string) int {
return lookupInt(name, c.globalSet)
}
// Looks up the value of a global time.Duration flag, returns 0 if no time.Duration flag exists
func (c *Context) GlobalDuration(name string) time.Duration {
return lookupDuration(name, c.globalSet)
}
// Looks up the value of a global bool flag, returns false if no bool flag exists
func (c *Context) GlobalBool(name string) bool {
return lookupBool(name, c.globalSet)
}
// Looks up the value of a global string flag, returns "" if no string flag exists
func (c *Context) GlobalString(name string) string {
return lookupString(name, c.globalSet)
}
// Looks up the value of a global string slice flag, returns nil if no string slice flag exists
func (c *Context) GlobalStringSlice(name string) []string {
return lookupStringSlice(name, c.globalSet)
}
// Looks up the value of a global int slice flag, returns nil if no int slice flag exists
func (c *Context) GlobalIntSlice(name string) []int {
return lookupIntSlice(name, c.globalSet)
}
// Looks up the value of a global generic flag, returns nil if no generic flag exists
func (c *Context) GlobalGeneric(name string) interface{} {
return lookupGeneric(name, c.globalSet)
}
// Determines if the flag was actually set exists
func (c *Context) IsSet(name string) bool {
if c.setFlags == nil {
c.setFlags = make(map[string]bool)
c.flagSet.Visit(func(f *flag.Flag) {
c.setFlags[f.Name] = true
})
}
return c.setFlags[name] == true
}
// Returns a slice of flag names used in this context.
func (c *Context) FlagNames() (names []string) {
for _, flag := range c.Command.Flags {
name := strings.Split(flag.getName(), ",")[0]
if name == "help" {
continue
}
names = append(names, name)
}
return
}
type Args []string
// Returns the command line arguments associated with the context.
func (c *Context) Args() Args {
args := Args(c.flagSet.Args())
return args
}
// Returns the nth argument, or else a blank string
func (a Args) Get(n int) string {
if len(a) > n {
return a[n]
}
return ""
}
// Returns the first argument, or else a blank string
func (a Args) First() string {
return a.Get(0)
}
// Return the rest of the arguments (not the first one)
// or else an empty string slice
func (a Args) Tail() []string {
if len(a) >= 2 {
return []string(a)[1:]
}
return []string{}
}
// Checks if there are any arguments present
func (a Args) Present() bool {
return len(a) != 0
}
// Swaps arguments at the given indexes
func (a Args) Swap(from, to int) error {
if from >= len(a) || to >= len(a) {
return errors.New("index out of range")
}
a[from], a[to] = a[to], a[from]
return nil
}
func lookupInt(name string, set *flag.FlagSet) int {
f := set.Lookup(name)
if f != nil {
val, err := strconv.Atoi(f.Value.String())
if err != nil {
return 0
}
return val
}
return 0
}
func lookupDuration(name string, set *flag.FlagSet) time.Duration {
f := set.Lookup(name)
if f != nil {
val, err := time.ParseDuration(f.Value.String())
if err == nil {
return val
}
}
return 0
}
func lookupFloat64(name string, set *flag.FlagSet) float64 {
f := set.Lookup(name)
if f != nil {
val, err := strconv.ParseFloat(f.Value.String(), 64)
if err != nil {
return 0
}
return val
}
return 0
}
func lookupString(name string, set *flag.FlagSet) string {
f := set.Lookup(name)
if f != nil {
return f.Value.String()
}
return ""
}
func lookupStringSlice(name string, set *flag.FlagSet) []string {
f := set.Lookup(name)
if f != nil {
return (f.Value.(*StringSlice)).Value()
}
return nil
}
func lookupIntSlice(name string, set *flag.FlagSet) []int {
f := set.Lookup(name)
if f != nil {
return (f.Value.(*IntSlice)).Value()
}
return nil
}
func lookupGeneric(name string, set *flag.FlagSet) interface{} {
f := set.Lookup(name)
if f != nil {
return f.Value
}
return nil
}
func lookupBool(name string, set *flag.FlagSet) bool {
f := set.Lookup(name)
if f != nil {
val, err := strconv.ParseBool(f.Value.String())
if err != nil {
return false
}
return val
}
return false
}
func lookupBoolT(name string, set *flag.FlagSet) bool {
f := set.Lookup(name)
if f != nil {
val, err := strconv.ParseBool(f.Value.String())
if err != nil {
return true
}
return val
}
return false
}
func copyFlag(name string, ff *flag.Flag, set *flag.FlagSet) {
switch ff.Value.(type) {
case *StringSlice:
default:
set.Set(name, ff.Value.String())
}
}
func normalizeFlags(flags []Flag, set *flag.FlagSet) error {
visited := make(map[string]bool)
set.Visit(func(f *flag.Flag) {
visited[f.Name] = true
})
for _, f := range flags {
parts := strings.Split(f.getName(), ",")
if len(parts) == 1 {
continue
}
var ff *flag.Flag
for _, name := range parts {
name = strings.Trim(name, " ")
if visited[name] {
if ff != nil {
return errors.New("Cannot use two forms of the same flag: " + name + " " + ff.Name)
}
ff = set.Lookup(name)
}
}
if ff == nil {
continue
}
for _, name := range parts {
name = strings.Trim(name, " ")
if !visited[name] {
copyFlag(name, ff, set)
}
}
}
return nil
}

View File

@ -0,0 +1,77 @@
package cli_test
import (
"flag"
"testing"
"time"
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/codegangsta/cli"
)
func TestNewContext(t *testing.T) {
set := flag.NewFlagSet("test", 0)
set.Int("myflag", 12, "doc")
globalSet := flag.NewFlagSet("test", 0)
globalSet.Int("myflag", 42, "doc")
command := cli.Command{Name: "mycommand"}
c := cli.NewContext(nil, set, globalSet)
c.Command = command
expect(t, c.Int("myflag"), 12)
expect(t, c.GlobalInt("myflag"), 42)
expect(t, c.Command.Name, "mycommand")
}
func TestContext_Int(t *testing.T) {
set := flag.NewFlagSet("test", 0)
set.Int("myflag", 12, "doc")
c := cli.NewContext(nil, set, set)
expect(t, c.Int("myflag"), 12)
}
func TestContext_Duration(t *testing.T) {
set := flag.NewFlagSet("test", 0)
set.Duration("myflag", time.Duration(12*time.Second), "doc")
c := cli.NewContext(nil, set, set)
expect(t, c.Duration("myflag"), time.Duration(12*time.Second))
}
func TestContext_String(t *testing.T) {
set := flag.NewFlagSet("test", 0)
set.String("myflag", "hello world", "doc")
c := cli.NewContext(nil, set, set)
expect(t, c.String("myflag"), "hello world")
}
func TestContext_Bool(t *testing.T) {
set := flag.NewFlagSet("test", 0)
set.Bool("myflag", false, "doc")
c := cli.NewContext(nil, set, set)
expect(t, c.Bool("myflag"), false)
}
func TestContext_BoolT(t *testing.T) {
set := flag.NewFlagSet("test", 0)
set.Bool("myflag", true, "doc")
c := cli.NewContext(nil, set, set)
expect(t, c.BoolT("myflag"), true)
}
func TestContext_Args(t *testing.T) {
set := flag.NewFlagSet("test", 0)
set.Bool("myflag", false, "doc")
c := cli.NewContext(nil, set, set)
set.Parse([]string{"--myflag", "bat", "baz"})
expect(t, len(c.Args()), 2)
expect(t, c.Bool("myflag"), true)
}
func TestContext_IsSet(t *testing.T) {
set := flag.NewFlagSet("test", 0)
set.Bool("myflag", false, "doc")
set.String("otherflag", "hello world", "doc")
c := cli.NewContext(nil, set, set)
set.Parse([]string{"--myflag", "bat", "baz"})
expect(t, c.IsSet("myflag"), true)
expect(t, c.IsSet("otherflag"), false)
expect(t, c.IsSet("bogusflag"), false)
}

View File

@ -0,0 +1,410 @@
package cli
import (
"flag"
"fmt"
"os"
"strconv"
"strings"
"time"
)
// This flag enables bash-completion for all commands and subcommands
var BashCompletionFlag = BoolFlag{
Name: "generate-bash-completion",
}
// This flag prints the version for the application
var VersionFlag = BoolFlag{
Name: "version, v",
Usage: "print the version",
}
// This flag prints the help for all commands and subcommands
var HelpFlag = BoolFlag{
Name: "help, h",
Usage: "show help",
}
// Flag is a common interface related to parsing flags in cli.
// For more advanced flag parsing techniques, it is recomended that
// this interface be implemented.
type Flag interface {
fmt.Stringer
// Apply Flag settings to the given flag set
Apply(*flag.FlagSet)
getName() string
}
func flagSet(name string, flags []Flag) *flag.FlagSet {
set := flag.NewFlagSet(name, flag.ContinueOnError)
for _, f := range flags {
f.Apply(set)
}
return set
}
func eachName(longName string, fn func(string)) {
parts := strings.Split(longName, ",")
for _, name := range parts {
name = strings.Trim(name, " ")
fn(name)
}
}
// Generic is a generic parseable type identified by a specific flag
type Generic interface {
Set(value string) error
String() string
}
// GenericFlag is the flag type for types implementing Generic
type GenericFlag struct {
Name string
Value Generic
Usage string
EnvVar string
}
func (f GenericFlag) String() string {
return withEnvHint(f.EnvVar, fmt.Sprintf("%s%s %v\t`%v` %s", prefixFor(f.Name), f.Name, f.Value, "-"+f.Name+" option -"+f.Name+" option", f.Usage))
}
func (f GenericFlag) Apply(set *flag.FlagSet) {
val := f.Value
if f.EnvVar != "" {
if envVal := os.Getenv(f.EnvVar); envVal != "" {
val.Set(envVal)
}
}
eachName(f.Name, func(name string) {
set.Var(f.Value, name, f.Usage)
})
}
func (f GenericFlag) getName() string {
return f.Name
}
type StringSlice []string
func (f *StringSlice) Set(value string) error {
*f = append(*f, value)
return nil
}
func (f *StringSlice) String() string {
return fmt.Sprintf("%s", *f)
}
func (f *StringSlice) Value() []string {
return *f
}
type StringSliceFlag struct {
Name string
Value *StringSlice
Usage string
EnvVar string
}
func (f StringSliceFlag) String() string {
firstName := strings.Trim(strings.Split(f.Name, ",")[0], " ")
pref := prefixFor(firstName)
return withEnvHint(f.EnvVar, fmt.Sprintf("%s '%v'\t%v", prefixedNames(f.Name), pref+firstName+" option "+pref+firstName+" option", f.Usage))
}
func (f StringSliceFlag) Apply(set *flag.FlagSet) {
if f.EnvVar != "" {
if envVal := os.Getenv(f.EnvVar); envVal != "" {
newVal := &StringSlice{}
for _, s := range strings.Split(envVal, ",") {
newVal.Set(s)
}
f.Value = newVal
}
}
eachName(f.Name, func(name string) {
set.Var(f.Value, name, f.Usage)
})
}
func (f StringSliceFlag) getName() string {
return f.Name
}
type IntSlice []int
func (f *IntSlice) Set(value string) error {
tmp, err := strconv.Atoi(value)
if err != nil {
return err
} else {
*f = append(*f, tmp)
}
return nil
}
func (f *IntSlice) String() string {
return fmt.Sprintf("%d", *f)
}
func (f *IntSlice) Value() []int {
return *f
}
type IntSliceFlag struct {
Name string
Value *IntSlice
Usage string
EnvVar string
}
func (f IntSliceFlag) String() string {
firstName := strings.Trim(strings.Split(f.Name, ",")[0], " ")
pref := prefixFor(firstName)
return withEnvHint(f.EnvVar, fmt.Sprintf("%s '%v'\t%v", prefixedNames(f.Name), pref+firstName+" option "+pref+firstName+" option", f.Usage))
}
func (f IntSliceFlag) Apply(set *flag.FlagSet) {
if f.EnvVar != "" {
if envVal := os.Getenv(f.EnvVar); envVal != "" {
newVal := &IntSlice{}
for _, s := range strings.Split(envVal, ",") {
err := newVal.Set(s)
if err != nil {
fmt.Fprintf(os.Stderr, err.Error())
}
}
f.Value = newVal
}
}
eachName(f.Name, func(name string) {
set.Var(f.Value, name, f.Usage)
})
}
func (f IntSliceFlag) getName() string {
return f.Name
}
type BoolFlag struct {
Name string
Usage string
EnvVar string
}
func (f BoolFlag) String() string {
return withEnvHint(f.EnvVar, fmt.Sprintf("%s\t%v", prefixedNames(f.Name), f.Usage))
}
func (f BoolFlag) Apply(set *flag.FlagSet) {
val := false
if f.EnvVar != "" {
if envVal := os.Getenv(f.EnvVar); envVal != "" {
envValBool, err := strconv.ParseBool(envVal)
if err == nil {
val = envValBool
}
}
}
eachName(f.Name, func(name string) {
set.Bool(name, val, f.Usage)
})
}
func (f BoolFlag) getName() string {
return f.Name
}
type BoolTFlag struct {
Name string
Usage string
EnvVar string
}
func (f BoolTFlag) String() string {
return withEnvHint(f.EnvVar, fmt.Sprintf("%s\t%v", prefixedNames(f.Name), f.Usage))
}
func (f BoolTFlag) Apply(set *flag.FlagSet) {
val := true
if f.EnvVar != "" {
if envVal := os.Getenv(f.EnvVar); envVal != "" {
envValBool, err := strconv.ParseBool(envVal)
if err == nil {
val = envValBool
}
}
}
eachName(f.Name, func(name string) {
set.Bool(name, val, f.Usage)
})
}
func (f BoolTFlag) getName() string {
return f.Name
}
type StringFlag struct {
Name string
Value string
Usage string
EnvVar string
}
func (f StringFlag) String() string {
var fmtString string
fmtString = "%s %v\t%v"
if len(f.Value) > 0 {
fmtString = "%s '%v'\t%v"
} else {
fmtString = "%s %v\t%v"
}
return withEnvHint(f.EnvVar, fmt.Sprintf(fmtString, prefixedNames(f.Name), f.Value, f.Usage))
}
func (f StringFlag) Apply(set *flag.FlagSet) {
if f.EnvVar != "" {
if envVal := os.Getenv(f.EnvVar); envVal != "" {
f.Value = envVal
}
}
eachName(f.Name, func(name string) {
set.String(name, f.Value, f.Usage)
})
}
func (f StringFlag) getName() string {
return f.Name
}
type IntFlag struct {
Name string
Value int
Usage string
EnvVar string
}
func (f IntFlag) String() string {
return withEnvHint(f.EnvVar, fmt.Sprintf("%s '%v'\t%v", prefixedNames(f.Name), f.Value, f.Usage))
}
func (f IntFlag) Apply(set *flag.FlagSet) {
if f.EnvVar != "" {
if envVal := os.Getenv(f.EnvVar); envVal != "" {
envValInt, err := strconv.ParseUint(envVal, 10, 64)
if err == nil {
f.Value = int(envValInt)
}
}
}
eachName(f.Name, func(name string) {
set.Int(name, f.Value, f.Usage)
})
}
func (f IntFlag) getName() string {
return f.Name
}
type DurationFlag struct {
Name string
Value time.Duration
Usage string
EnvVar string
}
func (f DurationFlag) String() string {
return withEnvHint(f.EnvVar, fmt.Sprintf("%s '%v'\t%v", prefixedNames(f.Name), f.Value, f.Usage))
}
func (f DurationFlag) Apply(set *flag.FlagSet) {
if f.EnvVar != "" {
if envVal := os.Getenv(f.EnvVar); envVal != "" {
envValDuration, err := time.ParseDuration(envVal)
if err == nil {
f.Value = envValDuration
}
}
}
eachName(f.Name, func(name string) {
set.Duration(name, f.Value, f.Usage)
})
}
func (f DurationFlag) getName() string {
return f.Name
}
type Float64Flag struct {
Name string
Value float64
Usage string
EnvVar string
}
func (f Float64Flag) String() string {
return withEnvHint(f.EnvVar, fmt.Sprintf("%s '%v'\t%v", prefixedNames(f.Name), f.Value, f.Usage))
}
func (f Float64Flag) Apply(set *flag.FlagSet) {
if f.EnvVar != "" {
if envVal := os.Getenv(f.EnvVar); envVal != "" {
envValFloat, err := strconv.ParseFloat(envVal, 10)
if err == nil {
f.Value = float64(envValFloat)
}
}
}
eachName(f.Name, func(name string) {
set.Float64(name, f.Value, f.Usage)
})
}
func (f Float64Flag) getName() string {
return f.Name
}
func prefixFor(name string) (prefix string) {
if len(name) == 1 {
prefix = "-"
} else {
prefix = "--"
}
return
}
func prefixedNames(fullName string) (prefixed string) {
parts := strings.Split(fullName, ",")
for i, name := range parts {
name = strings.Trim(name, " ")
prefixed += prefixFor(name) + name
if i < len(parts)-1 {
prefixed += ", "
}
}
return
}
func withEnvHint(envVar, str string) string {
envText := ""
if envVar != "" {
envText = fmt.Sprintf(" [$%s]", envVar)
}
return str + envText
}

View File

@ -0,0 +1,587 @@
package cli_test
import (
"fmt"
"os"
"reflect"
"strings"
"testing"
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/codegangsta/cli"
)
var boolFlagTests = []struct {
name string
expected string
}{
{"help", "--help\t"},
{"h", "-h\t"},
}
func TestBoolFlagHelpOutput(t *testing.T) {
for _, test := range boolFlagTests {
flag := cli.BoolFlag{Name: test.name}
output := flag.String()
if output != test.expected {
t.Errorf("%s does not match %s", output, test.expected)
}
}
}
var stringFlagTests = []struct {
name string
value string
expected string
}{
{"help", "", "--help \t"},
{"h", "", "-h \t"},
{"h", "", "-h \t"},
{"test", "Something", "--test 'Something'\t"},
}
func TestStringFlagHelpOutput(t *testing.T) {
for _, test := range stringFlagTests {
flag := cli.StringFlag{Name: test.name, Value: test.value}
output := flag.String()
if output != test.expected {
t.Errorf("%s does not match %s", output, test.expected)
}
}
}
func TestStringFlagWithEnvVarHelpOutput(t *testing.T) {
os.Setenv("APP_FOO", "derp")
for _, test := range stringFlagTests {
flag := cli.StringFlag{Name: test.name, Value: test.value, EnvVar: "APP_FOO"}
output := flag.String()
if !strings.HasSuffix(output, " [$APP_FOO]") {
t.Errorf("%s does not end with [$APP_FOO]", output)
}
}
}
var stringSliceFlagTests = []struct {
name string
value *cli.StringSlice
expected string
}{
{"help", func() *cli.StringSlice {
s := &cli.StringSlice{}
s.Set("")
return s
}(), "--help '--help option --help option'\t"},
{"h", func() *cli.StringSlice {
s := &cli.StringSlice{}
s.Set("")
return s
}(), "-h '-h option -h option'\t"},
{"h", func() *cli.StringSlice {
s := &cli.StringSlice{}
s.Set("")
return s
}(), "-h '-h option -h option'\t"},
{"test", func() *cli.StringSlice {
s := &cli.StringSlice{}
s.Set("Something")
return s
}(), "--test '--test option --test option'\t"},
}
func TestStringSliceFlagHelpOutput(t *testing.T) {
for _, test := range stringSliceFlagTests {
flag := cli.StringSliceFlag{Name: test.name, Value: test.value}
output := flag.String()
if output != test.expected {
t.Errorf("%q does not match %q", output, test.expected)
}
}
}
func TestStringSliceFlagWithEnvVarHelpOutput(t *testing.T) {
os.Setenv("APP_QWWX", "11,4")
for _, test := range stringSliceFlagTests {
flag := cli.StringSliceFlag{Name: test.name, Value: test.value, EnvVar: "APP_QWWX"}
output := flag.String()
if !strings.HasSuffix(output, " [$APP_QWWX]") {
t.Errorf("%q does not end with [$APP_QWWX]", output)
}
}
}
var intFlagTests = []struct {
name string
expected string
}{
{"help", "--help '0'\t"},
{"h", "-h '0'\t"},
}
func TestIntFlagHelpOutput(t *testing.T) {
for _, test := range intFlagTests {
flag := cli.IntFlag{Name: test.name}
output := flag.String()
if output != test.expected {
t.Errorf("%s does not match %s", output, test.expected)
}
}
}
func TestIntFlagWithEnvVarHelpOutput(t *testing.T) {
os.Setenv("APP_BAR", "2")
for _, test := range intFlagTests {
flag := cli.IntFlag{Name: test.name, EnvVar: "APP_BAR"}
output := flag.String()
if !strings.HasSuffix(output, " [$APP_BAR]") {
t.Errorf("%s does not end with [$APP_BAR]", output)
}
}
}
var durationFlagTests = []struct {
name string
expected string
}{
{"help", "--help '0'\t"},
{"h", "-h '0'\t"},
}
func TestDurationFlagHelpOutput(t *testing.T) {
for _, test := range durationFlagTests {
flag := cli.DurationFlag{Name: test.name}
output := flag.String()
if output != test.expected {
t.Errorf("%s does not match %s", output, test.expected)
}
}
}
func TestDurationFlagWithEnvVarHelpOutput(t *testing.T) {
os.Setenv("APP_BAR", "2h3m6s")
for _, test := range durationFlagTests {
flag := cli.DurationFlag{Name: test.name, EnvVar: "APP_BAR"}
output := flag.String()
if !strings.HasSuffix(output, " [$APP_BAR]") {
t.Errorf("%s does not end with [$APP_BAR]", output)
}
}
}
var intSliceFlagTests = []struct {
name string
value *cli.IntSlice
expected string
}{
{"help", &cli.IntSlice{}, "--help '--help option --help option'\t"},
{"h", &cli.IntSlice{}, "-h '-h option -h option'\t"},
{"h", &cli.IntSlice{}, "-h '-h option -h option'\t"},
{"test", func() *cli.IntSlice {
i := &cli.IntSlice{}
i.Set("9")
return i
}(), "--test '--test option --test option'\t"},
}
func TestIntSliceFlagHelpOutput(t *testing.T) {
for _, test := range intSliceFlagTests {
flag := cli.IntSliceFlag{Name: test.name, Value: test.value}
output := flag.String()
if output != test.expected {
t.Errorf("%q does not match %q", output, test.expected)
}
}
}
func TestIntSliceFlagWithEnvVarHelpOutput(t *testing.T) {
os.Setenv("APP_SMURF", "42,3")
for _, test := range intSliceFlagTests {
flag := cli.IntSliceFlag{Name: test.name, Value: test.value, EnvVar: "APP_SMURF"}
output := flag.String()
if !strings.HasSuffix(output, " [$APP_SMURF]") {
t.Errorf("%q does not end with [$APP_SMURF]", output)
}
}
}
var float64FlagTests = []struct {
name string
expected string
}{
{"help", "--help '0'\t"},
{"h", "-h '0'\t"},
}
func TestFloat64FlagHelpOutput(t *testing.T) {
for _, test := range float64FlagTests {
flag := cli.Float64Flag{Name: test.name}
output := flag.String()
if output != test.expected {
t.Errorf("%s does not match %s", output, test.expected)
}
}
}
func TestFloat64FlagWithEnvVarHelpOutput(t *testing.T) {
os.Setenv("APP_BAZ", "99.4")
for _, test := range float64FlagTests {
flag := cli.Float64Flag{Name: test.name, EnvVar: "APP_BAZ"}
output := flag.String()
if !strings.HasSuffix(output, " [$APP_BAZ]") {
t.Errorf("%s does not end with [$APP_BAZ]", output)
}
}
}
var genericFlagTests = []struct {
name string
value cli.Generic
expected string
}{
{"help", &Parser{}, "--help <nil>\t`-help option -help option` "},
{"h", &Parser{}, "-h <nil>\t`-h option -h option` "},
{"test", &Parser{}, "--test <nil>\t`-test option -test option` "},
}
func TestGenericFlagHelpOutput(t *testing.T) {
for _, test := range genericFlagTests {
flag := cli.GenericFlag{Name: test.name}
output := flag.String()
if output != test.expected {
t.Errorf("%q does not match %q", output, test.expected)
}
}
}
func TestGenericFlagWithEnvVarHelpOutput(t *testing.T) {
os.Setenv("APP_ZAP", "3")
for _, test := range genericFlagTests {
flag := cli.GenericFlag{Name: test.name, EnvVar: "APP_ZAP"}
output := flag.String()
if !strings.HasSuffix(output, " [$APP_ZAP]") {
t.Errorf("%s does not end with [$APP_ZAP]", output)
}
}
}
func TestParseMultiString(t *testing.T) {
(&cli.App{
Flags: []cli.Flag{
cli.StringFlag{Name: "serve, s"},
},
Action: func(ctx *cli.Context) {
if ctx.String("serve") != "10" {
t.Errorf("main name not set")
}
if ctx.String("s") != "10" {
t.Errorf("short name not set")
}
},
}).Run([]string{"run", "-s", "10"})
}
func TestParseMultiStringFromEnv(t *testing.T) {
os.Setenv("APP_COUNT", "20")
(&cli.App{
Flags: []cli.Flag{
cli.StringFlag{Name: "count, c", EnvVar: "APP_COUNT"},
},
Action: func(ctx *cli.Context) {
if ctx.String("count") != "20" {
t.Errorf("main name not set")
}
if ctx.String("c") != "20" {
t.Errorf("short name not set")
}
},
}).Run([]string{"run"})
}
func TestParseMultiStringSlice(t *testing.T) {
(&cli.App{
Flags: []cli.Flag{
cli.StringSliceFlag{Name: "serve, s", Value: &cli.StringSlice{}},
},
Action: func(ctx *cli.Context) {
if !reflect.DeepEqual(ctx.StringSlice("serve"), []string{"10", "20"}) {
t.Errorf("main name not set")
}
if !reflect.DeepEqual(ctx.StringSlice("s"), []string{"10", "20"}) {
t.Errorf("short name not set")
}
},
}).Run([]string{"run", "-s", "10", "-s", "20"})
}
func TestParseMultiStringSliceFromEnv(t *testing.T) {
os.Setenv("APP_INTERVALS", "20,30,40")
(&cli.App{
Flags: []cli.Flag{
cli.StringSliceFlag{Name: "intervals, i", Value: &cli.StringSlice{}, EnvVar: "APP_INTERVALS"},
},
Action: func(ctx *cli.Context) {
if !reflect.DeepEqual(ctx.StringSlice("intervals"), []string{"20", "30", "40"}) {
t.Errorf("main name not set from env")
}
if !reflect.DeepEqual(ctx.StringSlice("i"), []string{"20", "30", "40"}) {
t.Errorf("short name not set from env")
}
},
}).Run([]string{"run"})
}
func TestParseMultiInt(t *testing.T) {
a := cli.App{
Flags: []cli.Flag{
cli.IntFlag{Name: "serve, s"},
},
Action: func(ctx *cli.Context) {
if ctx.Int("serve") != 10 {
t.Errorf("main name not set")
}
if ctx.Int("s") != 10 {
t.Errorf("short name not set")
}
},
}
a.Run([]string{"run", "-s", "10"})
}
func TestParseMultiIntFromEnv(t *testing.T) {
os.Setenv("APP_TIMEOUT_SECONDS", "10")
a := cli.App{
Flags: []cli.Flag{
cli.IntFlag{Name: "timeout, t", EnvVar: "APP_TIMEOUT_SECONDS"},
},
Action: func(ctx *cli.Context) {
if ctx.Int("timeout") != 10 {
t.Errorf("main name not set")
}
if ctx.Int("t") != 10 {
t.Errorf("short name not set")
}
},
}
a.Run([]string{"run"})
}
func TestParseMultiIntSlice(t *testing.T) {
(&cli.App{
Flags: []cli.Flag{
cli.IntSliceFlag{Name: "serve, s", Value: &cli.IntSlice{}},
},
Action: func(ctx *cli.Context) {
if !reflect.DeepEqual(ctx.IntSlice("serve"), []int{10, 20}) {
t.Errorf("main name not set")
}
if !reflect.DeepEqual(ctx.IntSlice("s"), []int{10, 20}) {
t.Errorf("short name not set")
}
},
}).Run([]string{"run", "-s", "10", "-s", "20"})
}
func TestParseMultiIntSliceFromEnv(t *testing.T) {
os.Setenv("APP_INTERVALS", "20,30,40")
(&cli.App{
Flags: []cli.Flag{
cli.IntSliceFlag{Name: "intervals, i", Value: &cli.IntSlice{}, EnvVar: "APP_INTERVALS"},
},
Action: func(ctx *cli.Context) {
if !reflect.DeepEqual(ctx.IntSlice("intervals"), []int{20, 30, 40}) {
t.Errorf("main name not set from env")
}
if !reflect.DeepEqual(ctx.IntSlice("i"), []int{20, 30, 40}) {
t.Errorf("short name not set from env")
}
},
}).Run([]string{"run"})
}
func TestParseMultiFloat64(t *testing.T) {
a := cli.App{
Flags: []cli.Flag{
cli.Float64Flag{Name: "serve, s"},
},
Action: func(ctx *cli.Context) {
if ctx.Float64("serve") != 10.2 {
t.Errorf("main name not set")
}
if ctx.Float64("s") != 10.2 {
t.Errorf("short name not set")
}
},
}
a.Run([]string{"run", "-s", "10.2"})
}
func TestParseMultiFloat64FromEnv(t *testing.T) {
os.Setenv("APP_TIMEOUT_SECONDS", "15.5")
a := cli.App{
Flags: []cli.Flag{
cli.Float64Flag{Name: "timeout, t", EnvVar: "APP_TIMEOUT_SECONDS"},
},
Action: func(ctx *cli.Context) {
if ctx.Float64("timeout") != 15.5 {
t.Errorf("main name not set")
}
if ctx.Float64("t") != 15.5 {
t.Errorf("short name not set")
}
},
}
a.Run([]string{"run"})
}
func TestParseMultiBool(t *testing.T) {
a := cli.App{
Flags: []cli.Flag{
cli.BoolFlag{Name: "serve, s"},
},
Action: func(ctx *cli.Context) {
if ctx.Bool("serve") != true {
t.Errorf("main name not set")
}
if ctx.Bool("s") != true {
t.Errorf("short name not set")
}
},
}
a.Run([]string{"run", "--serve"})
}
func TestParseMultiBoolFromEnv(t *testing.T) {
os.Setenv("APP_DEBUG", "1")
a := cli.App{
Flags: []cli.Flag{
cli.BoolFlag{Name: "debug, d", EnvVar: "APP_DEBUG"},
},
Action: func(ctx *cli.Context) {
if ctx.Bool("debug") != true {
t.Errorf("main name not set from env")
}
if ctx.Bool("d") != true {
t.Errorf("short name not set from env")
}
},
}
a.Run([]string{"run"})
}
func TestParseMultiBoolT(t *testing.T) {
a := cli.App{
Flags: []cli.Flag{
cli.BoolTFlag{Name: "serve, s"},
},
Action: func(ctx *cli.Context) {
if ctx.BoolT("serve") != true {
t.Errorf("main name not set")
}
if ctx.BoolT("s") != true {
t.Errorf("short name not set")
}
},
}
a.Run([]string{"run", "--serve"})
}
func TestParseMultiBoolTFromEnv(t *testing.T) {
os.Setenv("APP_DEBUG", "0")
a := cli.App{
Flags: []cli.Flag{
cli.BoolTFlag{Name: "debug, d", EnvVar: "APP_DEBUG"},
},
Action: func(ctx *cli.Context) {
if ctx.BoolT("debug") != false {
t.Errorf("main name not set from env")
}
if ctx.BoolT("d") != false {
t.Errorf("short name not set from env")
}
},
}
a.Run([]string{"run"})
}
type Parser [2]string
func (p *Parser) Set(value string) error {
parts := strings.Split(value, ",")
if len(parts) != 2 {
return fmt.Errorf("invalid format")
}
(*p)[0] = parts[0]
(*p)[1] = parts[1]
return nil
}
func (p *Parser) String() string {
return fmt.Sprintf("%s,%s", p[0], p[1])
}
func TestParseGeneric(t *testing.T) {
a := cli.App{
Flags: []cli.Flag{
cli.GenericFlag{Name: "serve, s", Value: &Parser{}},
},
Action: func(ctx *cli.Context) {
if !reflect.DeepEqual(ctx.Generic("serve"), &Parser{"10", "20"}) {
t.Errorf("main name not set")
}
if !reflect.DeepEqual(ctx.Generic("s"), &Parser{"10", "20"}) {
t.Errorf("short name not set")
}
},
}
a.Run([]string{"run", "-s", "10,20"})
}
func TestParseGenericFromEnv(t *testing.T) {
os.Setenv("APP_SERVE", "20,30")
a := cli.App{
Flags: []cli.Flag{
cli.GenericFlag{Name: "serve, s", Value: &Parser{}, EnvVar: "APP_SERVE"},
},
Action: func(ctx *cli.Context) {
if !reflect.DeepEqual(ctx.Generic("serve"), &Parser{"20", "30"}) {
t.Errorf("main name not set from env")
}
if !reflect.DeepEqual(ctx.Generic("s"), &Parser{"20", "30"}) {
t.Errorf("short name not set from env")
}
},
}
a.Run([]string{"run"})
}

View File

@ -0,0 +1,224 @@
package cli
import (
"fmt"
"os"
"text/tabwriter"
"text/template"
)
// The text template for the Default help topic.
// cli.go uses text/template to render templates. You can
// render custom help text by setting this variable.
var AppHelpTemplate = `NAME:
{{.Name}} - {{.Usage}}
USAGE:
{{.Name}} {{if .Flags}}[global options] {{end}}command{{if .Flags}} [command options]{{end}} [arguments...]
VERSION:
{{.Version}}{{if or .Author .Email}}
AUTHOR:{{if .Author}}
{{.Author}}{{if .Email}} - <{{.Email}}>{{end}}{{else}}
{{.Email}}{{end}}{{end}}
COMMANDS:
{{range .Commands}}{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}}
{{end}}{{if .Flags}}
GLOBAL OPTIONS:
{{range .Flags}}{{.}}
{{end}}{{end}}
`
// The text template for the command help topic.
// cli.go uses text/template to render templates. You can
// render custom help text by setting this variable.
var CommandHelpTemplate = `NAME:
{{.Name}} - {{.Usage}}
USAGE:
command {{.Name}}{{if .Flags}} [command options]{{end}} [arguments...]{{if .Description}}
DESCRIPTION:
{{.Description}}{{end}}{{if .Flags}}
OPTIONS:
{{range .Flags}}{{.}}
{{end}}{{ end }}
`
// The text template for the subcommand help topic.
// cli.go uses text/template to render templates. You can
// render custom help text by setting this variable.
var SubcommandHelpTemplate = `NAME:
{{.Name}} - {{.Usage}}
USAGE:
{{.Name}} command{{if .Flags}} [command options]{{end}} [arguments...]
COMMANDS:
{{range .Commands}}{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}}
{{end}}{{if .Flags}}
OPTIONS:
{{range .Flags}}{{.}}
{{end}}{{end}}
`
var helpCommand = Command{
Name: "help",
ShortName: "h",
Usage: "Shows a list of commands or help for one command",
Action: func(c *Context) {
args := c.Args()
if args.Present() {
ShowCommandHelp(c, args.First())
} else {
ShowAppHelp(c)
}
},
}
var helpSubcommand = Command{
Name: "help",
ShortName: "h",
Usage: "Shows a list of commands or help for one command",
Action: func(c *Context) {
args := c.Args()
if args.Present() {
ShowCommandHelp(c, args.First())
} else {
ShowSubcommandHelp(c)
}
},
}
// Prints help for the App
var HelpPrinter = printHelp
// Prints version for the App
var VersionPrinter = printVersion
func ShowAppHelp(c *Context) {
HelpPrinter(AppHelpTemplate, c.App)
}
// Prints the list of subcommands as the default app completion method
func DefaultAppComplete(c *Context) {
for _, command := range c.App.Commands {
fmt.Println(command.Name)
if command.ShortName != "" {
fmt.Println(command.ShortName)
}
}
}
// Prints help for the given command
func ShowCommandHelp(c *Context, command string) {
for _, c := range c.App.Commands {
if c.HasName(command) {
HelpPrinter(CommandHelpTemplate, c)
return
}
}
if c.App.CommandNotFound != nil {
c.App.CommandNotFound(c, command)
} else {
fmt.Printf("No help topic for '%v'\n", command)
}
}
// Prints help for the given subcommand
func ShowSubcommandHelp(c *Context) {
HelpPrinter(SubcommandHelpTemplate, c.App)
}
// Prints the version number of the App
func ShowVersion(c *Context) {
VersionPrinter(c)
}
func printVersion(c *Context) {
fmt.Printf("%v version %v\n", c.App.Name, c.App.Version)
}
// Prints the lists of commands within a given context
func ShowCompletions(c *Context) {
a := c.App
if a != nil && a.BashComplete != nil {
a.BashComplete(c)
}
}
// Prints the custom completions for a given command
func ShowCommandCompletions(ctx *Context, command string) {
c := ctx.App.Command(command)
if c != nil && c.BashComplete != nil {
c.BashComplete(ctx)
}
}
func printHelp(templ string, data interface{}) {
w := tabwriter.NewWriter(os.Stdout, 0, 8, 1, '\t', 0)
t := template.Must(template.New("help").Parse(templ))
err := t.Execute(w, data)
if err != nil {
panic(err)
}
w.Flush()
}
func checkVersion(c *Context) bool {
if c.GlobalBool("version") {
ShowVersion(c)
return true
}
return false
}
func checkHelp(c *Context) bool {
if c.GlobalBool("h") || c.GlobalBool("help") {
ShowAppHelp(c)
return true
}
return false
}
func checkCommandHelp(c *Context, name string) bool {
if c.Bool("h") || c.Bool("help") {
ShowCommandHelp(c, name)
return true
}
return false
}
func checkSubcommandHelp(c *Context) bool {
if c.GlobalBool("h") || c.GlobalBool("help") {
ShowSubcommandHelp(c)
return true
}
return false
}
func checkCompletions(c *Context) bool {
if c.GlobalBool(BashCompletionFlag.Name) && c.App.EnableBashCompletion {
ShowCompletions(c)
return true
}
return false
}
func checkCommandCompletions(c *Context, name string) bool {
if c.Bool(BashCompletionFlag.Name) && c.App.EnableBashCompletion {
ShowCommandCompletions(c, name)
return true
}
return false
}

View File

@ -0,0 +1,19 @@
package cli_test
import (
"reflect"
"testing"
)
/* Test Helpers */
func expect(t *testing.T, a interface{}, b interface{}) {
if a != b {
t.Errorf("Expected %v (type %v) - Got %v (type %v)", b, reflect.TypeOf(b), a, reflect.TypeOf(a))
}
}
func refute(t *testing.T, a interface{}, b interface{}) {
if a == b {
t.Errorf("Did not expect %v (type %v) - Got %v (type %v)", b, reflect.TypeOf(b), a, reflect.TypeOf(a))
}
}

View File

@ -8,7 +8,7 @@ func (c *Client) AddChildDir(key string, ttl uint64) (*Response, error) {
return nil, err
}
return raw.toResponse()
return raw.Unmarshal()
}
// Add a new file with a random etcd-generated key under the given path.
@ -19,5 +19,5 @@ func (c *Client) AddChild(key string, value string, ttl uint64) (*Response, erro
return nil, err
}
return raw.toResponse()
return raw.Unmarshal()
}

View File

@ -32,8 +32,8 @@ type Config struct {
CertFile string `json:"certFile"`
KeyFile string `json:"keyFile"`
CaCertFile []string `json:"caCertFiles"`
Timeout time.Duration `json:"timeout"`
Consistency string `json: "consistency"`
DialTimeout time.Duration `json:"timeout"`
Consistency string `json:"consistency"`
}
type Client struct {
@ -42,7 +42,20 @@ type Client struct {
httpClient *http.Client
persistence io.Writer
cURLch chan string
keyPrefix string
// CheckRetry can be used to control the policy for failed requests
// and modify the cluster if needed.
// The client calls it before sending requests again, and
// stops retrying if CheckRetry returns some error. The cases that
// this function needs to handle include no response and unexpected
// http status code of response.
// If CheckRetry is nil, client will call the default one
// `DefaultCheckRetry`.
// Argument cluster is the etcd.Cluster object that these requests have been made on.
// Argument numReqs is the number of http.Requests that have been made so far.
// Argument lastResp is the http.Responses from the last request.
// Argument err is the reason of the failure.
CheckRetry func(cluster *Cluster, numReqs int,
lastResp http.Response, err error) error
}
// NewClient create a basic client that is configured to be used
@ -50,15 +63,14 @@ type Client struct {
func NewClient(machines []string) *Client {
config := Config{
// default timeout is one second
Timeout: time.Second,
DialTimeout: time.Second,
// default consistency level is STRONG
Consistency: STRONG_CONSISTENCY,
}
client := &Client{
cluster: NewCluster(machines),
config: config,
keyPrefix: path.Join(version, "keys"),
cluster: NewCluster(machines),
config: config,
}
client.initHTTPClient()
@ -76,7 +88,7 @@ func NewTLSClient(machines []string, cert, key, caCert string) (*Client, error)
config := Config{
// default timeout is one second
Timeout: time.Second,
DialTimeout: time.Second,
// default consistency level is STRONG
Consistency: STRONG_CONSISTENCY,
CertFile: cert,
@ -85,9 +97,8 @@ func NewTLSClient(machines []string, cert, key, caCert string) (*Client, error)
}
client := &Client{
cluster: NewCluster(machines),
config: config,
keyPrefix: path.Join(version, "keys"),
cluster: NewCluster(machines),
config: config,
}
err := client.initHTTPSClient(cert, key)
@ -157,16 +168,10 @@ func (c *Client) SetTransport(tr *http.Transport) {
c.httpClient.Transport = tr
}
// SetKeyPrefix changes the key prefix from the default `/v2/keys` to whatever
// is set.
func (c *Client) SetKeyPrefix(prefix string) {
c.keyPrefix = prefix
}
// initHTTPClient initializes a HTTP client for etcd client
func (c *Client) initHTTPClient() {
tr := &http.Transport{
Dial: dialTimeout,
Dial: c.dial,
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
@ -192,7 +197,7 @@ func (c *Client) initHTTPSClient(cert, key string) error {
tr := &http.Transport{
TLSClientConfig: tlsConfig,
Dial: dialTimeout,
Dial: c.dial,
}
c.httpClient = &http.Client{Transport: tr}
@ -226,6 +231,11 @@ func (c *Client) SetConsistency(consistency string) error {
return nil
}
// Sets the DialTimeout value
func (c *Client) SetDialTimeout(d time.Duration) {
c.config.DialTimeout = d
}
// AddRootCA adds a root CA cert for the etcd client
func (c *Client) AddRootCA(caCert string) error {
if c.httpClient == nil {
@ -326,9 +336,29 @@ func (c *Client) createHttpPath(serverName string, _path string) string {
return u.String()
}
// Dial with timeout.
func dialTimeout(network, addr string) (net.Conn, error) {
return net.DialTimeout(network, addr, time.Second)
// dial attempts to open a TCP connection to the provided address, explicitly
// enabling keep-alives with a one-second interval.
func (c *Client) dial(network, addr string) (net.Conn, error) {
conn, err := net.DialTimeout(network, addr, c.config.DialTimeout)
if err != nil {
return nil, err
}
tcpConn, ok := conn.(*net.TCPConn)
if !ok {
return nil, errors.New("Failed type-assertion of net.Conn as *net.TCPConn")
}
// Keep TCP alive to check whether or not the remote machine is down
if err = tcpConn.SetKeepAlive(true); err != nil {
return nil, err
}
if err = tcpConn.SetKeepAlivePeriod(time.Second); err != nil {
return nil, err
}
return tcpConn, nil
}
func (c *Client) OpenCURL() {
@ -391,8 +421,8 @@ func (c *Client) MarshalJSON() ([]byte, error) {
// as defined by the standard JSON package.
func (c *Client) UnmarshalJSON(b []byte) error {
temp := struct {
Config Config `json: "config"`
Cluster *Cluster `json: "cluster"`
Config Config `json:"config"`
Cluster *Cluster `json:"cluster"`
}{}
err := json.Unmarshal(b, &temp)
if err != nil {

View File

@ -8,7 +8,7 @@ func (c *Client) CompareAndDelete(key string, prevValue string, prevIndex uint64
return nil, err
}
return raw.toResponse()
return raw.Unmarshal()
}
func (c *Client) RawCompareAndDelete(key string, prevValue string, prevIndex uint64) (*RawResponse, error) {
@ -16,7 +16,7 @@ func (c *Client) RawCompareAndDelete(key string, prevValue string, prevIndex uin
return nil, fmt.Errorf("You must give either prevValue or prevIndex.")
}
options := options{}
options := Options{}
if prevValue != "" {
options["prevValue"] = prevValue
}

View File

@ -9,7 +9,7 @@ func (c *Client) CompareAndSwap(key string, value string, ttl uint64,
return nil, err
}
return raw.toResponse()
return raw.Unmarshal()
}
func (c *Client) RawCompareAndSwap(key string, value string, ttl uint64,
@ -18,7 +18,7 @@ func (c *Client) RawCompareAndSwap(key string, value string, ttl uint64,
return nil, fmt.Errorf("You must give either prevValue or prevIndex.")
}
options := options{}
options := Options{}
if prevValue != "" {
options["prevValue"] = prevValue
}

View File

@ -0,0 +1,55 @@
package etcd
import (
"fmt"
"io/ioutil"
"log"
"strings"
)
var logger *etcdLogger
func SetLogger(l *log.Logger) {
logger = &etcdLogger{l}
}
func GetLogger() *log.Logger {
return logger.log
}
type etcdLogger struct {
log *log.Logger
}
func (p *etcdLogger) Debug(args ...interface{}) {
msg := "DEBUG: " + fmt.Sprint(args...)
p.log.Println(msg)
}
func (p *etcdLogger) Debugf(f string, args ...interface{}) {
msg := "DEBUG: " + fmt.Sprintf(f, args...)
// Append newline if necessary
if !strings.HasSuffix(msg, "\n") {
msg = msg + "\n"
}
p.log.Print(msg)
}
func (p *etcdLogger) Warning(args ...interface{}) {
msg := "WARNING: " + fmt.Sprint(args...)
p.log.Println(msg)
}
func (p *etcdLogger) Warningf(f string, args ...interface{}) {
msg := "WARNING: " + fmt.Sprintf(f, args...)
// Append newline if necessary
if !strings.HasSuffix(msg, "\n") {
msg = msg + "\n"
}
p.log.Print(msg)
}
func init() {
// Default logger uses the go default log.
SetLogger(log.New(ioutil.Discard, "go-etcd", log.LstdFlags))
}

View File

@ -0,0 +1,28 @@
package etcd
import (
"testing"
)
type Foo struct{}
type Bar struct {
one string
two int
}
// Tests that logs don't panic with arbitrary interfaces
func TestDebug(t *testing.T) {
f := &Foo{}
b := &Bar{"asfd", 3}
for _, test := range []interface{}{
1234,
"asdf",
f,
b,
} {
logger.Debug(test)
logger.Debugf("something, %s", test)
logger.Warning(test)
logger.Warningf("something, %s", test)
}
}

View File

@ -16,7 +16,7 @@ func (c *Client) Delete(key string, recursive bool) (*Response, error) {
return nil, err
}
return raw.toResponse()
return raw.Unmarshal()
}
// DeleteDir deletes an empty directory or a key value pair
@ -27,11 +27,11 @@ func (c *Client) DeleteDir(key string) (*Response, error) {
return nil, err
}
return raw.toResponse()
return raw.Unmarshal()
}
func (c *Client) RawDelete(key string, recursive bool, dir bool) (*RawResponse, error) {
ops := options{
ops := Options{
"recursive": recursive,
"dir": dir,
}

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