Skip to content

Commit 1b9a18d

Browse files
committed
mmaprototype: add assertion on emptyVoterConstraintIndex
This commit adds assertions on emptyVoterConstraintIndex and emptyConstraintIndex since there should only be one.
1 parent 8f079ba commit 1b9a18d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/kv/kvserver/allocator/mmaprototype/constraint.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,10 +479,16 @@ func doStructuralNormalization(conf *normalizedSpanConfig) error {
479479
var rels []relationshipVoterAndAll
480480
for i := range conf.voterConstraints {
481481
if len(conf.voterConstraints[i].constraints) == 0 {
482+
if emptyVoterConstraintIndex != -1 {
483+
return errors.Errorf("invalid configurations with empty voter constraint")
484+
}
482485
emptyVoterConstraintIndex = i
483486
}
484487
for j := range conf.constraints {
485488
if len(conf.constraints[j].constraints) == 0 {
489+
if emptyConstraintIndex != -1 && emptyConstraintIndex != j {
490+
return errors.Errorf("invalid configurations with empty constraint")
491+
}
486492
emptyConstraintIndex = j
487493
}
488494
rels = append(rels, relationshipVoterAndAll{

0 commit comments

Comments
 (0)