mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
fix(etcd): rename ignore to force
It was suprising that the ignore file deleted node configuration. Change the name to force!
This commit is contained in:
parent
27000cf5df
commit
04318ff1be
8
etcd.go
8
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)
|
||||
|
@ -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
|
||||
|
2
test.go
2
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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user