Skip to content

Commit f499100

Browse files
committed
Merge branch 'master' of https://github.com/benbjohnson/etcd into benbjohnson-master
Conflicts: README.md
2 parents b988f5b + aa047b1 commit f499100

File tree

294 files changed

+17741
-33481
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

294 files changed

+17741
-33481
lines changed

.gitignore

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
src/
22
pkg/
33
/etcd
4+
/server/release_version.go
45
/go-bindata
5-
release_version.go
66
/machine*
7-
.vagrant/
8-
conf
9-
info
10-
log

CHANGELOG

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
v0.2
2+
* Support directory creation and removal.
3+
* Add Compare-and-Swap (CAS) support.
4+
* Support recursive GETs.
5+
* Support fully consistent GETs.
6+
* Allow clients to watch specific paths.
7+
* Allow clients to watch for key expiration.
8+
* Unique key generation.
9+
* Support hidden paths.
10+
* Refactor low-level data store.
11+
* Modularize store, server and API code.
12+
* Integrate Gorilla Web Toolkit.
13+
* Add tiered configuration (command line args, env variables, config file).
14+
* Add peer protocol versioning.
15+
* Add rolling upgrade support for future versions.
16+
* Sync key expiration across cluster.
17+
* Significantly improve test coverage.
18+
* Improve migration testing.
19+
* Configurable snapshot count.
20+
* Reduce TCP connection count.
21+
* Fix TCP connection leak.
22+
* Bug Fixes: https://github.com/coreos/etcd/issues?milestone=1&state=closed
23+
24+
Contributors:
25+
* Xiang Li (@xiangli-cmu)
26+
* Ben Johnson (@benbjohnson)
27+
* Brandon Philips (@philips)
28+
* Yifan (@yifan-gu)
29+
* Rob Szumski
30+
* Hongchao Deng (@fengjingchao)
31+
* Kelsey Hightower (@kelseyhightower)
32+
* Adrián (@adrianlzt)
33+
* Antonio Terreno (@aterreno)

Documentation/errorcode.md

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
Error Code
2+
======
3+
4+
This document describes the error code in **Etcd** project.
5+
6+
It's categorized into four groups:
7+
8+
- Command Related Error
9+
- Post Form Related Error
10+
- Raft Related Error
11+
- Etcd Related Error
12+
13+
Error code corresponding strerror
14+
------
15+
16+
const (
17+
EcodeKeyNotFound = 100
18+
EcodeTestFailed = 101
19+
EcodeNotFile = 102
20+
EcodeNoMoreMachine = 103
21+
EcodeNotDir = 104
22+
EcodeNodeExist = 105
23+
EcodeKeyIsPreserved = 106
24+
25+
EcodeValueRequired = 200
26+
EcodePrevValueRequired = 201
27+
EcodeTTLNaN = 202
28+
EcodeIndexNaN = 203
29+
30+
EcodeRaftInternal = 300
31+
EcodeLeaderElect = 301
32+
33+
EcodeWatcherCleared = 400
34+
EcodeEventIndexCleared = 401
35+
)
36+
37+
// command related errors
38+
errors[100] = "Key Not Found"
39+
errors[101] = "Test Failed" //test and set
40+
errors[102] = "Not A File"
41+
errors[103] = "Reached the max number of machines in the cluster"
42+
errors[104] = "Not A Directory"
43+
errors[105] = "Already exists" // create
44+
errors[106] = "The prefix of given key is a keyword in etcd"
45+
46+
// Post form related errors
47+
errors[200] = "Value is Required in POST form"
48+
errors[201] = "PrevValue is Required in POST form"
49+
errors[202] = "The given TTL in POST form is not a number"
50+
errors[203] = "The given index in POST form is not a number"
51+
52+
// raft related errors
53+
errors[300] = "Raft Internal Error"
54+
errors[301] = "During Leader Election"
55+
56+
// etcd related errors
57+
errors[400] = "watcher is cleared due to etcd recovery"
58+
errors[401] = "The event in requested index is outdated and cleared"

