[#1064] node: Replace deprecated methods
DCO action / DCO (pull_request) Successful in 3m56s Details
Vulncheck / Vulncheck (pull_request) Successful in 4m20s Details
Tests and linters / Lint (pull_request) Successful in 5m2s Details
Build / Build Components (1.21) (pull_request) Successful in 8m34s Details
Build / Build Components (1.20) (pull_request) Successful in 9m3s Details
Tests and linters / gopls check (pull_request) Successful in 11m6s Details
Tests and linters / Staticcheck (pull_request) Successful in 11m12s Details
Tests and linters / Tests (1.20) (pull_request) Successful in 13m4s Details
Tests and linters / Tests (1.21) (pull_request) Successful in 13m29s Details
Tests and linters / Tests with -race (pull_request) Successful in 14m10s Details

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
Dmitrii Stepanov 2024-04-01 17:02:39 +03:00
parent 26a3609ac7
commit 7d1ce328cf
5 changed files with 16 additions and 5 deletions

View File

@ -13,6 +13,7 @@ import (
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/policy"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/acl"
@ -58,12 +59,12 @@ It will be stored in sidechain when inner ring will accepts it.`,
"use --force option to skip this check: %w", err)
for i, nodes := range nodesByRep {
if placementPolicy.ReplicaNumberByIndex(i) > uint32(len(nodes)) {
if policy.TotalObjectNodesNumber(placementPolicy, i) > uint32(len(nodes)) {
commonCmd.ExitOnErr(cmd, "", fmt.Errorf(
"the number of nodes '%d' in selector is not enough for the number of replicas '%d', "+
"use --force option to skip this check",
len(nodes),
placementPolicy.ReplicaNumberByIndex(i),
policy.TotalObjectNodesNumber(placementPolicy, i),
))
}
}

View File

@ -46,7 +46,7 @@ var containerNodesCmd = &cobra.Command{
commonCmd.ExitOnErr(cmd, "could not build container nodes for given container: %w", err)
for i := range cnrNodes {
cmd.Printf("Descriptor #%d, REP %d:\n", i+1, policy.ReplicaNumberByIndex(i))
cmd.Printf("Descriptor #%d, REP %d:\n", i+1, policy.ReplicaDescriptor(i).NumberOfObjects())
for j := range cnrNodes[i] {
commonCmd.PrettyPrintNodeInfo(cmd, cnrNodes[i][j], j, "\t", short)
}

View File

@ -190,7 +190,7 @@ func getRequiredPlacement(cmd *cobra.Command, objInfo *objectNodesInfo, placemen
placement, err := placementBuilder.BuildPlacement(objInfo.containerID, &objInfo.objectID, placementPolicy)
commonCmd.ExitOnErr(cmd, "failed to get required placement: %w", err)
for repIdx, rep := range placement {
numOfReplicas := placementPolicy.ReplicaNumberByIndex(repIdx)
numOfReplicas := placementPolicy.ReplicaDescriptor(repIdx).NumberOfObjects()
var nodeIdx uint32
for _, n := range rep {
if !objInfo.isLockOrTombstone && nodeIdx == numOfReplicas { // lock and tombstone objects should be on all container nodes

View File

@ -0,0 +1,10 @@
package policy
import netmapSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap"
// TotalObjectNodesNumber returns total number of nodes required by placement policy.
func TotalObjectNodesNumber(policy *netmapSDK.PlacementPolicy, i int) uint32 {
return policy.ReplicaDescriptor(i).NumberOfObjects() +
policy.ReplicaDescriptor(i).GetECDataCount() +
policy.ReplicaDescriptor(i).GetECParityCount()
}

View File

@ -68,7 +68,7 @@ func (p *Policer) processObject(ctx context.Context, addrWithType objectcore.Add
default:
}
p.processNodes(ctx, c, addrWithType, nn[i], policy.ReplicaNumberByIndex(i), checkedNodes)
p.processNodes(ctx, c, addrWithType, nn[i], policy.ReplicaDescriptor(i).NumberOfObjects(), checkedNodes)
}
if !c.needLocalCopy && c.removeLocalCopy {