Commit 7b5f0674 authored by Dimitris Aragiorgis's avatar Dimitris Aragiorgis Committed by Michele Tartara

Include target node in hooks nodes for migration

In case of DRBD, hooks run on both primary (source) and secondary
(target) nodes. To get the same behavior for DTS_EXT_MIRROR, where we
do not have secondary node, we should explicitly add target node to
hooks nodes during instance migration/failover.

CheckPrereq() of TLMigrateInstance runs before BuildHooksManager(),
thus target_node calculated by Iallocator is available under
self._migrater.target_node. Use this value instead of
self.op.target_node which can be None.

Update NEWS and related doc entries.
Signed-off-by: default avatarDimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: default avatarMichele Tartara <mtartara@google.com>
Reviewed-by: default avatarMichele Tartara <mtartara@google.com>
parent ae6a0a7c
......@@ -21,6 +21,8 @@ Incompatible/important changes
checks whether there are instances still using those templates.
- 'gnt-node list-storage' now also reports storage information about
file-based storage types.
- In case of non drbd instances, export \*_SECONDARY environment variables
as empty strings (and not "None") during 'instance-migrate' related hooks.
New features
~~~~~~~~~~~~
......
......@@ -379,8 +379,8 @@ and secondary before failover.
:directory: instance-failover
:env. vars: IGNORE_CONSISTENCY, SHUTDOWN_TIMEOUT, OLD_PRIMARY, OLD_SECONDARY, NEW_PRIMARY, NEW_SECONDARY
:pre-execution: master node, secondary node
:post-execution: master node, primary and secondary nodes
:pre-execution: master node, secondary (target) node
:post-execution: master node, primary (source) and secondary (target) nodes
OP_INSTANCE_MIGRATE
++++++++++++++++++++
......@@ -391,8 +391,8 @@ and secondary before migration.
:directory: instance-migrate
:env. vars: MIGRATE_LIVE, MIGRATE_CLEANUP, OLD_PRIMARY, OLD_SECONDARY, NEW_PRIMARY, NEW_SECONDARY
:pre-execution: master node, primary and secondary nodes
:post-execution: master node, primary and secondary nodes
:pre-execution: master node, primary (source) and secondary (target) nodes
:post-execution: master node, primary (source) and secondary (target) nodes
OP_INSTANCE_REMOVE
......
......@@ -136,11 +136,12 @@ class LUInstanceFailover(LogicalUnit):
"""
instance = self._migrater.instance
source_node_uuid = instance.primary_node
target_node_uuid = self._migrater.target_node_uuid
env = {
"IGNORE_CONSISTENCY": self.op.ignore_consistency,
"SHUTDOWN_TIMEOUT": self.op.shutdown_timeout,
"OLD_PRIMARY": self.cfg.GetNodeName(source_node_uuid),
"NEW_PRIMARY": self.op.target_node,
"NEW_PRIMARY": self.cfg.GetNodeName(target_node_uuid),
"FAILOVER_CLEANUP": self.op.cleanup,
}
......@@ -160,6 +161,7 @@ class LUInstanceFailover(LogicalUnit):
"""
instance = self._migrater.instance
nl = [self.cfg.GetMasterNode()] + list(instance.secondary_nodes)
nl.append(self._migrater.target_node_uuid)
return (nl, nl + [instance.primary_node])
......@@ -198,12 +200,13 @@ class LUInstanceMigrate(LogicalUnit):
"""
instance = self._migrater.instance
source_node_uuid = instance.primary_node
target_node_uuid = self._migrater.target_node_uuid
env = BuildInstanceHookEnvByObject(self, instance)
env.update({
"MIGRATE_LIVE": self._migrater.live,
"MIGRATE_CLEANUP": self.op.cleanup,
"OLD_PRIMARY": self.cfg.GetNodeName(source_node_uuid),
"NEW_PRIMARY": self.op.target_node,
"NEW_PRIMARY": self.cfg.GetNodeName(target_node_uuid),
"ALLOW_RUNTIME_CHANGES": self.op.allow_runtime_changes,
})
......@@ -211,7 +214,7 @@ class LUInstanceMigrate(LogicalUnit):
env["OLD_SECONDARY"] = self.cfg.GetNodeName(instance.secondary_nodes[0])
env["NEW_SECONDARY"] = self.cfg.GetNodeName(source_node_uuid)
else:
env["OLD_SECONDARY"] = env["NEW_SECONDARY"] = None
env["OLD_SECONDARY"] = env["NEW_SECONDARY"] = ""
return env
......@@ -222,6 +225,7 @@ class LUInstanceMigrate(LogicalUnit):
instance = self._migrater.instance
snode_uuids = list(instance.secondary_nodes)
nl = [self.cfg.GetMasterNode(), instance.primary_node] + snode_uuids
nl.append(self._migrater.target_node_uuid)
return (nl, nl)
......@@ -350,7 +354,7 @@ class TLMigrateInstance(Tasklet):
raise errors.ConfigurationError("No secondary node but using"
" %s disk template" %
self.instance.disk_template)
target_node_uuid = secondary_node_uuids[0]
self.target_node_uuid = target_node_uuid = secondary_node_uuids[0]
if self.lu.op.iallocator or \
(self.lu.op.target_node_uuid and
self.lu.op.target_node_uuid != target_node_uuid):
......
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