From 9a198532ba9d3f3badbe0e516e82127e08ed0cae Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Fri, 24 Apr 2009 08:43:01 +0000 Subject: [PATCH] Prevent errors when xenvg is broken cluster verify When vg_name is not returned at all, we currently abort with an internal error. This is because we don't catch KeyError. This patch adds a custom message for this case, and also adds KeyError to the list of catched exceptions, just for safety. On the other hand, we could also just remove this piece of code since it's not used at all the ["dfree"] value. Reviewed-by: ultrotter --- lib/cmdlib.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 01a8c93b4..b8fd0beda 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -1073,9 +1073,17 @@ class LUVerifyCluster(LogicalUnit): } # FIXME: devise a free space model for file based instances as well if vg_name is not None: + if (constants.NV_VGLIST not in nresult or + vg_name not in nresult[constants.NV_VGLIST]): + feedback_fn(" - ERROR: node %s didn't return data for the" + " volume group '%s' - it is either missing or broken" % + (node, vg_name)) + bad = True + continue node_info[node]["dfree"] = int(nresult[constants.NV_VGLIST][vg_name]) - except ValueError: - feedback_fn(" - ERROR: invalid value returned from node %s" % (node,)) + except (ValueError, KeyError): + feedback_fn(" - ERROR: invalid nodeinfo value returned" + " from node %s" % (node,)) bad = True continue -- GitLab