cli: Validate container creation for EC policy #1063
7 changed files with 35 additions and 13 deletions
|
@ -58,14 +58,28 @@ 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 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),
|
||||
placementPolicy.ReplicaNumberByIndex(i),
|
||||
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"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
4
go.mod
|
@ -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
BIN
go.sum
Binary file not shown.
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue