forked from TrueCloudLab/frostfs-node
Dmitrii Stepanov
d62c6e4ce6
Add tracing spans for PUT requests. Add tracing spans for DELETE requests. Add tracing spans for SELECT requests. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
37 lines
1 KiB
Go
37 lines
1 KiB
Go
package control
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control"
|
|
"google.golang.org/grpc/codes"
|
|
"google.golang.org/grpc/status"
|
|
)
|
|
|
|
func (s *Server) RestoreShard(ctx context.Context, req *control.RestoreShardRequest) (*control.RestoreShardResponse, error) {
|
|
err := s.isValidRequest(req)
|
|
if err != nil {
|
|
return nil, status.Error(codes.PermissionDenied, err.Error())
|
|
}
|
|
|
|
shardID := shard.NewIDFromBytes(req.GetBody().GetShard_ID())
|
|
|
|
var prm shard.RestorePrm
|
|
prm.WithPath(req.GetBody().GetFilepath())
|
|
prm.WithIgnoreErrors(req.GetBody().GetIgnoreErrors())
|
|
|
|
err = s.s.RestoreShard(ctx, shardID, prm)
|
|
if err != nil {
|
|
return nil, status.Error(codes.Internal, err.Error())
|
|
}
|
|
|
|
resp := new(control.RestoreShardResponse)
|
|
resp.SetBody(new(control.RestoreShardResponse_Body))
|
|
|
|
err = SignMessage(s.key, resp)
|
|
if err != nil {
|
|
return nil, status.Error(codes.Internal, err.Error())
|
|
}
|
|
return resp, nil
|
|
}
|