forked from TrueCloudLab/frostfs-node
[#619] node: Fix object put when copies numbers contains only zeros
In this case object should placement according to replicas. Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
5335e7089e
commit
6407bb5bd1
2 changed files with 22 additions and 6 deletions
|
@ -97,16 +97,22 @@ func NewTraverser(opts ...Option) (*Traverser, error) {
|
||||||
} else {
|
} else {
|
||||||
rem = defaultCopiesVector(cfg.policy)
|
rem = defaultCopiesVector(cfg.policy)
|
||||||
|
|
||||||
// compatibleZeroVector is a bool flag which is set when cfg.copyNumbers
|
// Bool flag which is set when cfg.copyNumbers contains not only zeros.
|
||||||
// is [0]. In this case we should not modify `rem` slice unless track
|
// In this case we should not modify `rem` slice unless track
|
||||||
// copies are ignored, because [0] means that all copies should be
|
// copies are ignored, because [0, ...] means that all copies should be
|
||||||
// stored before returning OK to the client.
|
// stored before returning OK to the client.
|
||||||
compatibleZeroVector := len(cfg.copyNumbers) == 1 && cfg.copyNumbers[0] == 0
|
var considerCopiesNumber bool
|
||||||
|
for _, val := range cfg.copyNumbers {
|
||||||
|
if val != 0 {
|
||||||
|
considerCopiesNumber = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for i := range rem {
|
for i := range rem {
|
||||||
if !cfg.trackCopies {
|
if !cfg.trackCopies {
|
||||||
rem[i] = -1
|
rem[i] = -1
|
||||||
} else if len(cfg.copyNumbers) > i && !compatibleZeroVector {
|
} else if considerCopiesNumber && len(cfg.copyNumbers) > i {
|
||||||
rem[i] = int(cfg.copyNumbers[i])
|
rem[i] = int(cfg.copyNumbers[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,10 +227,20 @@ func TestTraverserRemValues(t *testing.T) {
|
||||||
expectedRem: replicas,
|
expectedRem: replicas,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "compatible zero copy numbers",
|
name: "compatible zero copy numbers, len 1",
|
||||||
copyNumbers: []uint32{0},
|
copyNumbers: []uint32{0},
|
||||||
expectedRem: replicas,
|
expectedRem: replicas,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "compatible zero copy numbers, len 2",
|
||||||
|
copyNumbers: []uint32{0, 0},
|
||||||
|
expectedRem: replicas,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "compatible zero copy numbers, len 3",
|
||||||
|
copyNumbers: []uint32{0, 0, 0},
|
||||||
|
expectedRem: replicas,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "copy numbers for all replicas",
|
name: "copy numbers for all replicas",
|
||||||
copyNumbers: []uint32{1, 1, 1},
|
copyNumbers: []uint32{1, 1, 1},
|
||||||
|
|
Loading…
Reference in a new issue