提交 bea40565 编写于 作者: H helinwang 提交者: GitHub

Merge pull request #2997 from helinwang/checkpoint

do not do log.Errorln when checkpoint is not found (which is normal)
...@@ -59,9 +59,13 @@ func main() { ...@@ -59,9 +59,13 @@ func main() {
cp, err = pserver.NewCheckpointFromFile(*checkpointPath, idx, e) cp, err = pserver.NewCheckpointFromFile(*checkpointPath, idx, e)
if err != nil { if err != nil {
if err == pserver.ErrCheckpointNotFound {
log.Infof("Could not find the pserver checkpoint.")
} else {
log.Errorf("Fetch checkpoint failed, %s", err) log.Errorf("Fetch checkpoint failed, %s", err)
} }
} }
}
s, err := pserver.NewService(idx, *checkpointInterval, *checkpointPath, e, cp) s, err := pserver.NewService(idx, *checkpointInterval, *checkpointPath, e, cp)
candy.Must(err) candy.Must(err)
......
...@@ -36,6 +36,10 @@ import ( ...@@ -36,6 +36,10 @@ import (
// ElementType is the type of elements of a Parameter. // ElementType is the type of elements of a Parameter.
type ElementType int type ElementType int
// ErrCheckpointNotFound indicates that the pserver checkpoint could
// not be found.
var ErrCheckpointNotFound = errors.New("checkpoint not found")
// RPC error message. // RPC error message.
const ( const (
AlreadyInitialized = "pserver already initialized" AlreadyInitialized = "pserver already initialized"
...@@ -103,6 +107,10 @@ func NewCheckpointFromFile(cpPath string, idx int, e *EtcdClient) (Checkpoint, e ...@@ -103,6 +107,10 @@ func NewCheckpointFromFile(cpPath string, idx int, e *EtcdClient) (Checkpoint, e
return nil, err return nil, err
} }
if len(v) == 0 {
return nil, ErrCheckpointNotFound
}
var cpMeta checkpointMeta var cpMeta checkpointMeta
if err = json.Unmarshal(v, &cpMeta); err != nil { if err = json.Unmarshal(v, &cpMeta); err != nil {
return nil, err return nil, err
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册