提交 a7e69d94 编写于 作者: H Helin Wang

do not do log.Errorln when checkpoint is not found (which is normal)

上级 75b53179
...@@ -59,7 +59,11 @@ func main() { ...@@ -59,7 +59,11 @@ func main() {
cp, err = pserver.NewCheckpointFromFile(*checkpointPath, idx, e) cp, err = pserver.NewCheckpointFromFile(*checkpointPath, idx, e)
if err != nil { if err != nil {
log.Errorf("Fetch checkpoint failed, %s", err) if err == pserver.ErrCheckpointNotFound {
log.Infof("Could not find the pserver checkpoint.")
} else {
log.Errorf("Fetch checkpoint failed, %s", 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.
先完成此消息的编辑!
想要评论请 注册