Merge pull request #8726 from amenzhinsky/grpc-hc-error

Return grpc serving status in health check errors
This commit is contained in:
Daniel Nephin 2020-09-25 13:24:32 -04:00 committed by GitHub
commit e1855afbe1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

3
.changelog/8726.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:improvement
checks: add health status to the failure message when gRPC healthchecks fail.
```

View File

@ -13,8 +13,6 @@ import (
"google.golang.org/grpc/resolver"
)
var ErrGRPCUnhealthy = fmt.Errorf("gRPC application didn't report service healthy")
// GrpcHealthProbe connects to gRPC application and queries health service for application/service status.
type GrpcHealthProbe struct {
server string
@ -69,8 +67,8 @@ func (probe *GrpcHealthProbe) Check(target string) error {
if err != nil {
return err
}
if response == nil || response.Status != hv1.HealthCheckResponse_SERVING {
return ErrGRPCUnhealthy
if response.Status != hv1.HealthCheckResponse_SERVING {
return fmt.Errorf("gRPC %s serving status: %s", target, response.Status)
}
return nil