Commit 08eec276 authored by Iustin Pop's avatar Iustin Pop

Add {NEW,OLD}_{PRIMARY,SECONDARY} vars to hooks

Per issue 71, the migrate and failover need special variables for
keeping the nodes consistent during instance migrations.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 83d9f436
......@@ -260,7 +260,7 @@ INSTANCE_SECONDARIES refer to the nodes that were repectively primary
and secondary before failover.
:directory: instance-failover
:env. vars: IGNORE_CONSISTENCY
:env. vars: IGNORE_CONSISTENCY, OLD_SECONDARY, OLD_PRIMARY, NEW_SECONDARY, NEW_PRIMARY
:pre-execution: master node, secondary node
:post-execution: master node, secondary node
......@@ -272,7 +272,7 @@ INSTANCE_SECONDARIES refer to the nodes that were repectively primary
and secondary before migration.
:directory: instance-migrate
:env. vars: MIGRATE_LIVE, MIGRATE_CLEANUP
:env. vars: MIGRATE_LIVE, MIGRATE_CLEANUP, OLD_SECONDARY, OLD_PRIMARY, NEW_SECONDARY, NEW_PRIMARY
:pre-execution: master node, secondary node
:post-execution: master node, secondary node
......@@ -492,10 +492,16 @@ INSTANCE_OS_TYPE
The name of the instance OS.
INSTANCE_PRIMARY
The name of the node which is the primary for the instance.
The name of the node which is the primary for the instance. Note that
for migrations/failovers, you shouldn't rely on this variable since
the nodes change during the exectution, but on the
OLD_PRIMARY/NEW_PRIMARY values.
INSTANCE_SECONDARIES
Space-separated list of secondary nodes for the instance.
Space-separated list of secondary nodes for the instance. Note that
for migrations/failovers, you shouldn't rely on this variable since
the nodes change during the exectution, but on the
OLD_SECONDARY/NEW_SECONDARY values.
INSTANCE_MEMORY
The memory size (in MiBs) of the instance.
......@@ -538,13 +544,19 @@ SRC_NODE, SRC_PATH, SRC_IMAGE
NEW_SECONDARY
The name of the node on which the new mirror component is being
added. This can be the name of the current secondary, if the new
mirror is on the same secondary.
added (for replace disk). This can be the name of the current
secondary, if the new mirror is on the same secondary. For
migrations/failovers, this is the old primary node.
OLD_SECONDARY
The name of the old secondary in the replace-disks command Note that
The name of the old secondary in the replace-disks command. Note that
this can be equal to the new secondary if the secondary node hasn't
actually changed.
actually changed. For migrations/failovers, this is the new primary
node.
OLD_PRIMARY, NEW_PRIMARY
For migrations/failovers, the old and respectively new primary
nodes. These two mirror the NEW_SECONDARY/OLD_SECONDARY variables
EXPORT_NODE
The node on which the exported image of the instance was done.
......@@ -595,3 +607,7 @@ script::
GANETI_OP_TARGET=instance2.example.com
.. vim: set textwidth=72 :
.. Local Variables:
.. mode: rst
.. fill-column: 72
.. End:
......@@ -4587,12 +4587,19 @@ class LUFailoverInstance(LogicalUnit):
This runs on master, primary and secondary nodes of the instance.
"""
instance = self.instance
source_node = instance.primary_node
target_node = instance.secondary_nodes[0]
env = {
"IGNORE_CONSISTENCY": self.op.ignore_consistency,
"SHUTDOWN_TIMEOUT": self.shutdown_timeout,
"OLD_PRIMARY": source_node,
"OLD_SECONDARY": target_node,
"NEW_PRIMARY": target_node,
"NEW_SECONDARY": source_node,
}
env.update(_BuildInstanceHookEnvByObject(self, self.instance))
nl = [self.cfg.GetMasterNode()] + list(self.instance.secondary_nodes)
env.update(_BuildInstanceHookEnvByObject(self, instance))
nl = [self.cfg.GetMasterNode()] + list(instance.secondary_nodes)
return env, nl, nl
def CheckPrereq(self):
......@@ -4735,9 +4742,17 @@ class LUMigrateInstance(LogicalUnit):
"""
instance = self._migrater.instance
source_node = instance.primary_node
target_node = instance.secondary_nodes[0]
env = _BuildInstanceHookEnvByObject(self, instance)
env["MIGRATE_LIVE"] = self.op.live
env["MIGRATE_CLEANUP"] = self.op.cleanup
env.update({
"OLD_PRIMARY": source_node,
"OLD_SECONDARY": target_node,
"NEW_PRIMARY": target_node,
"NEW_SECONDARY": source_node,
})
nl = [self.cfg.GetMasterNode()] + list(instance.secondary_nodes)
return env, nl, nl
......
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