From 0b9622c418d89d76e9b82ac1fa4969d2b2087a79 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Fri, 7 Apr 2023 14:21:05 +0300 Subject: [PATCH] [#191] control: Add Doctor RPC Doctor RPC performs complex operations on the storage engine. Currently only duplicate removal is supported. Signed-off-by: Evgenii Stratonikov --- pkg/services/control/convert.go | 18 ++++++++++ pkg/services/control/rpc.go | 14 ++++++++ pkg/services/control/server/doctor.go | 37 +++++++++++++++++++++ pkg/services/control/service.pb.go | Bin 111752 -> 121755 bytes pkg/services/control/service.proto | 28 ++++++++++++++++ pkg/services/control/service_frostfs.pb.go | Bin 52798 -> 57948 bytes pkg/services/control/service_grpc.pb.go | Bin 18217 -> 20760 bytes 7 files changed, 97 insertions(+) create mode 100644 pkg/services/control/server/doctor.go diff --git a/pkg/services/control/convert.go b/pkg/services/control/convert.go index 833288bb7..f7582dd68 100644 --- a/pkg/services/control/convert.go +++ b/pkg/services/control/convert.go @@ -200,3 +200,21 @@ func (w *flushCacheResponseWrapper) FromGRPCMessage(m grpc.Message) error { w.FlushCacheResponse = r return nil } + +type doctorResponseWrapper struct { + *DoctorResponse +} + +func (w *doctorResponseWrapper) ToGRPCMessage() grpc.Message { + return w.DoctorResponse +} + +func (w *doctorResponseWrapper) FromGRPCMessage(m grpc.Message) error { + r, ok := m.(*DoctorResponse) + if !ok { + return message.NewUnexpectedMessageType(m, (*DoctorResponse)(nil)) + } + + w.DoctorResponse = r + return nil +} diff --git a/pkg/services/control/rpc.go b/pkg/services/control/rpc.go index 0779e177b..2676ea7a5 100644 --- a/pkg/services/control/rpc.go +++ b/pkg/services/control/rpc.go @@ -18,6 +18,7 @@ const ( rpcSynchronizeTree = "SynchronizeTree" rpcEvacuateShard = "EvacuateShard" rpcFlushCache = "FlushCache" + rpcDoctor = "Doctor" ) // HealthCheck executes ControlService.HealthCheck RPC. @@ -191,3 +192,16 @@ func FlushCache(cli *client.Client, req *FlushCacheRequest, opts ...client.CallO return wResp.FlushCacheResponse, nil } + +// Doctor executes ControlService.Doctor RPC. +func Doctor(cli *client.Client, req *DoctorRequest, opts ...client.CallOption) (*DoctorResponse, error) { + wResp := &doctorResponseWrapper{new(DoctorResponse)} + wReq := &requestWrapper{m: req} + + err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceName, rpcDoctor), wReq, wResp, opts...) + if err != nil { + return nil, err + } + + return wResp.DoctorResponse, nil +} diff --git a/pkg/services/control/server/doctor.go b/pkg/services/control/server/doctor.go new file mode 100644 index 000000000..2c91d4c2b --- /dev/null +++ b/pkg/services/control/server/doctor.go @@ -0,0 +1,37 @@ +package control + +import ( + "context" + + "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/engine" + "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (s *Server) Doctor(ctx context.Context, req *control.DoctorRequest) (*control.DoctorResponse, error) { + err := s.isValidRequest(req) + if err != nil { + return nil, status.Error(codes.PermissionDenied, err.Error()) + } + + if !req.Body.RemoveDuplicates { + return nil, status.Error(codes.InvalidArgument, "operation not specified") + } + + var prm engine.RemoveDuplicatesPrm + prm.Concurrency = int(req.Body.Concurrency) + + err = s.s.RemoveDuplicates(ctx, prm) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + resp := &control.DoctorResponse{Body: &control.DoctorResponse_Body{}} + + err = SignMessage(s.key, resp) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + return resp, nil +} diff --git a/pkg/services/control/service.pb.go b/pkg/services/control/service.pb.go index 78e7b0598d93a7a763bfc152815feab18749387b..ca3e2770e1425432e663a12d4763d7420d57f637 100644 GIT binary patch delta 6014 zcma(#X;@TOmftC;DypbrQ3Mfz0$kXww#MR6$h{MNlAhjC!P6BC(OC;)k9q7`-UHn zbI(2dc5mJ1zR|pVOxtJN9y7;P>2`- zeYP^6ar-J@Q+A20TRVpJYt?LL?_AavY-I64YH2;Q9ofO%gY1$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e(`#Har>z|)+5>g$lhC->`+Njn<&ePOrIiH+Qy(K{j8 zPswhTq4hg?@)PL5&LOfqS3{%o7_l^wvIt&yVCVGD5b^8DK85se!2AGzHxs2{8cpXK zAtunCB$doRVI#=1hf{v1md9h@4QV`djga9V4~N)H-r6Qe9U6i3DjCsJL^Ig5@*Fva z?Py6eSheyHIHXod`=_IxW|*XPNWmQrv31cD)dDu&*v>tCZRE8;io%f~AG%v$hQg63 z4v{o=7r!zcQ)J2PHlFZJyLcBINiy=`E=Z?0TOe}hZoVgf>*jsWDuWOu-+TnSxH+%2 zLOO4W6y>v4_#M5qi@heed3PK#TJHvjk~5*_TUno(=xMqK>DAIEo94KDvyA(i=9`DqV~UtY$|kg>=QUmsqeuo0fp8F zsVMb4oS_$vGjj2-AbuLCspx%%wspf(0+K%bWv$K=tW|c3T^aZ4WUcEbS&N~5GQ7`E z`%gn3C7hC< zb+Ir6$lb$X9=pJT?6)BdJ3iwJUyy&UhoOUA%+zyLN5K~v+VG(ag;Uab=%M|+e9X86 zU()4^@{<9DID#PElo^3=p1<=1`McHStdRPi4(NfxxzKR$sN%u6mUDoV{uuAKaFsk}f? zYHog6s!M4>PG)jqNow)tjmlFP*<4`S)=!q&tjqz^GCA;|$mD=}p2@o6{$^!su&c delta 9 Qcmca}gn8c_<_&h|02tr|y#N3J diff --git a/pkg/services/control/service_grpc.pb.go b/pkg/services/control/service_grpc.pb.go index 2cfddd7f57c2371a832755a5ac9f25f7e74d1eaf..4a4fbeac1f727cc433a38e8d9ebaf1a9c4a87956 100644 GIT binary patch delta 1551 zcmZ44$2emV3Ea^QW?)r`=C}-!ntWe~7i7>|SFHY$o~$pz50YPK zBP)bq5hP?PMEO7}?CkOQ%*HLJv^c{#F*zeuiHp-YKd+=HKPNb~s4O!%HQpsZxg@_R z9>aKWz(B*F6QW3oOLOu;N8!omxY;&4GS#q8c3@?3hDa$Cq!y*+7v&Z!6a!65OixuP zN-ZuaDorjaEy~PGSI7s-CzfOaV_P9VPa!ogJu@#=j|*z{9ZR z9|QtU9~rSF6_C7z zwdiIqn|F-Z(h5lauC4Iqmv)aCu_cxd4wom}8;Qb#Fu`a#jG1U#17n`o_9H5VOa|H} u0f|G6BM5 z2`C^l*~M32@)FyU%}0#?BK)z?wqkOosletUvxi_o6wd&)PyTH#u$js78AwtMWZvXH zE1}J^t?z?XBYA7{LfdSRJrF;EEMDut3=+Wf6i70}87K+z70AdxF2b96+#W+5fb2D} ReI7BJ6TJmkCm#w30{~nCq(cAz