frostfs-node/pkg/services/control/server/seal_writecache.go
Evgenii Stratonikov 66a872cf8f
All checks were successful
DCO action / DCO (pull_request) Successful in 4m7s
Tests and linters / Run gofumpt (pull_request) Successful in 4m12s
Vulncheck / Vulncheck (pull_request) Successful in 4m47s
Build / Build Components (1.22) (pull_request) Successful in 5m42s
Build / Build Components (1.23) (pull_request) Successful in 5m41s
Pre-commit hooks / Pre-commit (pull_request) Successful in 5m49s
Tests and linters / Staticcheck (pull_request) Successful in 5m53s
Tests and linters / Tests (1.22) (pull_request) Successful in 6m4s
Tests and linters / Tests (1.23) (pull_request) Successful in 6m3s
Tests and linters / gopls check (pull_request) Successful in 6m10s
Tests and linters / Lint (pull_request) Successful in 6m37s
Tests and linters / Tests with -race (pull_request) Successful in 6m31s
[#1343] go.mod: Update api-go
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
2024-08-29 15:47:12 +03:00

52 lines
1.5 KiB
Go

package control
import (
"context"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/engine"
"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"
)
func (s *Server) SealWriteCache(ctx context.Context, req *control.SealWriteCacheRequest) (*control.SealWriteCacheResponse, error) {
err := s.isValidRequest(req)
if err != nil {
return nil, status.Error(codes.PermissionDenied, err.Error())
}
prm := engine.SealWriteCachePrm{
ShardIDs: s.getShardIDList(req.GetBody().GetShard_ID()),
IgnoreErrors: req.GetBody().GetIgnoreErrors(),
Async: req.GetBody().GetAsync(),
RestoreMode: req.GetBody().GetRestoreMode(),
Shrink: req.GetBody().GetShrink(),
}
res, err := s.s.SealWriteCache(ctx, prm)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
resp := &control.SealWriteCacheResponse{Body: &control.SealWriteCacheResponse_Body{}}
for _, r := range res.ShardResults {
if r.Success {
resp.Body.Results = append(resp.GetBody().GetResults(), control.SealWriteCacheResponse_Body_Status{
Shard_ID: *r.ShardID,
Success: true,
})
} else {
resp.Body.Results = append(resp.GetBody().GetResults(), control.SealWriteCacheResponse_Body_Status{
Shard_ID: *r.ShardID,
Error: r.ErrorMsg,
})
}
}
err = ctrlmessage.Sign(s.key, resp)
if err != nil {
return nil, err
}
return resp, nil
}