Merge pull request #13880 from ahrtr/fix_dump_logs_panic

etcd-dump-logs will panic if there is no WAL entry after the snapshot
This commit is contained in:
Piotr Tabor 2022-04-06 09:25:17 +02:00 committed by GitHub
commit 047e61df7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -123,8 +123,10 @@ and output a hex encoded line of binary for each input line`)
fmt.Printf("WAL metadata:\nnodeID=%s clusterID=%s term=%d commitIndex=%d vote=%s\n",
id, cid, state.Term, state.Commit, vid)
fmt.Printf("WAL entries:\n")
fmt.Printf("lastIndex=%d\n", ents[len(ents)-1].Index)
fmt.Printf("WAL entries: %d\n", len(ents))
if len(ents) > 0 {
fmt.Printf("lastIndex=%d\n", ents[len(ents)-1].Index)
}
fmt.Printf("%4s\t%10s\ttype\tdata", "term", "index")
if *streamdecoder != "" {