From 8a6f10ce6c47dc8c629f2d3ac8513d1dee8c3006 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Mon, 25 May 2009 20:54:15 +0100
Subject: [PATCH] hail: don't relocate to current primary node

This patch fixes the relocate-to-primary-node problem, and doesn't mark
the excluded nodes as offline anymore (we don't use them anyway, so
let's not use a different/fake cluster state).
---
 hail.hs | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/hail.hs b/hail.hs
index 217c79908..c9d6f5fb0 100644
--- a/hail.hs
+++ b/hail.hs
@@ -92,15 +92,13 @@ tryReloc :: (Monad m) =>
 tryReloc nl il xid 1 ex_idx =
     let all_nodes = getOnline nl
         inst = Container.find xid il
-        valid_nodes = filter (not . flip elem ex_idx . idx) all_nodes
+        ex_idx' = (Instance.pnode inst):ex_idx
+        valid_nodes = filter (not . flip elem ex_idx' . idx) all_nodes
         valid_idxes = map Node.idx valid_nodes
-        nl' = Container.map (\n -> if elem (Node.idx n) ex_idx then
-                                       Node.setOffline n True
-                                   else n) nl
         sols1 = map (\x -> let (mnl, _, _, _) =
-                                    Cluster.applyMove nl' inst
+                                    Cluster.applyMove nl inst
                                                (Cluster.ReplaceSecondary x)
-                            in (mnl, [Container.find x nl'])
+                            in (mnl, [Container.find x nl])
                      ) valid_idxes
     in return sols1
 
-- 
GitLab