Skip to content

Commit

Permalink
etcdctl: cherry pick of etcd-io#10109 to release-3.3
Browse files Browse the repository at this point in the history
Add snapshot file integrity verification in snapshot status.
  • Loading branch information
jingyih committed Sep 25, 2018
1 parent e774f73 commit 60d546e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions etcdctl/ctlv3/command/snapshot_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,14 @@ func dbStatus(p string) dbstatus {
h := crc32.New(crc32.MakeTable(crc32.Castagnoli))

err = db.View(func(tx *bolt.Tx) error {
// check snapshot file integrity first
var dbErrStrings []string
for dbErr := range tx.Check() {
dbErrStrings = append(dbErrStrings, dbErr.Error())
}
if len(dbErrStrings) > 0 {
return fmt.Errorf("snapshot file integrity check failed. %d errors found.\n"+strings.Join(dbErrStrings, "\n"), len(dbErrStrings))
}
ds.TotalSize = tx.Size()
c := tx.Cursor()
for next, _ := c.First(); next != nil; next, _ = c.Next() {
Expand Down

0 comments on commit 60d546e

Please sign in to comment.