Change in vdsm[ovirt-3.6]: hsm: Remove image run links in teardownImage

nsoffer at redhat.com nsoffer at redhat.com
Tue Feb 16 09:04:56 UTC 2016


Hello Adam Litke, Dan Kenigsberg,

I'd like you to do a code review.  Please visit

    https://gerrit.ovirt.org/53559

to review the following change.

Change subject: hsm: Remove image run links in teardownImage
......................................................................

hsm: Remove image run links in teardownImage

We were creating the /run/vdsm/sd_uuid/img_uuid in prepareImage, but we
never delete it. This directory (block storage) or link (file storage)
are used by hosted engine VM so it can run without a connected pool.

After vdsm maintenance, file storage domain mount path may change,
invalidating the links. When we create the links, we skip existing
links, assuming that the link target cannot change. Any operation with
the stale link will fail.

We need two fixes:
1. Remove links created in prepareImage during teardownImage
2. For the unlikely case when Vdsm was terminated before teardownImage
   was completed, repair stale links during creation.

This patch fixes the first issue. The second issue is handled in
https://gerrit.ovirt.org/52937.

Change-Id: I4568aaac2ce26c67132a839d95b75dd97bb28f29
Bug-Url: https://bugzilla.redhat.com/1300749
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
Reviewed-on: https://gerrit.ovirt.org/53298
Reviewed-by: Adam Litke <alitke at redhat.com>
Continuous-Integration: Jenkins CI
Reviewed-by: Simone Tiraboschi <stirabos at redhat.com>
Tested-by: Simone Tiraboschi <stirabos at redhat.com>
Reviewed-by: Allon Mureinik <amureini at redhat.com>
Reviewed-by: Dan Kenigsberg <danken at redhat.com>
---
M vdsm/storage/blockSD.py
M vdsm/storage/fileSD.py
M vdsm/storage/sd.py
3 files changed, 32 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/59/53559/1

diff --git a/vdsm/storage/blockSD.py b/vdsm/storage/blockSD.py
index 4a8a176..86a3a94 100644
--- a/vdsm/storage/blockSD.py
+++ b/vdsm/storage/blockSD.py
@@ -1031,6 +1031,7 @@
         If the image is based on a template image it should be expressly
         deactivated.
         """
+        self.removeImageLinks(imgUUID)
         allVols = self.getAllVolumes()
         volUUIDs = self._getImgExclusiveVols(imgUUID, allVols)
         lvm.deactivateLVs(self.sdUUID, volUUIDs)
@@ -1110,6 +1111,15 @@
 
         return imgRunDir
 
+    def removeImageLinks(self, imgUUID):
+        """
+        Remove /run/vdsm/storage/sd_uuid/img_uuid directory, created in
+        createImageLinks.
+
+        Should be called when tearing down an image.
+        """
+        fileUtils.cleanupdir(self.getImageRundir(imgUUID))
+
     def activateVolumes(self, imgUUID, volUUIDs):
         """
         Activate all the volumes belonging to the image.
diff --git a/vdsm/storage/fileSD.py b/vdsm/storage/fileSD.py
index 9deabf3..7f9ae17 100644
--- a/vdsm/storage/fileSD.py
+++ b/vdsm/storage/fileSD.py
@@ -427,7 +427,7 @@
 
         imgUUID: the image to be deactivated.
         """
-        pass
+        self.removeImageLinks(imgUUID)
 
     def getAllVolumes(self):
         """
@@ -522,6 +522,24 @@
 
         return imgRunDir
 
+    def removeImageLinks(self, imgUUID):
+        """
+        Remove /run/vdsm/storage/sd_uuid/img_uuid link, created in
+        createImageLinks.
+
+        Should be called when tearing down an image.
+        """
+        path = self.getImageRundir(imgUUID)
+        self.log.debug("Removing image rundir link %r", path)
+        try:
+            os.unlink(path)
+        except OSError as e:
+            if e.errno == errno.ENOENT:
+                self.log.debug("Image rundir link %r does not exists", path)
+            else:
+                self.log.error("Cannot remove image rundir link %r: %s",
+                               path, e)
+
     def activateVolumes(self, imgUUID, volUUIDs):
         """
         Activate all the volumes listed in volUUIDs
diff --git a/vdsm/storage/sd.py b/vdsm/storage/sd.py
index 4b48180..8339efb 100644
--- a/vdsm/storage/sd.py
+++ b/vdsm/storage/sd.py
@@ -727,6 +727,9 @@
         return image.Image(self._getRepoPath()) \
                     .getImageDir(self.sdUUID, imgUUID)
 
+    def getImageRundir(self, imgUUID):
+        return os.path.join(constants.P_VDSM_STORAGE, self.sdUUID, imgUUID)
+
     def getIsoDomainImagesDir(self):
         return self._manifest.getIsoDomainImagesDir()
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4568aaac2ce26c67132a839d95b75dd97bb28f29
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.6
Gerrit-Owner: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: Adam Litke <alitke at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>


More information about the vdsm-patches mailing list