From cacfd1fdd4a9fade7526d5da9de72ec147f27161 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Tue, 10 Feb 2009 14:44:07 +0000 Subject: [PATCH] Switch the blockdev_shutdown rpc to (status, data) This converts the backend and cmdlib modules to a (status, data) implementation of the blockdev_shutdown rpc call. bdev.py is not yet converted, so we don't actually have error information. We also fix a bug in _ShutdownInstanceDisks by not reusing a variable. Reviewed-by: ultrotter --- lib/backend.py | 14 +++++++++++--- lib/cmdlib.py | 20 +++++++++++--------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/lib/backend.py b/lib/backend.py index 2c601dbb6..e56628e99 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -1248,18 +1248,26 @@ def BlockdevShutdown(disk): @return: the success of the operation """ + msgs = [] r_dev = _RecursiveFindBD(disk) if r_dev is not None: r_path = r_dev.dev_path - result = r_dev.Shutdown() + try: + result = r_dev.Shutdown() + except errors.BlockDeviceError, err: + msgs.append(str(err)) + result = False if result: DevCacheManager.RemoveCache(r_path) else: result = True if disk.children: for child in disk.children: - result = result and BlockdevShutdown(child) - return result + c_status, c_msg = BlockdevShutdown(child) + result = result and c_status + if c_msg: # not an empty message + msgs.append(c_msg) + return (result, "; ".join(msgs)) def BlockdevAddchildren(parent_cdev, new_cdevs): diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 3171c18fd..4b9f62c2a 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -2572,17 +2572,18 @@ def _ShutdownInstanceDisks(lu, instance, ignore_primary=False): ignored. """ - result = True + all_result = True for disk in instance.disks: for node, top_disk in disk.ComputeNodeTree(instance.primary_node): lu.cfg.SetDiskID(top_disk, node) result = lu.rpc.call_blockdev_shutdown(node, top_disk) - if result.failed or not result.data: - logging.error("Could not shutdown block device %s on node %s", - disk.iv_name, node) + msg = result.RemoteFailMsg() + if msg: + lu.LogWarning("Could not shutdown block device %s on node %s: %s", + disk.iv_name, node, msg) if not ignore_primary or node != instance.primary_node: - result = False - return result + all_result = False + return all_result def _CheckNodeFreeMemory(lu, node, reason, requested, hypervisor_name): @@ -5197,9 +5198,10 @@ class LUReplaceDisks(LogicalUnit): # we have new devices, shutdown the drbd on the old secondary info("shutting down drbd for disk/%d on old node" % idx) cfg.SetDiskID(dev, old_node) - result = self.rpc.call_blockdev_shutdown(old_node, dev) - if result.failed or not result.data: - warning("Failed to shutdown drbd for disk/%d on old node" % idx, + msg = self.rpc.call_blockdev_shutdown(old_node, dev).RemoteFailMsg() + if msg: + warning("Failed to shutdown drbd for disk/%d on old node: %s" % + (idx, msg), hint="Please cleanup this device manually as soon as possible") info("detaching primary drbds from the network (=> standalone)") -- GitLab