Commit 70db354e authored by Iustin Pop's avatar Iustin Pop
Browse files

Fix the ReplacePrimary instance move

During a replace-primary instance move, on the real cluster the instance
is temporarily started on the secondary, and as such we must check that
the secondary node can hold it for this duration. Currently the code
does not, and depending on cluster scoring it will put instances on such
'bad' secondaries (usually without enough memory).

This patch fixes this by adding/removing the instance as a primary on
the secondary node; and then using the result node as the new secondary.
(Since we're in a monad, we could have just tried the allocation and
dropped the result, but this is more clear).
parent bfb03e22
......@@ -467,8 +467,12 @@ applyMove nl inst (ReplacePrimary new_pdx) =
int_p = Node.removePri old_p inst
int_s = Node.removeSec old_s inst
new_nl = do -- Maybe monad
-- check that the current secondary can host the instance
-- during the migration
tmp_s <- Node.addPri int_s inst
let tmp_s' = Node.removePri tmp_s inst
new_p <- Node.addPri tgt_n inst
new_s <- Node.addSec int_s inst new_pdx
new_s <- Node.addSec tmp_s' inst new_pdx
return $ Container.add new_pdx new_p $
Container.addTwo old_pdx int_p old_sdx new_s nl
in (new_nl, Instance.setPri inst new_pdx, new_pdx, old_sdx)
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