On Fri, Apr 26, 2013 at 2:19 PM, Klaus Aehlig <[email protected]> wrote:
> Currently, if converting an instance from plain to drbd fails after > renaming the original LVs, the instance is left in an inconsistent > state. This commit tries to undo the renaming if a failure occurs > on assembling a DRBD device, e.g., when device minor numbers are > exhausted. (Issue 229) > > Signed-off-by: Klaus Aehlig <[email protected]> > --- > lib/cmdlib.py | 21 ++++++++++++++++----- > 1 file changed, 16 insertions(+), 5 deletions(-) > > diff --git a/lib/cmdlib.py b/lib/cmdlib.py > index 228abd5..a509d9d 100644 > --- a/lib/cmdlib.py > +++ b/lib/cmdlib.py > @@ -14008,11 +14008,22 @@ class LUInstanceSetParams(LogicalUnit): > > feedback_fn("Initializing DRBD devices...") > # all child devices are in place, we can now create the DRBD devices > - for disk in anno_disks: > - for (node, excl_stor) in [(pnode, p_excl_stor), (snode, > s_excl_stor)]: > - f_create = node == pnode > - _CreateSingleBlockDev(self, node, instance, disk, info, f_create, > - excl_stor) > + try: > + for disk in anno_disks: > + for (node, excl_stor) in [(pnode, p_excl_stor), (snode, > s_excl_stor)]: > + f_create = node == pnode > + _CreateSingleBlockDev(self, node, instance, disk, info, > f_create, > + excl_stor) > + except errors.GenericError: > + feedback_fn("Initializing of DRBD devices failed;" > + " renaming back original volumes...") > + for disk in new_disks: > + self.cfg.SetDiskID(disk, pnode) > + rename_back_list = [(n.children[0], o.logical_id) > + for (n, o) in zip(new_disks, instance.disks)] > + result = self.rpc.call_blockdev_rename(pnode, rename_back_list) > + result.Raise("Failed to rename LVs back") > This would raise another exception than the original one, thus masking the "real" error. Wouldn't it be better to raise an exception with both information in it? > + raise > > # at this point, the instance has been modified > instance.disk_template = constants.DT_DRBD8 > -- > 1.8.2.1 > > -- Thomas Thrainer | Software Engineer | [email protected] | Google Germany GmbH Dienerstr. 12 80331 München Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Graham Law, Katherine Stephens
