Eduardo has uploaded a new change for review.
Change subject: WIP - Avoid creation of fake templates.
......................................................................
WIP - Avoid creation of fake templates.
Change-Id: I7ae6e455757f247bfc3d8e261d8f5cec25f8776a
Signed-off-by: Eduardo <ewarszaw(a)redhat.com>
---
M vdsm/storage/image.py
M vdsm/storage/sp.py
2 files changed, 0 insertions(+), 45 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/80/8280/1
diff --git a/vdsm/storage/image.py b/vdsm/storage/image.py
index d004046..bb620ef 100644
--- a/vdsm/storage/image.py
+++ b/vdsm/storage/image.py
@@ -20,7 +20,6 @@
import os
import logging
-import threading
import uuid
from contextlib import contextmanager
@@ -65,7 +64,6 @@
Consist from chain of volumes.
"""
log = logging.getLogger('Storage.Image')
- _fakeTemplateLock = threading.Lock()
@classmethod
def createImageRollback(cls, taskObj, imageDir):
@@ -428,37 +426,6 @@
self.repoPath, destDom.sdUUID, sd.DOMAIN_IMAGES,
templateImage, volUUID), tLink)
- def createFakeTemplate(self, sdUUID, volParams):
- """
- Create fake template (relevant for Backup domain only)
- """
- with self._fakeTemplateLock:
- try:
- destDom = sdCache.produce(sdUUID)
- volclass = destDom.getVolumeClass()
- # Validate that the destination template exists and accessible
- volclass(self.repoPath, sdUUID, volParams['imgUUID'],
volParams['volUUID'])
- except (se.VolumeDoesNotExist, se.ImagePathError):
- try:
- # Create fake parent volume
- destDom.createVolume(imgUUID=volParams['imgUUID'],
size=volParams['size'],
- volFormat=volume.COW_FORMAT,
preallocate=volume.SPARSE_VOL,
- diskType=volParams['disktype'],
volUUID=volParams['volUUID'], desc="Fake volume",
- srcImgUUID=volume.BLANK_UUID,
srcVolUUID=volume.BLANK_UUID)
-
- vol = destDom.produceVolume(imgUUID=volParams['imgUUID'],
volUUID=volParams['volUUID'])
- # Mark fake volume as "FAKE"
- vol.setLegality(volume.FAKE_VOL)
- # Mark fake volume as shared
- vol.setShared()
- # Now we should re-link all hardlinks of this template in all VMs
based on it
- self.__templateRelink(destDom, volParams['imgUUID'],
volParams['volUUID'])
-
- self.log.debug("Succeeded to create fake image %s in domain
%s", volParams['imgUUID'], destDom.sdUUID)
- except Exception:
- self.log.error("Failure to create fake image %s in domain
%s", volParams['imgUUID'],
- destDom.sdUUID, exc_info=True)
-
def isLegal(self, sdUUID, imgUUID):
"""
Check correctness of the whole chain (excluding template)
@@ -502,7 +469,6 @@
self.log.error("Unexpected error", exc_info=True)
raise se.SourceImageActionError(imgUUID, srcSdUUID, str(e))
- fakeTemplate = False
pimg = volume.BLANK_UUID # standalone chain
# check if the chain is build above a template, or it is a standalone
pvol = srcChain[0].getParentVolume()
@@ -510,11 +476,6 @@
# find out parent volume parameters
volParams = pvol.getVolumeParams()
pimg = volParams['imgUUID'] # pimg == template image
- if destDom.isBackup():
- # FIXME: This workaround help as copy VM to the backup domain without its
template
- # We will create fake template for future VM creation and mark it as FAKE
volume
- # This situation is relevant for backup domain only
- fakeTemplate = True
@contextmanager
def justLogIt(img):
@@ -525,9 +486,6 @@
# In destination domain we need to lock image's template if exists
with rmanager.acquireResource(dstImageResourcesNamespace, pimg,
rm.LockType.shared) \
if pimg != volume.BLANK_UUID else justLogIt(imgUUID):
- if fakeTemplate:
- self.createFakeTemplate(destDom.sdUUID, volParams)
-
dstChain = []
for srcVol in srcChain:
# Create the dst volume
diff --git a/vdsm/storage/sp.py b/vdsm/storage/sp.py
index 78fbe66..d3b7009 100644
--- a/vdsm/storage/sp.py
+++ b/vdsm/storage/sp.py
@@ -1828,10 +1828,7 @@
allVols)
else:
# Removing a template with dependencies in backup domain
- # A fake template will be created
img.delete(sdUUID=sdUUID, imgUUID=imgUUID, postZero=postZero,
force=True)
- tParams = dom.produceVolume(imgUUID, tName).getVolumeParams()
- img.createFakeTemplate(sdUUID=sdUUID, volParams=tParams)
def mergeSnapshots(self, sdUUID, vmUUID, imgUUID, ancestor, successor, postZero):
"""
--
To view, visit
http://gerrit.ovirt.org/8280
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7ae6e455757f247bfc3d8e261d8f5cec25f8776a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Eduardo <ewarszaw(a)redhat.com>