correct assign logic for rack level. Still need to fix data center
level.
This commit is contained in:
@@ -110,12 +110,22 @@ func (vg *VolumeGrowth) findEmptySlotsForOneVolume(topo *Topology, option *Volum
|
|||||||
if option.Rack != "" && node.IsRack() && node.Id() != NodeId(option.Rack) {
|
if option.Rack != "" && node.IsRack() && node.Id() != NodeId(option.Rack) {
|
||||||
return fmt.Errorf("Not matching preferred rack:%s", option.Rack)
|
return fmt.Errorf("Not matching preferred rack:%s", option.Rack)
|
||||||
}
|
}
|
||||||
if len(node.Children()) < rp.SameRackCount+1 {
|
|
||||||
return fmt.Errorf("Only has %d data nodes, not enough for %d.", len(node.Children()), rp.SameRackCount+1)
|
|
||||||
}
|
|
||||||
if node.FreeSpace() < rp.SameRackCount+1 {
|
if node.FreeSpace() < rp.SameRackCount+1 {
|
||||||
return fmt.Errorf("Free:%d < Expected:%d", node.FreeSpace(), rp.SameRackCount+1)
|
return fmt.Errorf("Free:%d < Expected:%d", node.FreeSpace(), rp.SameRackCount+1)
|
||||||
}
|
}
|
||||||
|
if len(node.Children()) < rp.SameRackCount+1 {
|
||||||
|
// a bit faster way test failed cases
|
||||||
|
return fmt.Errorf("Only has %d data nodes, not enough for %d.", len(node.Children()), rp.SameRackCount+1)
|
||||||
|
}
|
||||||
|
possibleDataNodeCount := 0
|
||||||
|
for _, n := range node.Children() {
|
||||||
|
if n.FreeSpace() >= 1 {
|
||||||
|
possibleDataNodeCount++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if possibleDataNodeCount < rp.SameRackCount+1 {
|
||||||
|
return fmt.Errorf("Only has %d data nodes with a slot, not enough for %d.", possibleDataNodeCount, rp.SameRackCount+1)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if rack_err != nil {
|
if rack_err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user