[#1506] ape_manager: Await tx persist before returning response
Some checks failed
DCO action / DCO (pull_request) Successful in 48s
Vulncheck / Vulncheck (pull_request) Successful in 1m30s
Tests and linters / Run gofumpt (pull_request) Successful in 1m36s
Build / Build Components (pull_request) Successful in 2m3s
Tests and linters / Lint (pull_request) Failing after 1m57s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m58s
Tests and linters / Staticcheck (pull_request) Successful in 2m18s
Tests and linters / Tests (pull_request) Successful in 2m33s
Tests and linters / gopls check (pull_request) Successful in 2m33s
Tests and linters / Tests with -race (pull_request) Successful in 2m45s
Some checks failed
DCO action / DCO (pull_request) Successful in 48s
Vulncheck / Vulncheck (pull_request) Successful in 1m30s
Tests and linters / Run gofumpt (pull_request) Successful in 1m36s
Build / Build Components (pull_request) Successful in 2m3s
Tests and linters / Lint (pull_request) Failing after 1m57s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m58s
Tests and linters / Staticcheck (pull_request) Successful in 2m18s
Tests and linters / Tests (pull_request) Successful in 2m33s
Tests and linters / gopls check (pull_request) Successful in 2m33s
Tests and linters / Tests with -race (pull_request) Successful in 2m45s
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
7fc1db7c89
commit
74a938dd4b
2 changed files with 21 additions and 5 deletions
|
@ -19,6 +19,7 @@ func initAPEManagerService(c *cfg) {
|
||||||
c.cfgObject.cfgAccessPolicyEngine.policyContractHash)
|
c.cfgObject.cfgAccessPolicyEngine.policyContractHash)
|
||||||
|
|
||||||
execsvc := apemanager.New(c.cfgObject.cnrSource, contractStorage,
|
execsvc := apemanager.New(c.cfgObject.cnrSource, contractStorage,
|
||||||
|
c.cfgMorph.client,
|
||||||
apemanager.WithLogger(c.log))
|
apemanager.WithLogger(c.log))
|
||||||
sigsvc := apemanager.NewSignService(&c.key.PrivateKey, execsvc)
|
sigsvc := apemanager.NewSignService(&c.key.PrivateKey, execsvc)
|
||||||
auditSvc := apemanager.NewAuditService(sigsvc, c.log, c.audit)
|
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"
|
ape_contract "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/ape/contract_storage"
|
||||||
containercore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/container"
|
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"
|
apemanager_errors "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/apemanager/errors"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
|
||||||
apeV2 "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/ape"
|
apeV2 "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/ape"
|
||||||
|
@ -34,6 +35,8 @@ type cfg struct {
|
||||||
type Service struct {
|
type Service struct {
|
||||||
cfg
|
cfg
|
||||||
|
|
||||||
|
waiter Waiter
|
||||||
|
|
||||||
cnrSrc containercore.Source
|
cnrSrc containercore.Source
|
||||||
|
|
||||||
contractStorage ape_contract.ProxyAdaptedContractStorage
|
contractStorage ape_contract.ProxyAdaptedContractStorage
|
||||||
|
@ -41,7 +44,11 @@ type Service struct {
|
||||||
|
|
||||||
type Option func(*cfg)
|
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{
|
s := &Service{
|
||||||
cnrSrc: cnrSrc,
|
cnrSrc: cnrSrc,
|
||||||
|
|
||||||
|
@ -84,7 +91,7 @@ func (s *Service) validateContainerTargetRequest(cid string, pubKey *keys.Public
|
||||||
return nil
|
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())
|
pub, err := getSignaturePublicKey(req.GetVerificationHeader())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -116,7 +123,11 @@ func (s *Service) AddChain(_ context.Context, req *apemanagerV2.AddChainRequest)
|
||||||
return nil, fmt.Errorf("unsupported target type: %s", targetType)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +140,7 @@ func (s *Service) AddChain(_ context.Context, req *apemanagerV2.AddChainRequest)
|
||||||
return resp, nil
|
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())
|
pub, err := getSignaturePublicKey(req.GetVerificationHeader())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -148,7 +159,11 @@ func (s *Service) RemoveChain(_ context.Context, req *apemanagerV2.RemoveChainRe
|
||||||
return nil, fmt.Errorf("unsupported target type: %s", targetType)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue