From 9aacb1991620bd1b0c778459b7e6e5ccea4f7e10 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Thu, 18 Nov 2010 10:37:34 +0100 Subject: [PATCH] Reinstall instance: disallow offline secondaries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, reinstallation of a DRBD instance with the secondary node offline does: node1# gnt-instance reinstall -f instance1 Waiting for job 139053 for instance1... Thu Nov 18 01:36:09 2010 - WARNING: Could not prepare block device disk/0 on node node3 (is_primary=False, pass=1): Node is marked offline Thu Nov 18 01:36:09 2010 - WARNING: Could not shutdown block device disk/0 on node node3: Node is marked offline Job 139053 for instance1 has failed: Failure: command execution error: Disk consistency error Since this fails anyway, let's check the secondary nodes, thus preventing any modifications to the instance (e.g. OS type change): node1# gnt-instance reinstall -f instance1 Waiting for job 139058 for instance1... Job 139058 for instance1 has failed: Failure: prerequisites not met for this operation: error type: wrong_state, error details: Instance secondary node offline, cannot reinstall: node3 The patch needs modifications to the _CheckNodeOnline function, in order to display meaningful messages ("Can't use offline node" would be very confusing for an instance reinstall, since we didn't select a node manually). Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: RenΓ© Nussbaumer <rn@google.com> --- lib/cmdlib.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 6393cce0e..8c175d694 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -593,17 +593,19 @@ def _CheckGlobalHvParams(params): raise errors.OpPrereqError(msg, errors.ECODE_INVAL) -def _CheckNodeOnline(lu, node): +def _CheckNodeOnline(lu, node, msg=None): """Ensure that a given node is online. @param lu: the LU on behalf of which we make the check @param node: the node to check + @param msg: if passed, should be a message to replace the default one @raise errors.OpPrereqError: if the node is offline """ + if msg is None: + msg = "Can't use offline node" if lu.cfg.GetNodeInfo(node).offline: - raise errors.OpPrereqError("Can't use offline node %s" % node, - errors.ECODE_STATE) + raise errors.OpPrereqError("%s: %s" % (msg, node), errors.ECODE_STATE) def _CheckNodeNotDrained(lu, node): @@ -4994,7 +4996,11 @@ class LUReinstallInstance(LogicalUnit): instance = self.cfg.GetInstanceInfo(self.op.instance_name) assert instance is not None, \ "Cannot retrieve locked instance %s" % self.op.instance_name - _CheckNodeOnline(self, instance.primary_node) + _CheckNodeOnline(self, instance.primary_node, "Instance primary node" + " offline, cannot reinstall") + for node in instance.secondary_nodes: + _CheckNodeOnline(self, node, "Instance secondary node offline," + " cannot reinstall") if instance.disk_template == constants.DT_DISKLESS: raise errors.OpPrereqError("Instance '%s' has no disks" % -- GitLab