htools: rework the algorithm for ChangeAll mode
authorIustin Pop <iustin@google.com>
Mon, 18 Jul 2011 11:17:41 +0000 (13:17 +0200)
committerIustin Pop <iustin@google.com>
Fri, 22 Jul 2011 11:33:28 +0000 (13:33 +0200)
commit97da6b71cc8831bed33f42f6e603864fb85287c3
treec84db67799e0e7c86edf4d5a5a3facdcc2236cea
parentf965260c2a14202cd7558e90f3939ecc8ff1dec3
htools: rework the algorithm for ChangeAll mode

I think I've identified the problem with the current ChangeAll
mode. The current algorithm works as follows:

- identify a new primary by choosing the node which gives best score
  as new secondary
- failover to it
- identify a new secondary by choosing the node which gives best score
  as new secondary

This means that the future primary is 'fixed' after the first
iteration, leaving to possibly suboptimal results. This patch changes
the algorithm to do what, in hindsight, seems the obvious thing to do:
- generate all pairs (primary, secondary)
- identify the pair that after the above sequence (r:np, f, r:ns)
  gives the best group score

This fixes some of the corner cases I've seen in relocation, but not
all; the remaining cases are related to multi-instance relocation and
while they can't be fixed in the current framework, the needed
rebalancing is much smaller than with the current algorithm.

The patch also fixes an issue with the docstring of another function.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
htools/Ganeti/HTools/Cluster.hs