mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdctl: cherry pick of #10109 to release-3.1
Add snapshot file integrity verification when querying snapshot status.
This commit is contained in:
parent
216be8b79b
commit
87b4e08c29
@ -417,6 +417,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() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user