Change in vdsm[master]: vm: Set disk replica only if it can be prepared

nsoffer at redhat.com nsoffer at redhat.com
Sun Apr 19 21:47:18 UTC 2015


Nir Soffer has uploaded a new change for review.

Change subject: vm: Set disk replica only if it can be prepared
......................................................................

vm: Set disk replica only if it can be prepared

We used to set drive replicating state, and then try to prepare the
volume. If the preparing the volume fails, we revert the disk state.

To support LSM between mixed domain types, we need to check if the
replica disk is a block device, and keep this information in
Drive.diskReplicate dict. So we must prepare the volume before setting
the disk in replication state. This also makes sense anyway, since if we
cannot prepare the volume we cannot start the replication.

With the new order, we can simplify logging, and log only one exception
in the outer try block, instead of 3 different exceptions.  Since
Vm._delDiskReplica() may raise, we keep now the original error and
re-raise it.

Change-Id: I43814fa41c9cdc830fee9e929baa2e8249b18720
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
---
M vdsm/virt/vm.py
1 file changed, 12 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/22/40022/1

diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 4e64728..56f43a5 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -25,6 +25,7 @@
 from xml.dom.minidom import parseString as _domParseStr
 import logging
 import os
+import sys
 import tempfile
 import threading
 import time
@@ -3432,27 +3433,24 @@
         # prepareVolumePath
         dstDiskCopy['device'] = srcDrive.device
 
+        dstDiskCopy['path'] = self.cif.prepareVolumePath(dstDiskCopy)
         try:
             self._setDiskReplica(srcDrive, dstDisk)
-        except Exception:
-            self.log.error("Unable to set the replication for disk '%s' with "
-                           "destination '%s'", srcDrive.name, dstDisk)
-            return errCode['replicaErr']
-
-        try:
-            dstDiskCopy['path'] = self.cif.prepareVolumePath(dstDiskCopy)
 
             try:
                 self._startDriveReplication(srcDrive, dstDiskCopy)
             except Exception:
-                self.log.exception("Unable to start the replication"
-                                   " for %s to %s",
-                                   srcDrive.name, dstDiskCopy)
-                self.cif.teardownVolumePath(dstDiskCopy)
-                raise
+                t, v, tb = sys.exc_info()
+                try:
+                    self._delDiskReplica(srcDrive)
+                except Exception:
+                    self.log.exception("Error unsetting disk replica %s",
+                                       dstDisk)
+                raise t, v, tb
         except Exception:
-            self.log.exception("Cannot complete the disk replication process")
-            self._delDiskReplica(srcDrive)
+            self.log.exception("Unable to start replication for %s to %s",
+                               srcDrive.name, dstDiskCopy)
+            self.cif.teardownVolumePath(dstDiskCopy)
             return errCode['replicaErr']
 
         if srcDrive.chunked:


-- 
To view, visit https://gerrit.ovirt.org/40022
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I43814fa41c9cdc830fee9e929baa2e8249b18720
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer at redhat.com>


More information about the vdsm-patches mailing list