Commit 12a0cfbe authored by Guido Trotter's avatar Guido Trotter
Browse files

failover: only start instance if we should

gnt-instance failover on an instance marked as down will mistakenly bring it
up. The watcher will then shut it down again, but it's a lot better (and safer)
not to start it at all.

Reviewed-by: imsnah
parent c5cc3403
......@@ -2659,21 +2659,23 @@ class LUFailoverInstance(LogicalUnit):
# distribute new instance config to the other nodes
self.cfg.AddInstance(instance)
feedback_fn("* activating the instance's disks on target node")
logger.Info("Starting instance %s on node %s" %
(instance.name, target_node))
disks_ok, dummy = _AssembleInstanceDisks(instance, self.cfg,
ignore_secondaries=True)
if not disks_ok:
_ShutdownInstanceDisks(instance, self.cfg)
raise errors.OpExecError("Can't activate the instance's disks")
# Only start the instance if it's marked as up
if instance.status == "up":
feedback_fn("* activating the instance's disks on target node")
logger.Info("Starting instance %s on node %s" %
(instance.name, target_node))
disks_ok, dummy = _AssembleInstanceDisks(instance, self.cfg,
ignore_secondaries=True)
if not disks_ok:
_ShutdownInstanceDisks(instance, self.cfg)
raise errors.OpExecError("Can't activate the instance's disks")
feedback_fn("* starting the instance on the target node")
if not rpc.call_instance_start(target_node, instance, None):
_ShutdownInstanceDisks(instance, self.cfg)
raise errors.OpExecError("Could not start instance %s on node %s." %
(instance.name, target_node))
feedback_fn("* starting the instance on the target node")
if not rpc.call_instance_start(target_node, instance, None):
_ShutdownInstanceDisks(instance, self.cfg)
raise errors.OpExecError("Could not start instance %s on node %s." %
(instance.name, target_node))
def _CreateBlockDevOnPrimary(cfg, node, instance, device, info):
......
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