[#1448] container/ape: Ignore an error when getting a role
All checks were successful
DCO action / DCO (pull_request) Successful in 1m37s
Vulncheck / Vulncheck (pull_request) Successful in 2m8s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m38s
Tests and linters / Run gofumpt (pull_request) Successful in 2m35s
Tests and linters / Staticcheck (pull_request) Successful in 2m56s
Build / Build Components (pull_request) Successful in 3m4s
Tests and linters / gopls check (pull_request) Successful in 3m12s
Tests and linters / Lint (pull_request) Successful in 3m48s
Tests and linters / Tests (pull_request) Successful in 4m38s
Tests and linters / Tests with -race (pull_request) Successful in 6m20s

When getting a role in the APE checker for the container services,
an error may be returned if network maps of the previous two epochs
don't have enough nodes to fulfil a container placement policy.
It's a logical error, so we should ignore it.

Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
This commit is contained in:
Aleksey Savchuk 2024-10-29 15:47:19 +03:00
parent 87ac3c5279
commit d28a5d2d7a
Signed by: a-savchuk
GPG key ID: 70C0A7FF6F9C4639

View file

@ -537,10 +537,7 @@ func (ac *apeChecker) isContainerKey(pk []byte, cnrID cid.ID, cont *containercor
return false, err return false, err
} }
in, err := isContainerNode(nm, pk, binCnrID, cont) if isContainerNode(nm, pk, binCnrID, cont) {
if err != nil {
return false, err
} else if in {
return true, nil return true, nil
} }
@ -551,24 +548,24 @@ func (ac *apeChecker) isContainerKey(pk []byte, cnrID cid.ID, cont *containercor
return false, err return false, err
} }
return isContainerNode(nm, pk, binCnrID, cont) return isContainerNode(nm, pk, binCnrID, cont), nil
} }
func isContainerNode(nm *netmapSDK.NetMap, pk, binCnrID []byte, cont *containercore.Container) (bool, error) { func isContainerNode(nm *netmapSDK.NetMap, pk, binCnrID []byte, cont *containercore.Container) bool {
cnrVectors, err := nm.ContainerNodes(cont.Value.PlacementPolicy(), binCnrID) // It could an error only if the network map doesn't have enough nodes to
if err != nil { // fulfil the policy. It's a logical error that doesn't affect an actor role
return false, err // determining, so we ignore it
} cnrVectors, _ := nm.ContainerNodes(cont.Value.PlacementPolicy(), binCnrID)
for i := range cnrVectors { for i := range cnrVectors {
for j := range cnrVectors[i] { for j := range cnrVectors[i] {
if bytes.Equal(cnrVectors[i][j].PublicKey(), pk) { if bytes.Equal(cnrVectors[i][j].PublicKey(), pk) {
return true, nil return true
} }
} }
} }
return false, nil return false
} }
func (ac *apeChecker) namespaceByOwner(owner *refs.OwnerID) (string, error) { func (ac *apeChecker) namespaceByOwner(owner *refs.OwnerID) (string, error) {