Commit bfa9a5d1 authored by Klaus Aehlig's avatar Klaus Aehlig
Browse files

Make shrinkByType aware of individual disks



When shrinking an instances, you can't just get smaller disk footprint
while leaving the individual disks as they are. Make the shrink
heuristic aware of that fact, and decrease all individual disks as
well. Fixes issue 484.
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarThomas Thrainer <thomasth@google.com>
parent 60af7882
......@@ -246,10 +246,12 @@ shrinkByType inst T.FailMem = let v = mem inst - T.unitMem
in if v < T.unitMem
then Bad "out of memory"
else Ok inst { mem = v }
shrinkByType inst T.FailDisk = let v = dsk inst - T.unitDsk
in if v < T.unitDsk
then Bad "out of disk"
else Ok inst { dsk = v }
shrinkByType inst T.FailDisk =
let newdisks = map (flip (-) T.unitDsk) $ disks inst
v = dsk inst - (length . disks $ inst) * T.unitDsk
in if any (< T.unitDsk) newdisks
then Bad "out of disk"
else Ok inst { dsk = v, disks = newdisks }
shrinkByType inst T.FailCPU = let v = vcpus inst - T.unitCpu
in if v < T.unitCpu
then Bad "out of vcpus"
......
......@@ -178,7 +178,7 @@ prop_shrinkDG inst =
prop_shrinkDF :: Instance.Instance -> Property
prop_shrinkDF inst =
forAll (choose (0, 2 * Types.unitDsk - 1)) $ \dsk ->
let inst' = inst { Instance.dsk = dsk }
let inst' = inst { Instance.dsk = dsk, Instance.disks = [dsk] }
in isBad $ Instance.shrinkByType inst' Types.FailDisk
prop_setMovable :: Instance.Instance -> Bool -> Property
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment