Cleanup DRBD 8.4 devices properly during QA
authorThomas Thrainer <thomasth@google.com>
Mon, 29 Apr 2013 11:51:29 +0000 (13:51 +0200)
committerMichele Tartara <mtartara@google.com>
Mon, 29 Apr 2013 16:05:52 +0000 (16:05 +0000)
QA cleans up DRBD 8.4 devices via drbdsetup, which currently only worked
for DRBD 8.3. This (rather ugly) command makes sure that DRBD 8.4
devices are cleaned up as well.

Signed-off-by: Thomas Thrainer <thomasth@google.com>
Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Michele Tartara <mtartara@google.com>

qa/qa_instance.py

index 3d1ef8c..da623c7 100644 (file)
@@ -1053,7 +1053,16 @@ def TestRemoveInstanceOfflineNode(instance, snode, set_offline, set_online):
     # FIXME: abstract the cleanup inside the disks
     if info["storage-type"] == constants.ST_LVM_VG:
       for minor in info["drbd-minors"][snode.primary]:
-        AssertCommand(["drbdsetup", str(minor), "down"], node=snode)
+        # DRBD 8.3 syntax comes first, then DRBD 8.4 syntax. The 8.4 syntax
+        # relies on the fact that we always create a resources for each minor,
+        # and that this resources is always named resource{minor}.
+        # As 'drbdsetup 0 down' does return success (even though that's invalid
+        # syntax), we always have to perform both commands and ignore the
+        # output.
+        drbd_shutdown_cmd = \
+          "(drbdsetup %d down && drbdsetup down resource%d) || /bin/true" % \
+            (minor, minor)
+        AssertCommand(drbd_shutdown_cmd, node=snode)
       AssertCommand(["lvremove", "-f"] + info["volumes"], node=snode)
     elif info["storage-type"] == constants.ST_FILE:
       filestorage = pathutils.DEFAULT_FILE_STORAGE_DIR