From 1d42996b896965118e84322b48b32505a80400c2 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Wed, 7 Mar 2012 01:40:18 +0200
Subject: [PATCH] Fix TLMigrateInstance use of IAllocator
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

hail now expects correctly that relocate_from is of equal length with
the number of required nodes (fixme: there's a lot of not well
documented behaviour here… not nice for any other potential
IAllocators). As such, we _need_ to pass just the instance's primary
node.

Additionally, update the iallocator doc to correctly specify what this
list (`relocate_from`) contains.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
---
 doc/iallocator.rst | 8 +++++---
 lib/cmdlib.py      | 4 +---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/doc/iallocator.rst b/doc/iallocator.rst
index 723b948d7..92def0602 100644
--- a/doc/iallocator.rst
+++ b/doc/iallocator.rst
@@ -285,9 +285,11 @@ Allocation needs, in addition:
 Relocation:
 
   relocate_from
-     a list of nodes to move the instance away from (note that with
-     Ganeti 2.0, this list will always contain a single node, the
-     current secondary of the instance); type *list of strings*
+     a list of nodes to move the instance away from; for DRBD-based
+     instances, this will contain a single node, the current secondary
+     of the instance, whereas for shared-storage instance, this will
+     contain also a single node, the current primary of the instance;
+     type *list of strings*
 
 As for ``node-evacuate``, it needs the following request arguments:
 
diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 45a77dd49..d598a6365 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -8013,9 +8013,7 @@ class TLMigrateInstance(Tasklet):
     ial = IAllocator(self.cfg, self.rpc,
                      mode=constants.IALLOCATOR_MODE_RELOC,
                      name=self.instance_name,
-                     # TODO See why hail breaks with a single node below
-                     relocate_from=[self.instance.primary_node,
-                                    self.instance.primary_node],
+                     relocate_from=[self.instance.primary_node],
                      )
 
     ial.Run(self.lu.op.iallocator)
-- 
GitLab