2024-06-20 16:03:58 +03:00
|
|
|
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"
|
|
|
|
)
|
|
|
|
|
|
|
|
// GetNetmapStatus gets node status in FrostFS network.
|
2025-02-05 16:37:11 +03:00
|
|
|
func (s *Server) GetNetmapStatus(ctx context.Context, req *control.GetNetmapStatusRequest) (*control.GetNetmapStatusResponse, error) {
|
2024-06-20 16:03:58 +03:00
|
|
|
if err := s.isValidRequest(req); err != nil {
|
|
|
|
return nil, status.Error(codes.PermissionDenied, err.Error())
|
|
|
|
}
|
|
|
|
|
2025-02-05 16:37:11 +03:00
|
|
|
st, epoch, err := s.nodeState.GetNetmapStatus(ctx)
|
2024-06-20 16:03:58 +03:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
resp := &control.GetNetmapStatusResponse{
|
|
|
|
Body: &control.GetNetmapStatusResponse_Body{
|
|
|
|
Status: st,
|
|
|
|
Epoch: epoch,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := ctrlmessage.Sign(s.key, resp); err != nil {
|
|
|
|
return nil, status.Error(codes.Internal, err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
return resp, nil
|
|
|
|
}
|