Browse Source

Merge branch 'master' of https://github.com/coreos/etcd into clean-up-config

Ben Johnson 12 years ago
parent
commit
15eee885d7

+ 3 - 3
README.md

@@ -378,12 +378,12 @@ For testing you can use the certificates in the `fixtures/ca` directory.
 Let's configure etcd to use this keypair:
 Let's configure etcd to use this keypair:
 
 
 ```sh
 ```sh
-./etcd -name node0 -data-dir node0 -cert-file=./fixtures/ca/server.crt -key-file=./fixtures/ca/server.key.insecure -force-config
+./etcd -f -name node0 -data-dir node0 -cert-file=./fixtures/ca/server.crt -key-file=./fixtures/ca/server.key.insecure
 ```
 ```
 
 
 There are a few new options we're using:
 There are a few new options we're using:
 
 
-* `-force-config` - forces a new node configuration, even if an existing configuration is found. (WARNING: data loss!)
+* `-f` - forces a new node 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.
 * `-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:
 You can now test the configuration using HTTPS:
@@ -413,7 +413,7 @@ 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.
 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.
 
 
 ```sh
 ```sh
-./etcd -name node0 -data-dir node0 -ca-file=./fixtures/ca/ca.crt -cert-file=./fixtures/ca/server.crt -key-file=./fixtures/ca/server.key.insecure -force-config
+./etcd -f -name node0 -data-dir node0 -ca-file=./fixtures/ca/ca.crt -cert-file=./fixtures/ca/server.crt -key-file=./fixtures/ca/server.key.insecure
 ```
 ```
 
 
 ```-ca-file``` is the path to the CA cert.
 ```-ca-file``` is the path to the CA cert.

+ 2 - 0
server/server.go

@@ -162,6 +162,7 @@ func (s *Server) handleFunc(path string, f func(http.ResponseWriter, *http.Reque
 		if err := f(w, req); err != nil {
 		if err := f(w, req); err != nil {
 			if etcdErr, ok := err.(*etcdErr.Error); ok {
 			if etcdErr, ok := err.(*etcdErr.Error); ok {
 				log.Debug("Return error: ", (*etcdErr).Error())
 				log.Debug("Return error: ", (*etcdErr).Error())
+				w.Header().Set("Content-Type", "application/json")
 				etcdErr.Write(w)
 				etcdErr.Write(w)
 			} else {
 			} else {
 				http.Error(w, err.Error(), http.StatusInternalServerError)
 				http.Error(w, err.Error(), http.StatusInternalServerError)
@@ -262,6 +263,7 @@ func (s *Server) Dispatch(c raft.Command, w http.ResponseWriter, req *http.Reque
 			e, _ := result.(*store.Event)
 			e, _ := result.(*store.Event)
 			b, _ = json.Marshal(e)
 			b, _ = json.Marshal(e)
 
 
+			w.Header().Set("Content-Type", "application/json")
 			// etcd index should be the same as the event index
 			// etcd index should be the same as the event index
 			// which is also the last modified index of the node
 			// which is also the last modified index of the node
 			w.Header().Add("X-Etcd-Index", fmt.Sprint(e.Index))
 			w.Header().Add("X-Etcd-Index", fmt.Sprint(e.Index))

+ 1 - 0
server/v2/get_handler.go

@@ -68,6 +68,7 @@ func GetHandler(w http.ResponseWriter, req *http.Request, s Server) error {
 		}
 		}
 	}
 	}
 
 
+	w.Header().Set("Content-Type", "application/json")
 	w.Header().Add("X-Etcd-Index", fmt.Sprint(s.Store().Index()))
 	w.Header().Add("X-Etcd-Index", fmt.Sprint(s.Store().Index()))
 	w.Header().Add("X-Raft-Index", fmt.Sprint(s.CommitIndex()))
 	w.Header().Add("X-Raft-Index", fmt.Sprint(s.CommitIndex()))
 	w.Header().Add("X-Raft-Term", fmt.Sprint(s.Term()))
 	w.Header().Add("X-Raft-Term", fmt.Sprint(s.Term()))

+ 1 - 1
tests/functional/internal_version_test.go

@@ -31,7 +31,7 @@ func TestInternalVersion(t *testing.T) {
 
 
 	procAttr := new(os.ProcAttr)
 	procAttr := new(os.ProcAttr)
 	procAttr.Files = []*os.File{nil, os.Stdout, os.Stderr}
 	procAttr.Files = []*os.File{nil, os.Stdout, os.Stderr}
-	args := []string{"etcd", "-name=node1", "-force-config", "-data-dir=/tmp/node1", "-peers=" + fakeURL.Host}
+	args := []string{"etcd", "-name=node1", "-f", "-data-dir=/tmp/node1", "-peers=" + fakeURL.Host}
 
 
 	process, err := os.StartProcess(EtcdBinPath, args, procAttr)
 	process, err := os.StartProcess(EtcdBinPath, args, procAttr)
 	if err != nil {
 	if err != nil {

+ 1 - 0
tests/functional/node1.etcd/conf

@@ -0,0 +1 @@
+{"commitIndex":43,"peers":[{"name":"node2","connectionString":""},{"name":"node3","connectionString":""},{"name":"node4","connectionString":""},{"name":"node5","connectionString":""},{"name":"node6","connectionString":""},{"name":"node7","connectionString":""},{"name":"node9","connectionString":""},{"name":"node8","connectionString":""}]}

+ 1 - 0
tests/functional/node1.etcd/info

@@ -0,0 +1 @@
+{"name":"node1","raftURL":"http://127.0.0.1:7001","etcdURL":"http://127.0.0.1:4001","raftListenHost":"127.0.0.1:7001","etcdListenHost":"127.0.0.1:4001","raftTLS":{"CertFile":"","KeyFile":"","CAFile":""},"etcdTLS":{"CertFile":"","KeyFile":"","CAFile":""}}

BIN
tests/functional/node1.etcd/log


+ 2 - 2
tests/functional/remove_node_test.go

@@ -50,7 +50,7 @@ func TestRemoveNode(t *testing.T) {
 				etcds[2], err = os.StartProcess(EtcdBinPath, argGroup[2], procAttr)
 				etcds[2], err = os.StartProcess(EtcdBinPath, argGroup[2], procAttr)
 			} else {
 			} else {
 				// rejoin without log
 				// rejoin without log
-				etcds[2], err = os.StartProcess(EtcdBinPath, append(argGroup[2], "-force-config"), procAttr)
+				etcds[2], err = os.StartProcess(EtcdBinPath, append(argGroup[2], "-f"), procAttr)
 			}
 			}
 
 
 			if err != nil {
 			if err != nil {
@@ -93,7 +93,7 @@ func TestRemoveNode(t *testing.T) {
 				etcds[2], err = os.StartProcess(EtcdBinPath, append(argGroup[2]), procAttr)
 				etcds[2], err = os.StartProcess(EtcdBinPath, append(argGroup[2]), procAttr)
 			} else {
 			} else {
 				// rejoin without log
 				// rejoin without log
-				etcds[2], err = os.StartProcess(EtcdBinPath, append(argGroup[2], "-force-config"), procAttr)
+				etcds[2], err = os.StartProcess(EtcdBinPath, append(argGroup[2], "-f"), procAttr)
 			}
 			}
 
 
 			if err != nil {
 			if err != nil {

+ 1 - 1
tests/functional/simple_snapshot_test.go

@@ -16,7 +16,7 @@ func TestSimpleSnapshot(t *testing.T) {
 	procAttr.Files = []*os.File{nil, os.Stdout, os.Stderr}
 	procAttr.Files = []*os.File{nil, os.Stdout, os.Stderr}
 	args := []string{"etcd", "-name=node1", "-data-dir=/tmp/node1", "-snapshot=true", "-snapshot-count=500"}
 	args := []string{"etcd", "-name=node1", "-data-dir=/tmp/node1", "-snapshot=true", "-snapshot-count=500"}
 
 
-	process, err := os.StartProcess(EtcdBinPath, append(args, "-force-config"), procAttr)
+	process, err := os.StartProcess(EtcdBinPath, append(args, "-f"), procAttr)
 	if err != nil {
 	if err != nil {
 		t.Fatal("start process failed:" + err.Error())
 		t.Fatal("start process failed:" + err.Error())
 	}
 	}

+ 1 - 1
tests/functional/single_node_recovery_test.go

@@ -15,7 +15,7 @@ func TestSingleNodeRecovery(t *testing.T) {
 	procAttr.Files = []*os.File{nil, os.Stdout, os.Stderr}
 	procAttr.Files = []*os.File{nil, os.Stdout, os.Stderr}
 	args := []string{"etcd", "-name=node1", "-data-dir=/tmp/node1"}
 	args := []string{"etcd", "-name=node1", "-data-dir=/tmp/node1"}
 
 
-	process, err := os.StartProcess(EtcdBinPath, append(args, "-force-config"), procAttr)
+	process, err := os.StartProcess(EtcdBinPath, append(args, "-f"), procAttr)
 	if err != nil {
 	if err != nil {
 		t.Fatal("start process failed:" + err.Error())
 		t.Fatal("start process failed:" + err.Error())
 		return
 		return

+ 1 - 1
tests/functional/single_node_test.go

@@ -12,7 +12,7 @@ import (
 func TestSingleNode(t *testing.T) {
 func TestSingleNode(t *testing.T) {
 	procAttr := new(os.ProcAttr)
 	procAttr := new(os.ProcAttr)
 	procAttr.Files = []*os.File{nil, os.Stdout, os.Stderr}
 	procAttr.Files = []*os.File{nil, os.Stdout, os.Stderr}
-	args := []string{"etcd", "-name=node1", "-force-config", "-data-dir=/tmp/node1"}
+	args := []string{"etcd", "-name=node1", "-f", "-data-dir=/tmp/node1"}
 
 
 	process, err := os.StartProcess(EtcdBinPath, args, procAttr)
 	process, err := os.StartProcess(EtcdBinPath, args, procAttr)
 	if err != nil {
 	if err != nil {

+ 1 - 1
tests/functional/util.go

@@ -102,7 +102,7 @@ func CreateCluster(size int, procAttr *os.ProcAttr, ssl bool) ([][]string, []*os
 
 
 	for i, _ := range etcds {
 	for i, _ := range etcds {
 		var err error
 		var err error
-		etcds[i], err = os.StartProcess(EtcdBinPath, append(argGroup[i], "-force-config"), procAttr)
+		etcds[i], err = os.StartProcess(EtcdBinPath, append(argGroup[i], "-f"), procAttr)
 		if err != nil {
 		if err != nil {
 			return nil, nil, err
 			return nil, nil, err
 		}
 		}

+ 1 - 1
tests/functional/version_check_test.go

@@ -11,7 +11,7 @@ import (
 func TestVersionCheck(t *testing.T) {
 func TestVersionCheck(t *testing.T) {
 	procAttr := new(os.ProcAttr)
 	procAttr := new(os.ProcAttr)
 	procAttr.Files = []*os.File{nil, os.Stdout, os.Stderr}
 	procAttr.Files = []*os.File{nil, os.Stdout, os.Stderr}
-	args := []string{"etcd", "-name=node1", "-force-config", "-data-dir=/tmp/version_check"}
+	args := []string{"etcd", "-name=node1", "-f", "-data-dir=/tmp/version_check"}
 
 
 	process, err := os.StartProcess(EtcdBinPath, args, procAttr)
 	process, err := os.StartProcess(EtcdBinPath, args, procAttr)
 	if err != nil {
 	if err != nil {