Catch DeviceCreationError unhandled exceptions
authorGuido Trotter <ultrotter@google.com>
Fri, 21 Jun 2013 13:23:28 +0000 (15:23 +0200)
committerGuido Trotter <ultrotter@google.com>
Fri, 21 Jun 2013 14:07:50 +0000 (16:07 +0200)
_CreateBlockDevInner is called twice in TLReplaceDisks. While this
should be fixed, right now this leaves the DeviceCreationError exception
unhandled, which causes a problem due to the fact that this exception
was never supposed to be sent over the wire. For 2.7 we just catch the
exception and convert it to an OpExecError, but we should later do a
more proper cleanup.

This addresses Issue 472.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Michele Tartara <mtartara@google.com>

lib/cmdlib.py

index 28dec18..ba1ad64 100644 (file)
@@ -12001,9 +12001,12 @@ class TLReplaceDisks(Tasklet):
 
       # we pass force_create=True to force the LVM creation
       for new_lv in new_lvs:
-        _CreateBlockDevInner(self.lu, node_name, self.instance, new_lv, True,
-                             _GetInstanceInfoText(self.instance), False,
-                             excl_stor)
+        try:
+          _CreateBlockDevInner(self.lu, node_name, self.instance, new_lv,
+                               True, _GetInstanceInfoText(self.instance),
+                               False, excl_stor)
+        except errors.DeviceCreationError, e:
+          raise errors.OpExecError("Can't create block device: %s" % e.message)
 
     return iv_names
 
@@ -12218,9 +12221,12 @@ class TLReplaceDisks(Tasklet):
                       (self.new_node, idx))
       # we pass force_create=True to force LVM creation
       for new_lv in dev.children:
-        _CreateBlockDevInner(self.lu, self.new_node, self.instance, new_lv,
-                             True, _GetInstanceInfoText(self.instance), False,
-                             excl_stor)
+        try:
+          _CreateBlockDevInner(self.lu, self.new_node, self.instance, new_lv,
+                               True, _GetInstanceInfoText(self.instance),
+                               False, excl_stor)
+        except errors.DeviceCreationError, e:
+          raise errors.OpExecError("Can't create block device: %s" % e.message)
 
     # Step 4: dbrd minors and drbd setups changes
     # after this, we must manually remove the drbd minors on both the