Rpc service: log error if slasher is not up (#6907)

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
terence tsao 2020-08-06 10:13:09 -07:00 committed by GitHub
parent 1d679c9533
commit dc0f2140b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -39,6 +39,7 @@ go_library(
"@com_github_sirupsen_logrus//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library",
"@io_opencensus_go//plugin/ocgrpc:go_default_library", "@io_opencensus_go//plugin/ocgrpc:go_default_library",
"@org_golang_google_grpc//:go_default_library", "@org_golang_google_grpc//:go_default_library",
"@org_golang_google_grpc//connectivity:go_default_library",
"@org_golang_google_grpc//credentials:go_default_library", "@org_golang_google_grpc//credentials:go_default_library",
"@org_golang_google_grpc//peer:go_default_library", "@org_golang_google_grpc//peer:go_default_library",
"@org_golang_google_grpc//reflection:go_default_library", "@org_golang_google_grpc//reflection:go_default_library",

View File

@ -40,6 +40,7 @@ import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"go.opencensus.io/plugin/ocgrpc" "go.opencensus.io/plugin/ocgrpc"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/connectivity"
"google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials"
"google.golang.org/grpc/peer" "google.golang.org/grpc/peer"
"google.golang.org/grpc/reflection" "google.golang.org/grpc/reflection"
@ -341,6 +342,11 @@ func (s *Service) startSlasherClient() {
log.Errorf("Could not dial endpoint: %s, %v", s.slasherProvider, err) log.Errorf("Could not dial endpoint: %s, %v", s.slasherProvider, err)
return return
} }
if conn.GetState() != connectivity.Ready {
log.Errorf("Slasher status is %s, please verify slasher is up", conn.GetState())
return
}
log.Info("Successfully started hash slinging slasher© gRPC connection") log.Info("Successfully started hash slinging slasher© gRPC connection")
s.slasherConn = conn s.slasherConn = conn
s.slasherClient = slashpb.NewSlasherClient(s.slasherConn) s.slasherClient = slashpb.NewSlasherClient(s.slasherConn)