Add more information to health check

Prior to this patch, if the MySQL for signer down, the health check of
Server just warning out:
- "Trust not fully operational: Trust is not healthy"

Which is not enough to find the problem.

Signed-off-by: Hu Keping <hukeping@huawei.com>
This commit is contained in:
HuKeping 2016-01-07 21:55:23 +08:00
parent af40d720c0
commit 837f659e85
1 changed files with 9 additions and 4 deletions

View File

@ -185,11 +185,16 @@ func (trust *NotarySigner) CheckHealth(timeout time.Duration) error {
status, err := trust.kmClient.CheckHealth(ctx, &pb.Void{})
defer cancel()
if err == nil && len(status.Status) > 0 {
return fmt.Errorf("Trust is not healthy")
} else if err != nil && grpc.Code(err) == codes.DeadlineExceeded {
return fmt.Errorf(
"Timed out reaching trust service after %s.", timeout)
var stats string
for k, v := range status.Status {
stats += k + ":" + v + "; "
}
return fmt.Errorf("Trust is not healthy: %s", stats)
}
if err != nil && grpc.Code(err) == codes.DeadlineExceeded {
return fmt.Errorf("Timed out reaching trust service after %s.", timeout)
}
return err
}