From 04318ff1be8a871d5b32099c5f99868917e7e70b Mon Sep 17 00:00:00 2001 From: Brandon Philips Date: Thu, 8 Aug 2013 13:21:30 -0700 Subject: [PATCH] fix(etcd): rename ignore to force It was suprising that the ignore file deleted node configuration. Change the name to force! --- etcd.go | 8 +++----- etcd_test.go | 4 ++-- test.go | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/etcd.go b/etcd.go index 3f792b40c..e22152d40 100644 --- a/etcd.go +++ b/etcd.go @@ -40,7 +40,7 @@ var cluster []string var argInfo Info var dirPath string -var ignore bool +var force bool var maxSize int @@ -74,7 +74,7 @@ func init() { flag.StringVar(&dirPath, "d", ".", "the directory to store log and snapshot") - flag.BoolVar(&ignore, "i", false, "ignore the old configuration, create a new node") + flag.BoolVar(&force, "f", false, "force new node configuration if existing is found (WARNING: data loss!)") flag.BoolVar(&snapshot, "snapshot", false, "open or close snapshot") @@ -531,8 +531,7 @@ func getInfo(path string) *Info { infoPath := fmt.Sprintf("%s/info", path) // Delete the old configuration if exist - if ignore { - + if force { logPath := fmt.Sprintf("%s/log", path) confPath := fmt.Sprintf("%s/conf", path) snapshotPath := fmt.Sprintf("%s/snapshot", path) @@ -540,7 +539,6 @@ func getInfo(path string) *Info { os.Remove(logPath) os.Remove(confPath) os.RemoveAll(snapshotPath) - } info := parseInfo(infoPath) diff --git a/etcd_test.go b/etcd_test.go index efc62f286..f84050f4f 100644 --- a/etcd_test.go +++ b/etcd_test.go @@ -14,7 +14,7 @@ import ( func TestSingleNode(t *testing.T) { procAttr := new(os.ProcAttr) procAttr.Files = []*os.File{nil, os.Stdout, os.Stderr} - args := []string{"etcd", "-i", "-d=/tmp/node1"} + args := []string{"etcd", "-f", "-d=/tmp/node1"} process, err := os.StartProcess("etcd", args, procAttr) if err != nil { @@ -58,7 +58,7 @@ func TestSingleNodeRecovery(t *testing.T) { procAttr.Files = []*os.File{nil, os.Stdout, os.Stderr} args := []string{"etcd", "-d=/tmp/node1"} - process, err := os.StartProcess("etcd", append(args, "-i"), procAttr) + process, err := os.StartProcess("etcd", append(args, "-f"), procAttr) if err != nil { t.Fatal("start process failed:" + err.Error()) return diff --git a/test.go b/test.go index 02ce50c5a..a850c691c 100644 --- a/test.go +++ b/test.go @@ -70,7 +70,7 @@ func createCluster(size int, procAttr *os.ProcAttr) ([][]string, []*os.Process, for i, _ := range etcds { var err error - etcds[i], err = os.StartProcess("etcd", append(argGroup[i], "-i"), procAttr) + etcds[i], err = os.StartProcess("etcd", append(argGroup[i], "-f"), procAttr) if err != nil { return nil, nil, err }