Commit faaabe3c authored by Iustin Pop's avatar Iustin Pop

Instance failover: fix bug for INT_MIRROR cases

Patches db366d9a and aac4511a added support for EXT_MIRROR instances,
but inadvertently introduced a bug: for INT_MIRROR cases, we don't
need (actually we can't support) neither an iallocator nor a target
node.

To fix this, we move the iallocator/node checks in CheckPrereq (or
respectively in the tasklet CheckPrereq), where we have access to the
instance configuration, and additionally we check for and prevent
passing either of these two for INT_MIRROR instances.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent cfed3b9f
......@@ -5716,7 +5716,6 @@ class LUInstanceFailover(LogicalUnit):
"""
self.iallocator = getattr(self.op, "iallocator", None)
self.target_node = getattr(self.op, "target_node", None)
_CheckIAllocatorOrNode(self, "iallocator", "target_node")
def ExpandNames(self):
self._ExpandAndLockInstance()
......@@ -5784,6 +5783,7 @@ class LUInstanceFailover(LogicalUnit):
errors.ECODE_STATE)
if instance.disk_template in constants.DTS_EXT_MIRROR:
_CheckIAllocatorOrNode(self, "iallocator", "target_node")
if self.op.iallocator:
self._RunAllocator()
# Release all unnecessary node locks
......@@ -5805,6 +5805,13 @@ class LUInstanceFailover(LogicalUnit):
instance.disk_template)
target_node = secondary_nodes[0]
if self.op.iallocator or (self.op.target_node and
self.op.target_node != target_node):
raise errors.OpPrereqError("Instances with disk template %s cannot"
" be failed over to arbitrary nodes"
" (neither an iallocator nor a target"
" node can be passed)" %
instance.disk_template, errors.ECODE_INVAL)
_CheckNodeOnline(self, target_node)
_CheckNodeNotDrained(self, target_node)
......@@ -5934,9 +5941,6 @@ class LUInstanceMigrate(LogicalUnit):
HTYPE = constants.HTYPE_INSTANCE
REQ_BGL = False
def CheckArguments(self):
_CheckIAllocatorOrNode(self, "iallocator", "target_node")
def ExpandNames(self):
self._ExpandAndLockInstance()
......@@ -6272,9 +6276,7 @@ class TLMigrateInstance(Tasklet):
errors.ECODE_STATE)
if instance.disk_template in constants.DTS_EXT_MIRROR:
if [self.iallocator, self.target_node].count(None) != 1:
raise errors.OpPrereqError("Do not specify both, iallocator and"
" target node", errors.ECODE_INVAL)
_CheckIAllocatorOrNode(self.lu, "iallocator", "target_node")
if self.iallocator:
self._RunAllocator()
......@@ -6298,6 +6300,13 @@ class TLMigrateInstance(Tasklet):
" %s disk template" %
instance.disk_template)
target_node = secondary_nodes[0]
if self.lu.op.iallocator or (self.lu.op.target_node and
self.lu.op.target_node != target_node):
raise errors.OpPrereqError("Instances with disk template %s cannot"
" be migrated over to arbitrary nodes"
" (neither an iallocator nor a target"
" node can be passed)" %
instance.disk_template, errors.ECODE_INVAL)
i_be = self.cfg.GetClusterInfo().FillBE(instance)
......
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