mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
fix volume placement validating
fix https://github.com/chrislusf/seaweedfs/issues/1626
This commit is contained in:
parent
da04bb3d1b
commit
7385103057
|
@ -306,16 +306,16 @@ func isGoodMove(placement *super_block.ReplicaPlacement, existingReplicas []*Vol
|
||||||
dcs[targetNode.dc] = true
|
dcs[targetNode.dc] = true
|
||||||
racks[fmt.Sprintf("%s %s", targetNode.dc, targetNode.rack)]++
|
racks[fmt.Sprintf("%s %s", targetNode.dc, targetNode.rack)]++
|
||||||
|
|
||||||
if len(dcs) > placement.DiffDataCenterCount+1 {
|
if len(dcs) != placement.DiffDataCenterCount+1 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(racks) > placement.DiffRackCount+placement.DiffDataCenterCount+1 {
|
if len(racks) != placement.DiffRackCount+placement.DiffDataCenterCount+1 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, sameRackCount := range racks {
|
for _, sameRackCount := range racks {
|
||||||
if sameRackCount > placement.SameRackCount+1 {
|
if sameRackCount != placement.SameRackCount+1 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,22 @@ func TestIsGoodMove(t *testing.T) {
|
||||||
|
|
||||||
var tests = []testMoveCase{
|
var tests = []testMoveCase{
|
||||||
|
|
||||||
|
{
|
||||||
|
name: "test 100 move to wrong data centers",
|
||||||
|
replication: "100",
|
||||||
|
replicas: []*VolumeReplica{
|
||||||
|
{
|
||||||
|
location: &location{"dc1", "r1", &master_pb.DataNodeInfo{Id: "dn1"}},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
location: &location{"dc2", "r2", &master_pb.DataNodeInfo{Id: "dn2"}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
sourceLocation: location{"dc1", "r1", &master_pb.DataNodeInfo{Id: "dn1"}},
|
||||||
|
targetLocation: location{"dc2", "r3", &master_pb.DataNodeInfo{Id: "dn3"}},
|
||||||
|
expected: false,
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
name: "test 100 move to spread into proper data centers",
|
name: "test 100 move to spread into proper data centers",
|
||||||
replication: "100",
|
replication: "100",
|
||||||
|
|
Loading…
Reference in a new issue