[#1506] ape_manager: Await tx persist before returning response
All checks were successful
DCO action / DCO (pull_request) Successful in 39s
Vulncheck / Vulncheck (pull_request) Successful in 1m20s
Tests and linters / Run gofumpt (pull_request) Successful in 1m32s
Build / Build Components (pull_request) Successful in 1m53s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m49s
Tests and linters / Staticcheck (pull_request) Successful in 2m16s
Tests and linters / gopls check (pull_request) Successful in 2m23s
Tests and linters / Tests (pull_request) Successful in 2m43s
Tests and linters / Tests with -race (pull_request) Successful in 2m50s
Tests and linters / Lint (pull_request) Successful in 3m4s
All checks were successful
DCO action / DCO (pull_request) Successful in 39s
Vulncheck / Vulncheck (pull_request) Successful in 1m20s
Tests and linters / Run gofumpt (pull_request) Successful in 1m32s
Build / Build Components (pull_request) Successful in 1m53s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m49s
Tests and linters / Staticcheck (pull_request) Successful in 2m16s
Tests and linters / gopls check (pull_request) Successful in 2m23s
Tests and linters / Tests (pull_request) Successful in 2m43s
Tests and linters / Tests with -race (pull_request) Successful in 2m50s
Tests and linters / Lint (pull_request) Successful in 3m4s
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
7fc1db7c89
commit
dcd8c20952
2 changed files with 23 additions and 5 deletions
|
@ -19,6 +19,7 @@ func initAPEManagerService(c *cfg) {
|
|||
c.cfgObject.cfgAccessPolicyEngine.policyContractHash)
|
||||
|
||||
execsvc := apemanager.New(c.cfgObject.cnrSource, contractStorage,
|
||||
c.cfgMorph.client,
|
||||
apemanager.WithLogger(c.log))
|
||||
sigsvc := apemanager.NewSignService(&c.key.PrivateKey, execsvc)
|
||||
auditSvc := apemanager.NewAuditService(sigsvc, c.log, c.audit)
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
|
||||
ape_contract "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/ape/contract_storage"
|
||||
containercore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/container"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
||||
apemanager_errors "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/apemanager/errors"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
|
||||
apeV2 "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/ape"
|
||||
|
@ -34,6 +35,8 @@ type cfg struct {
|
|||
type Service struct {
|
||||
cfg
|
||||
|
||||
waiter Waiter
|
||||
|
||||
cnrSrc containercore.Source
|
||||
|
||||
contractStorage ape_contract.ProxyAdaptedContractStorage
|
||||
|
@ -41,11 +44,17 @@ type Service struct {
|
|||
|
||||
type Option func(*cfg)
|
||||
|
||||
func New(cnrSrc containercore.Source, contractStorage ape_contract.ProxyAdaptedContractStorage, opts ...Option) *Service {
|
||||
type Waiter interface {
|
||||
WaitTxHalt(context.Context, client.InvokeRes) error
|
||||
}
|
||||
|
||||
func New(cnrSrc containercore.Source, contractStorage ape_contract.ProxyAdaptedContractStorage, waiter Waiter, opts ...Option) *Service {
|
||||
s := &Service{
|
||||
cnrSrc: cnrSrc,
|
||||
|
||||
contractStorage: contractStorage,
|
||||
|
||||
waiter: waiter,
|
||||
}
|
||||
|
||||
for i := range opts {
|
||||
|
@ -84,7 +93,7 @@ func (s *Service) validateContainerTargetRequest(cid string, pubKey *keys.Public
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *Service) AddChain(_ context.Context, req *apemanagerV2.AddChainRequest) (*apemanagerV2.AddChainResponse, error) {
|
||||
func (s *Service) AddChain(ctx context.Context, req *apemanagerV2.AddChainRequest) (*apemanagerV2.AddChainResponse, error) {
|
||||
pub, err := getSignaturePublicKey(req.GetVerificationHeader())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -116,7 +125,11 @@ func (s *Service) AddChain(_ context.Context, req *apemanagerV2.AddChainRequest)
|
|||
return nil, fmt.Errorf("unsupported target type: %s", targetType)
|
||||
}
|
||||
|
||||
if _, _, err = s.contractStorage.AddMorphRuleChain(apechain.Ingress, target, &chain); err != nil {
|
||||
txHash, vub, err := s.contractStorage.AddMorphRuleChain(apechain.Ingress, target, &chain)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := s.waiter.WaitTxHalt(ctx, client.InvokeRes{Hash: txHash, VUB: vub}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
@ -129,7 +142,7 @@ func (s *Service) AddChain(_ context.Context, req *apemanagerV2.AddChainRequest)
|
|||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *Service) RemoveChain(_ context.Context, req *apemanagerV2.RemoveChainRequest) (*apemanagerV2.RemoveChainResponse, error) {
|
||||
func (s *Service) RemoveChain(ctx context.Context, req *apemanagerV2.RemoveChainRequest) (*apemanagerV2.RemoveChainResponse, error) {
|
||||
pub, err := getSignaturePublicKey(req.GetVerificationHeader())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -148,7 +161,11 @@ func (s *Service) RemoveChain(_ context.Context, req *apemanagerV2.RemoveChainRe
|
|||
return nil, fmt.Errorf("unsupported target type: %s", targetType)
|
||||
}
|
||||
|
||||
if _, _, err = s.contractStorage.RemoveMorphRuleChain(apechain.Ingress, target, req.GetBody().GetChainID()); err != nil {
|
||||
txHash, vub, err := s.contractStorage.RemoveMorphRuleChain(apechain.Ingress, target, req.GetBody().GetChainID())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := s.waiter.WaitTxHalt(ctx, client.InvokeRes{Hash: txHash, VUB: vub}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue