From dec88196c76d90fc004a0ca59d28c32cffc94408 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Thu, 2 Dec 2010 19:20:37 +0000 Subject: [PATCH] Improve error reporting for small clusters When doing a two-node allocation on a cluster/group in which only one node is online, or a one-node allocation without any online nodes, we didn't show a valid error mesage. The patch changes tryAlloc to "fail hard" in this case, to make the failure explicit. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Balazs Lecz <leczb@google.com> --- Ganeti/HTools/Cluster.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Ganeti/HTools/Cluster.hs b/Ganeti/HTools/Cluster.hs index fb53c2d05..7d11ddb0a 100644 --- a/Ganeti/HTools/Cluster.hs +++ b/Ganeti/HTools/Cluster.hs @@ -607,14 +607,18 @@ tryAlloc nl _ inst 2 = concatAllocs cstate $ allocateOnPair nl inst p s ) emptySolution ok_pairs - in return $ annotateSolution sols + in if null ok_pairs -- means we have just one node + then fail "Not enough online nodes" + else return $ annotateSolution sols tryAlloc nl _ inst 1 = let all_nodes = getOnline nl sols = foldl' (\cstate -> concatAllocs cstate . allocateOnSingle nl inst ) emptySolution all_nodes - in return $ annotateSolution sols + in if null all_nodes + then fail "No online nodes" + else return $ annotateSolution sols tryAlloc _ _ _ reqn = fail $ "Unsupported number of allocation \ \destinations required (" ++ show reqn ++ -- GitLab