From e70c2cedbea1e1985369b34a35bf642dfc022e12 Mon Sep 17 00:00:00 2001 From: Aleksey Savchuk Date: Tue, 29 Oct 2024 15:47:19 +0300 Subject: [PATCH] [#1448] container/ape: Ignore an error when getting a role 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 --- pkg/services/container/ape.go | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/pkg/services/container/ape.go b/pkg/services/container/ape.go index d92ecf58b..a8233c469 100644 --- a/pkg/services/container/ape.go +++ b/pkg/services/container/ape.go @@ -536,11 +536,7 @@ func (ac *apeChecker) isContainerKey(pk []byte, cnrID cid.ID, cont *containercor if err != nil { return false, err } - - in, err := isContainerNode(nm, pk, binCnrID, cont) - if err != nil { - return false, err - } else if in { + if isContainerNode(nm, pk, binCnrID, cont) { return true, nil } @@ -550,25 +546,25 @@ func (ac *apeChecker) isContainerKey(pk []byte, cnrID cid.ID, cont *containercor if err != nil { 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) { - cnrVectors, err := nm.ContainerNodes(cont.Value.PlacementPolicy(), binCnrID) - if err != nil { - return false, err - } +func isContainerNode(nm *netmapSDK.NetMap, pk, binCnrID []byte, cont *containercore.Container) bool { + // 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. + // See https://git.frostfs.info/TrueCloudLab/frostfs-node/issues/1448. + cnrVectors, _ := nm.ContainerNodes(cont.Value.PlacementPolicy(), binCnrID) for i := range cnrVectors { for j := range cnrVectors[i] { 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) {