<entry>Remove an instance</entry>
<entry><computeroutput>gnt-instance remove</computeroutput></entry>
<entry><constant>INSTANCE_NAME</constant>, <constant>INSTANCE_PRIMARY</constant>, <constant>INSTANCE_SECONDARIES</constant></entry>
+ <entry spanname="bothhooks">master node</entry>
</row>
<row>
<entry>OP_INSTANCE_ADD_MDDRBD</entry>
"""
env = _BuildInstanceHookEnvByObject(self.instance)
- nl = ([self.sstore.GetMasterNode(), self.instance.primary_node] +
- list(self.instance.secondary_nodes))
+ nl = [self.sstore.GetMasterNode()]
return env, nl, nl
def CheckPrereq(self):
(instance.name, instance.primary_node))
if not rpc.call_instance_shutdown(instance.primary_node, instance):
- raise errors.OpExecError("Could not shutdown instance %s on node %s" %
- (instance.name, instance.primary_node))
+ if self.op.ignore_failures:
+ feedback_fn("Warning: can't shutdown instance")
+ else:
+ raise errors.OpExecError("Could not shutdown instance %s on node %s" %
+ (instance.name, instance.primary_node))
logger.Info("removing block devices for instance %s" % instance.name)
- _RemoveDisks(instance, self.cfg)
+ if not _RemoveDisks(instance, self.cfg):
+ if self.op.ignore_failures:
+ feedback_fn("Warning: can't remove instance's disks")
+ else:
+ raise errors.OpExecError("Can't remove instance's disks")
logger.Info("removing instance %s out of cluster config" % instance.name)
This abstracts away some work from `AddInstance()` and
`RemoveInstance()`. Note that in case some of the devices couldn't
- be remove, the removal will continue with the other ones (compare
+ be removed, the removal will continue with the other ones (compare
with `_CreateDisks()`).
Args:
class OpRemoveInstance(OpCode):
"""Remove an instance."""
OP_ID = "OP_INSTANCE_REMOVE"
- __slots__ = ["instance_name"]
+ __slots__ = ["instance_name", "ignore_failures"]
class OpRenameInstance(OpCode):
<cmdsynopsis>
<command>remove</command>
+ <arg>--ignore-failures</arg>
<arg choice="req"><replaceable>instance</replaceable></arg>
</cmdsynopsis>
you are not sure if you use an instance again, use
<command>shutdown</command> first and leave it in the
shutdown state for a while.
+
+ </para>
+
+ <para>
+ The <option>--ignore-failures</option> option will cause the
+ removal to proceed even in the presence of errors during the
+ removal of the instance (e.g. during the shutdown or the
+ disk removal). If this option is not given, the command will
+ stop at the first error.
</para>
<para>
if not AskUser(usertext):
return 1
- op = opcodes.OpRemoveInstance(instance_name=instance_name)
+ op = opcodes.OpRemoveInstance(instance_name=instance_name,
+ ignore_failures=opts.ignore_failures)
SubmitOpCode(op)
return 0
"", "Lists the instances and their status"),
'reinstall': (ReinstallInstance, ARGS_ONE, [DEBUG_OPT, FORCE_OPT, os_opt],
"[-f] <instance>", "Reinstall the instance"),
- 'remove': (RemoveInstance, ARGS_ONE, [DEBUG_OPT, FORCE_OPT],
+ 'remove': (RemoveInstance, ARGS_ONE,
+ [DEBUG_OPT, FORCE_OPT,
+ make_option("--ignore-failures", dest="ignore_failures",
+ action="store_true", default=False,
+ help=("Remove the instance from the cluster even"
+ " if there are failures during the removal"
+ " process (shutdown, disk removal, etc.)")),
+ ],
"[-f] <instance>", "Shuts down the instance and removes it"),
'remove-mirror': (RemoveMDDRBDComponent, ARGS_ONE,
[DEBUG_OPT, node_opt,