From a7e69d949f23c6025ba93578e29020fba694d08c Mon Sep 17 00:00:00 2001 From: Helin Wang Date: Fri, 21 Jul 2017 00:55:58 +0000 Subject: [PATCH] do not do log.Errorln when checkpoint is not found (which is normal) --- go/cmd/pserver/pserver.go | 6 +++++- go/pserver/service.go | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/go/cmd/pserver/pserver.go b/go/cmd/pserver/pserver.go index 20094fbab4d..aa81d0432b1 100644 --- a/go/cmd/pserver/pserver.go +++ b/go/cmd/pserver/pserver.go @@ -59,7 +59,11 @@ func main() { cp, err = pserver.NewCheckpointFromFile(*checkpointPath, idx, e) 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) + } } } diff --git a/go/pserver/service.go b/go/pserver/service.go index 46738413f0a..a7767afa630 100644 --- a/go/pserver/service.go +++ b/go/pserver/service.go @@ -36,6 +36,10 @@ import ( // ElementType is the type of elements of a Parameter. type ElementType int +// ErrCheckpointNotFound indicates that the pserver checkpoint could +// not be found. +var ErrCheckpointNotFound = errors.New("checkpoint not found") + // RPC error message. const ( AlreadyInitialized = "pserver already initialized" @@ -103,6 +107,10 @@ func NewCheckpointFromFile(cpPath string, idx int, e *EtcdClient) (Checkpoint, e return nil, err } + if len(v) == 0 { + return nil, ErrCheckpointNotFound + } + var cpMeta checkpointMeta if err = json.Unmarshal(v, &cpMeta); err != nil { return nil, err -- GitLab