fix(etcd): rename ignore to force
It was suprising that the ignore file deleted node configuration. Change the name to force!release-0.4
parent
27000cf5df
commit
04318ff1be
8
etcd.go
8
etcd.go
|
@ -40,7 +40,7 @@ var cluster []string
|
||||||
var argInfo Info
|
var argInfo Info
|
||||||
var dirPath string
|
var dirPath string
|
||||||
|
|
||||||
var ignore bool
|
var force bool
|
||||||
|
|
||||||
var maxSize int
|
var maxSize int
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ func init() {
|
||||||
|
|
||||||
flag.StringVar(&dirPath, "d", ".", "the directory to store log and snapshot")
|
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")
|
flag.BoolVar(&snapshot, "snapshot", false, "open or close snapshot")
|
||||||
|
|
||||||
|
@ -531,8 +531,7 @@ func getInfo(path string) *Info {
|
||||||
infoPath := fmt.Sprintf("%s/info", path)
|
infoPath := fmt.Sprintf("%s/info", path)
|
||||||
|
|
||||||
// Delete the old configuration if exist
|
// Delete the old configuration if exist
|
||||||
if ignore {
|
if force {
|
||||||
|
|
||||||
logPath := fmt.Sprintf("%s/log", path)
|
logPath := fmt.Sprintf("%s/log", path)
|
||||||
confPath := fmt.Sprintf("%s/conf", path)
|
confPath := fmt.Sprintf("%s/conf", path)
|
||||||
snapshotPath := fmt.Sprintf("%s/snapshot", path)
|
snapshotPath := fmt.Sprintf("%s/snapshot", path)
|
||||||
|
@ -540,7 +539,6 @@ func getInfo(path string) *Info {
|
||||||
os.Remove(logPath)
|
os.Remove(logPath)
|
||||||
os.Remove(confPath)
|
os.Remove(confPath)
|
||||||
os.RemoveAll(snapshotPath)
|
os.RemoveAll(snapshotPath)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
info := parseInfo(infoPath)
|
info := parseInfo(infoPath)
|
||||||
|
|
|
@ -14,7 +14,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", "-i", "-d=/tmp/node1"}
|
args := []string{"etcd", "-f", "-d=/tmp/node1"}
|
||||||
|
|
||||||
process, err := os.StartProcess("etcd", args, procAttr)
|
process, err := os.StartProcess("etcd", args, procAttr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -58,7 +58,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", "-d=/tmp/node1"}
|
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 {
|
if err != nil {
|
||||||
t.Fatal("start process failed:" + err.Error())
|
t.Fatal("start process failed:" + err.Error())
|
||||||
return
|
return
|
||||||
|
|
2
test.go
2
test.go
|
@ -70,7 +70,7 @@ func createCluster(size int, procAttr *os.ProcAttr) ([][]string, []*os.Process,
|
||||||
|
|
||||||
for i, _ := range etcds {
|
for i, _ := range etcds {
|
||||||
var err error
|
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 {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue