From e2af59e4d15ac650689c02a72d3c468da0e53ac2 Mon Sep 17 00:00:00 2001 From: Gyuho Lee Date: Wed, 2 May 2018 14:17:00 -0700 Subject: [PATCH 1/2] raftsnap: clarify "ErrNoDBSnapshot" Signed-off-by: Gyuho Lee --- raftsnap/db.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/raftsnap/db.go b/raftsnap/db.go index 9c8a1f94771..3c2f577a546 100644 --- a/raftsnap/db.go +++ b/raftsnap/db.go @@ -76,9 +76,18 @@ func (s *Snapshotter) DBFilePath(id uint64) (string, error) { if _, err := fileutil.ReadDir(s.dir); err != nil { return "", err } - if fn := s.dbFilePath(id); fileutil.Exist(fn) { + fn := s.dbFilePath(id) + if fileutil.Exist(fn) { return fn, nil } + if s.lg != nil { + s.lg.Warn( + "failed to find [SNAPSHOT-INDEX].snap.db", + zap.Uint64("snapshot-index", id), + zap.String("snapshot-file-path", fn), + zap.Error(ErrNoDBSnapshot), + ) + } return "", ErrNoDBSnapshot } From 47ab4e22d20c41d8dfadd103b9914932f1eb420d Mon Sep 17 00:00:00 2001 From: Gyuho Lee Date: Wed, 2 May 2018 14:17:22 -0700 Subject: [PATCH 2/2] etcdserver: clarify errors from "openSnapshotBackend" Signed-off-by: Gyuho Lee --- etcdserver/backend.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etcdserver/backend.go b/etcdserver/backend.go index 4a59c8415da..8ad9fed7df7 100644 --- a/etcdserver/backend.go +++ b/etcdserver/backend.go @@ -42,10 +42,10 @@ func newBackend(cfg ServerConfig) backend.Backend { func openSnapshotBackend(cfg ServerConfig, ss *raftsnap.Snapshotter, snapshot raftpb.Snapshot) (backend.Backend, error) { snapPath, err := ss.DBFilePath(snapshot.Metadata.Index) if err != nil { - return nil, fmt.Errorf("database snapshot file path error: %v", err) + return nil, fmt.Errorf("failed to find database snapshot file (%v)", err) } if err := os.Rename(snapPath, cfg.backendPath()); err != nil { - return nil, fmt.Errorf("rename snapshot file error: %v", err) + return nil, fmt.Errorf("failed to rename database snapshot file (%v)", err) } return openBackend(cfg), nil }