Documentation/etcd-file-system.md

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
#Etcd File System
2+
3+
## Structure
4+
[TODO]
5+
![alt text](./img/etcd_fs_structure.jpg "etcd file system structure")
6+
7+
## Node
8+
In **Etcd**, the **Node** is the rudimentary element constructing the whole.
9+
Currently **Etcd** file system is comprised in a Unix-like way of files and directories, and they are two kinds of nodes different in:
10+
11+
- **File Node** has data associated with it.
12+
- **Directory Node** has children nodes associated with it.
13+
14+
Besides the file and directory difference, all nodes have common attributes and operations as follows:
15+
16+
### Attributes:
17+
- **Expiration Time** [optional]
18+
19+
The node will be deleted when it expires.
20+
21+
- **ACL**
22+
23+
The path of access control list of the node.
24+
25+
### Operation:
26+
- **Get** (path, recursive, sorted)
27+
28+
Get the content of the node
29+
- If the node is a file, the data of the file will be returned.
30+
- If the node is a directory, the child nodes of the directory will be returned.
31+
- If recursive is true, it will recursively get the nodes of the directory.
32+
- If sorted is true, the result will be sorted based on the path.
33+
34+
- **Create** (path, value[optional], ttl [optional])
35+
36+
Create a file. Create operation will help to create intermediate directories with no expiration time.
37+
- If the file already exists, create will fail.
38+
- If the value is given, set will create a file.
39+
- If the value is not given, set will crate a directory.
40+
- If ttl is given, the node will be deleted when it expires.
41+
42+
- **Update** (path, value[optional], ttl [optional])
43+
44+
Update the content of the node.
45+
- If the value is given, the value of the key will be updated.
46+
- If ttl is given, the expiration time of the node will be updated.
47+
48+
- **Delete** (path, recursive)
49+
50+
Delete the node of given path.
51+
- If the node is a directory:
52+
- If recursive is true, the operation will delete all nodes under the directory.
53+
- If recursive is false, error will be returned.
54+
55+
- **TestAndSet** (path, prevValue [prevIndex], value, ttl)
56+
57+
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.
58+
- If the prevValue is given, it will test against previous value of
59+
the node.
60+
- If the prevValue is empty, it will test if the node is not existing.
61+
- If the prevValue is not empty, it will test if the prevValue is equal to the current value of the file.
62+
- If the prevIndex is given, it will test if the create/last modified index of the node is equal to prevIndex.
63+
64+
- **Renew** (path, ttl)
65+
66+
Set the node's expiration time to (current time + ttl)
67+
68+
## ACL
69+
70+
### Theory
71+
Etcd exports a Unix-like file system interface consisting of files and directories, collectively called nodes.
72+
Each node has various meta-data, including three names of access control lists used to control reading, writing and changing (change ACL names for the node).
73+
74+
We are storing the ACL names for nodes under a special *ACL* directory.
75+
Each node has ACL name corresponding to one file within *ACL* dir.
76+
Unless overridden, a node naturally inherits the ACL names of its parent directory on creation.
77+
78+
For each ACL name, it has three children: *R (Reading)*, *W (Writing)*, *C (Changing)*
79+
80+
Each permission is also a node. Under the node it contains the users who have this permission for the file refering to this ACL name.
81+
82+
### Example
83+
[TODO]
84+
### Diagram
85+
[TODO]
86+
87+
### Interface
88+
89+
Testing permissions:
90+
91+
- (node *Node) get_perm()
92+
- (node *Node) has_perm(perm string, user string)
93+
94+
Setting/Changing permissions:
95+
96+
- (node *Node) set_perm(perm string)
97+
- (node *Node) change_ACLname(aclname string)
98+
99+
100+
## User Group
101+
[TODO]
+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Etcd Configuration
2+
3+
Configuration options can be set in three places:
4+
5+
1. Command line flags
6+
2. Environment variables
7+
3. Configuration file
8+
9+
Options set on the command line take precedence over all other sources.
10+
Options set in environment variables take precedence over options set in
11+
configuration files.
12+
13+
## Command Line Flags
14+
15+
### Required
16+
17+
* `-n` - The node name. Defaults to `default-name`.
18+
19+
### Optional
20+
21+
* `-c` - The advertised public hostname:port for client communication. Defaults to `127.0.0.1:4001`.
22+
* `-cl` - The listening hostname for client communication. Defaults to advertised ip.
23+
* `-C` - A comma separated list of machines in the cluster (i.e `"203.0.113.101:7001,203.0.113.102:7001"`).
24+
* `-CF` - The file path containing a comma separated list of machines in the cluster.
25+
* `-clientCAFile` - The path of the client CAFile. Enables client cert authentication when present.
26+
* `-clientCert` - The cert file of the client.
27+
* `-clientKey` - The key file of the client.
28+
* `-configfile` - The path of the etcd config file. Defaults to `/etc/etcd/etcd.conf`.
29+
* `-cors` - A comma separated white list of origins for cross-origin resource sharing.
30+
* `-cpuprofile` - The path to a file to output cpu profile data. Enables cpu profiling when present.
31+
* `-d` - The directory to store log and snapshot. Defaults to the current working directory.
32+
* `-m` - The max size of result buffer. Defaults to `1024`.
33+
* `-maxsize` - The max size of the cluster. Defaults to `9`.
34+
* `-r` - The max retry attempts when trying to join a cluster. Defaults to `3`.
35+
* `-s` - The advertised public hostname:port for server communication. Defaults to `127.0.0.1:7001`.
36+
* `-sl` - The listening hostname for server communication. Defaults to advertised ip.
37+
* `-serverCAFile` - The path of the CAFile. Enables client/peer cert authentication when present.
38+
* `-serverCert` - The cert file of the server.
39+
* `-serverKey` - The key file of the server.
40+
* `-snapshot` - Open or close snapshot. Defaults to `false`.
41+
* `-v` - Enable verbose logging. Defaults to `false`.
42+
* `-vv` - Enable very verbose logging. Defaults to `false`.
43+
* `-version` - Print the version and exit.
44+
* `-w` - The hostname:port of web interface.
45+
46+
## Configuration File
47+
48+
The etcd configuration file is written in [TOML](https://github.com/mojombo/toml)
49+
and read from `/etc/etcd/etcd.conf` by default.
50+
51+
```TOML
52+
advertised_url = "127.0.0.1:4001"
53+
ca_file = ""
54+
cert_file = ""
55+
cors = []
56+
cpu_profile_file = ""
57+
datadir = "."
58+
key_file = ""
59+
listen_host = "127.0.0.1:4001"
60+
machines = []
61+
machines_file = ""
62+
max_cluster_size = 9
63+
max_result_buffer = 1024
64+
max_retry_attempts = 3
65+
name = "default-name"
66+
snapshot = false
67+
verbose = false
68+
very_verbose = false
69+
web_url = ""
70+
71+
[peer]
72+
advertised_url = "127.0.0.1:7001"
73+
ca_file = ""
74+
cert_file = ""
75+
key_file = ""
76+
listen_host = "127.0.0.1:7001"
77+
```
78+
79+
## Environment Variables
80+
81+
* `ETCD_ADVERTISED_URL`
82+
* `ETCD_CA_FILE`
83+
* `ETCD_CERT_FILE`
84+
* `ETCD_CORS`
85+
* `ETCD_CONFIG_FILE`
86+
* `ETCD_CPU_PROFILE_FILE`
87+
* `ETCD_DATADIR`
88+
* `ETCD_KEY_FILE`
89+
* `ETCD_LISTEN_HOST`
90+
* `ETCD_MACHINES`
91+
* `ETCD_MACHINES_FILE`
92+
* `ETCD_MAX_RETRY_ATTEMPTS`
93+
* `ETCD_MAX_CLUSTER_SIZE`
94+
* `ETCD_MAX_RESULT_BUFFER`
95+
* `ETCD_NAME`
96+
* `ETCD_SNAPSHOT`
97+
* `ETCD_VERBOSE`
98+
* `ETCD_VERY_VERBOSE`
99+
* `ETCD_WEB_URL`
100+
* `ETCD_PEER_ADVERTISED_URL`
101+
* `ETCD_PEER_CA_FILE`
102+
* `ETCD_PEER_CERT_FILE`
103+
* `ETCD_PEER_KEY_FILE`
104+
* `ETCD_PEER_LISTEN_HOST`
26 KB
Loading

0 commit comments

Comments
 (0)