tools: Add -wal-dir flag on etcd-dump-logs to make it compatible with ETCD_WAL_DIR variable (#13672)

This commit is contained in:
Luiz Gustavo 2022-03-08 02:29:20 -03:00 committed by GitHub
parent 950a47504e
commit b6a2d2d48a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -13,7 +13,9 @@ Usage:
- data_dir/member/wal/0000000000000000-0000000000000000.wal
Flags:
-wal-dir string
If set, dumps WAL from the informed path, rather than following the
standard 'data_dir/member/wal/' location
-entry-type string
If set, filters output by entry type. Must be one or more than one of:
ConfigChange, Normal, Request, InternalRaftRequest,

View File

@ -45,6 +45,7 @@ const (
func main() {
snapfile := flag.String("start-snap", "", "The base name of snapshot file to start dumping")
waldir := flag.String("wal-dir", "", "If set, dumps WAL from the informed path, rather than following the standard 'data_dir/member/wal/' location")
index := flag.Uint64("start-index", 0, "The index to start dumping")
// Default entry types are Normal and ConfigChange
entrytype := flag.String("entry-type", defaultEntryTypes, `If set, filters output by entry type. Must be one or more than one of:
@ -103,7 +104,12 @@ and output a hex encoded line of binary for each input line`)
fmt.Println("Start dumping log entries from snapshot.")
}
w, err := wal.OpenForRead(zap.NewExample(), walDir(dataDir), walsnap)
wd := *waldir
if wd == "" {
wd = walDir(dataDir)
}
w, err := wal.OpenForRead(zap.NewExample(), wd, walsnap)
if err != nil {
log.Fatalf("Failed opening WAL: %v", err)
}