Compare commits

...

2 commits

Author SHA1 Message Date
73b91c7d64 [#1063] cli: Validate container creation for EC policy
All checks were successful
DCO action / DCO (pull_request) Successful in 6m48s
Vulncheck / Vulncheck (pull_request) Successful in 8m15s
Tests and linters / gopls check (pull_request) Successful in 8m53s
Tests and linters / Staticcheck (pull_request) Successful in 11m13s
Build / Build Components (1.20) (pull_request) Successful in 12m4s
Build / Build Components (1.21) (pull_request) Successful in 11m58s
Tests and linters / Lint (pull_request) Successful in 12m58s
Tests and linters / Tests (1.20) (pull_request) Successful in 14m22s
Tests and linters / Tests (1.21) (pull_request) Successful in 15m0s
Tests and linters / Tests with -race (pull_request) Successful in 15m47s
Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
2024-03-29 16:59:59 +03:00
4a82b72b50 [#1063] go.mod: Update SDK version
* Update frostfs-sdk and frostfs-api-go versions.
* Refactor depreacted method ReplicaNumberByIndex.

Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
2024-03-29 16:59:52 +03:00
7 changed files with 35 additions and 13 deletions

View file

@ -58,13 +58,27 @@ 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)) {
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),
))
if repNum := placementPolicy.ReplicaDescriptor(i).NumberOfObjects(); repNum > 0 {
if repNum > 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),
repNum,
))
}
} else if ecParts := placementPolicy.ReplicaDescriptor(i).TotalECPartCount(); ecParts > 0 {
if ecParts > uint32(len(nodes)) {
commonCmd.ExitOnErr(cmd, "", fmt.Errorf(
"the number of nodes '%d' in selector is not enough for EC placement '%d.%d', "+
"use --force option to skip this check",
len(nodes),
placementPolicy.ReplicaDescriptor(i).GetECDataCount(),
placementPolicy.ReplicaDescriptor(i).GetECParityCount(),
))
}
} else {
commonCmd.ExitOnErr(cmd, "%w", errors.New("no replication policy is set"))
}
}
}

View file

@ -2,6 +2,7 @@ package container
import (
"crypto/sha256"
"errors"
internalclient "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
@ -46,7 +47,14 @@ 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))
if repNum := policy.ReplicaDescriptor(i).NumberOfObjects(); repNum > 0 {
cmd.Printf("Descriptor #%d, REP %d:\n", i+1, repNum)
} else if ecParts := policy.ReplicaDescriptor(i).TotalECPartCount(); ecParts > 0 {
cmd.Printf("Descriptor #%d, EC %d.%d:\n", i+1, policy.ReplicaDescriptor(i).GetECDataCount(),
policy.ReplicaDescriptor(i).GetECParityCount())
} else {
commonCmd.ExitOnErr(cmd, "%w", errors.New("no replication policy is set"))
}
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

4
go.mod
View file

@ -4,10 +4,10 @@ go 1.20
require (
code.gitea.io/sdk/gitea v0.17.1
git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.16.1-0.20240215124401-634e24aba715
git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.16.1-0.20240327095603-491a47e7fe24
git.frostfs.info/TrueCloudLab/frostfs-contract v0.19.0
git.frostfs.info/TrueCloudLab/frostfs-observability v0.0.0-20231101111734-b3ad3335ff65
git.frostfs.info/TrueCloudLab/frostfs-sdk-go v0.0.0-20240301150205-6fe4e2541d0b
git.frostfs.info/TrueCloudLab/frostfs-sdk-go v0.0.0-20240329104804-ec0cb2169f92
git.frostfs.info/TrueCloudLab/hrw v1.2.1
git.frostfs.info/TrueCloudLab/policy-engine v0.0.0-20240307151106-2ec958cbfdfd
git.frostfs.info/TrueCloudLab/tzhash v1.8.0

BIN
go.sum

Binary file not shown.

View file

@ -137,7 +137,7 @@ func defaultCopiesVector(policy netmap.PlacementPolicy) []int {
copyVector := make([]int, 0, replNum)
for i := 0; i < replNum; i++ {
copyVector = append(copyVector, int(policy.ReplicaNumberByIndex(i)))
copyVector = append(copyVector, int(policy.ReplicaDescriptor(i).NumberOfObjects()))
}
return copyVector

View file

@ -63,7 +63,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 {