RPC: healthz should return an error when the node is syncing (#7890)

* RPC: healthz should return an error when the node is syncing

* fix test

* fix test

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
Preston Van Loon
2020-11-21 16:29:55 -08:00
committed by GitHub
parent 34a26740ff
commit 71ec919306
2 changed files with 5 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ package rpc
import (
"context"
"errors"
"fmt"
"net"
"sync"
@@ -337,6 +338,9 @@ func (s *Service) Stop() error {
// Status returns nil or credentialError
func (s *Service) Status() error {
if s.syncService.Syncing() {
return errors.New("syncing")
}
if s.credentialError != nil {
return s.credentialError
}

View File

@@ -45,7 +45,7 @@ func TestLifecycle_OK(t *testing.T) {
func TestStatus_CredentialError(t *testing.T) {
credentialErr := errors.New("credentialError")
s := &Service{credentialError: credentialErr}
s := &Service{credentialError: credentialErr, syncService: &mockSync.Sync{IsSyncing: false}}
assert.ErrorContains(t, s.credentialError.Error(), s.Status())
}