Alexander Chuprov
b078fe5ba1
All checks were successful
DCO action / DCO (pull_request) Successful in 6m11s
Build / Build Components (1.22) (pull_request) Successful in 7m50s
Build / Build Components (1.21) (pull_request) Successful in 8m3s
Tests and linters / Lint (pull_request) Successful in 9m45s
Tests and linters / gopls check (pull_request) Successful in 12m40s
Vulncheck / Vulncheck (pull_request) Successful in 12m35s
Tests and linters / Staticcheck (pull_request) Successful in 15m34s
Pre-commit hooks / Pre-commit (pull_request) Successful in 19m38s
Tests and linters / Tests with -race (pull_request) Successful in 21m40s
Tests and linters / Tests (1.22) (pull_request) Successful in 3m21s
Tests and linters / Tests (1.21) (pull_request) Successful in 3m36s
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
36 lines
1 KiB
Go
36 lines
1 KiB
Go
package control
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control/server/ctrlmessage"
|
|
"google.golang.org/grpc/codes"
|
|
"google.golang.org/grpc/status"
|
|
)
|
|
|
|
// HealthCheck returns health status of the local node.
|
|
//
|
|
// If request is unsigned or signed by disallowed key, permission error returns.
|
|
func (s *Server) HealthCheck(_ context.Context, req *control.HealthCheckRequest) (*control.HealthCheckResponse, error) {
|
|
// verify request
|
|
if err := s.isValidRequest(req); err != nil {
|
|
return nil, status.Error(codes.PermissionDenied, err.Error())
|
|
}
|
|
|
|
// create and fill response
|
|
resp := new(control.HealthCheckResponse)
|
|
|
|
body := new(control.HealthCheckResponse_Body)
|
|
resp.SetBody(body)
|
|
|
|
body.SetNetmapStatus(s.healthChecker.NetmapStatus())
|
|
body.SetHealthStatus(s.healthChecker.HealthStatus())
|
|
|
|
// sign the response
|
|
if err := ctrlmessage.Sign(s.key, resp); err != nil {
|
|
return nil, status.Error(codes.Internal, err.Error())
|
|
}
|
|
|
|
return resp, nil
|
|
}
|