Revision a334d536 Ganeti/HTools/Cluster.hs

b/Ganeti/HTools/Cluster.hs
81 81
-- * Types
82 82

  
83 83
-- | Allocation\/relocation solution.
84
type AllocSolution = ([FailMode], Int, [(Score, Node.AllocElement)])
84
type AllocSolution = ([FailMode], Int, [Node.AllocElement])
85 85

  
86 86
-- | The complete state for the balancing solution
87 87
data Table = Table Node.List Instance.List Score [Placement]
......
538 538
concatAllocs (flst, cntok, osols) (OpGood ns@(_, _, _, nscore)) =
539 539
    let -- Choose the old or new solution, based on the cluster score
540 540
        nsols = case osols of
541
                  [] -> [(nscore, ns)]
542
                  (oscore, _):[] ->
541
                  [] -> [ns]
542
                  (_, _, _, oscore):[] ->
543 543
                      if oscore < nscore
544 544
                      then osols
545
                      else [(nscore, ns)]
545
                      else [ns]
546 546
                  -- FIXME: here we simply concat to lists with more
547 547
                  -- than one element; we should instead abort, since
548 548
                  -- this is not a valid usage of this function
549
                  xs -> (nscore, ns):xs
549
                  xs -> ns:xs
550 550
        nsuc = cntok + 1
551 551
    -- Note: we force evaluation of nsols here in order to keep the
552 552
    -- memory profile low - we know that we will need nsols for sure
......
624 624
                           -- FIXME: hardcoded one node here
625 625
                           (fm, cs, aes) <- tryReloc nl' il idx 1 ex_ndx
626 626
                           case aes of
627
                             csol@(_, (nl'', _, _, _)):_ ->
627
                             csol@(nl'', _, _, _):_ ->
628 628
                                 return (nl'', (fm, cs, csol:rsols))
629 629
                             _ -> fail $ "Can't evacuate instance " ++
630 630
                                  Instance.name (Container.find idx il)
......
649 649
           Ok (errs, _, sols3) ->
650 650
               case sols3 of
651 651
                 [] -> Ok (collapseFailures errs, nl, il, ixes)
652
                 (_, (xnl, xi, _, _)):[] ->
652
                 (xnl, xi, _, _):[] ->
653 653
                     iterateAlloc xnl (Container.add newidx xi il)
654 654
                                  newinst nreq $! (xi:ixes)
655 655
                 _ -> Bad "Internal error: multiple solutions for single\

Also available in: Unified diff