Change in vdsm[master]: storage: Rename _share to share_to_image
by alitke@redhat.com
Adam Litke has uploaded a new change for review.
Change subject: storage: Rename _share to share_to_image
......................................................................
storage: Rename _share to share_to_image
When a new volume is created whose parent is a template volume, that
template must be "shared" into the new volume's image since volume
chains only link volumes in the same image. This logic is reusable by
the SDM create volume flow but _share should be renamed to
share_to_image to remove the _ which designates this as a protected
method.
Change-Id: I44c7fe43ada38aa97bbd9c08438a0ee686680330
Signed-off-by: Adam Litke <alitke(a)redhat.com>
---
M vdsm/storage/blockVolume.py
M vdsm/storage/fileVolume.py
M vdsm/storage/volume.py
3 files changed, 3 insertions(+), 3 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/46/44046/1
diff --git a/vdsm/storage/blockVolume.py b/vdsm/storage/blockVolume.py
index 47336b9..23e636e 100644
--- a/vdsm/storage/blockVolume.py
+++ b/vdsm/storage/blockVolume.py
@@ -314,7 +314,7 @@
def refreshVolume(self):
lvm.refreshLVs(self.sdUUID, (self.volUUID,))
- def _share(self, dstImgPath):
+ def share_to_image(self, dstImgPath):
"""
Share this volume to dstImgPath
"""
diff --git a/vdsm/storage/fileVolume.py b/vdsm/storage/fileVolume.py
index 15ca05b..c5b8667 100644
--- a/vdsm/storage/fileVolume.py
+++ b/vdsm/storage/fileVolume.py
@@ -300,7 +300,7 @@
os.path.join(dstImgPath, self.volUUID))
self.oop.utils.forceLink(self._getLeaseVolumePath(), dstLeasePath)
- def _share(self, dstImgPath):
+ def share_to_image(self, dstImgPath):
"""
Share this volume to dstImgPath, including the metadata and the lease
"""
diff --git a/vdsm/storage/volume.py b/vdsm/storage/volume.py
index 0d61643..951efe0 100644
--- a/vdsm/storage/volume.py
+++ b/vdsm/storage/volume.py
@@ -598,7 +598,7 @@
self.md.removeMetadata()
def _share(self, dstImgPath):
- return self.md._share(dstImgPath)
+ return self.md.share_to_image(dstImgPath)
@classmethod
def _getModuleAndClass(cls):
--
To view, visit https://gerrit.ovirt.org/44046
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I44c7fe43ada38aa97bbd9c08438a0ee686680330
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke(a)redhat.com>
6 years, 9 months
Change in vdsm[master]: storage: Rename getParent to getParentId
by alitke@redhat.com
Adam Litke has uploaded a new change for review.
Change subject: storage: Rename getParent to getParentId
......................................................................
storage: Rename getParent to getParentId
The Volume and VolumeMetadata classes have functions to return the
parent UUID and parent volume instance. It's a bit unclear that
getParent returns the ID so let's make this more explicit by renaming
getParent to getParentId.
Change-Id: Ie310d731709ebf1ba3589e92a7ae506ccdc8ae22
Signed-off-by: Adam Litke <alitke(a)redhat.com>
---
M vdsm/storage/blockVolume.py
M vdsm/storage/fileVolume.py
M vdsm/storage/image.py
M vdsm/storage/sp.py
M vdsm/storage/volume.py
5 files changed, 20 insertions(+), 20 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/47/44047/1
diff --git a/vdsm/storage/blockVolume.py b/vdsm/storage/blockVolume.py
index 23e636e..0168d64 100644
--- a/vdsm/storage/blockVolume.py
+++ b/vdsm/storage/blockVolume.py
@@ -167,7 +167,7 @@
def getParentMeta(self):
return self.getMetaParam(volume.PUUID)
- def getParent(self):
+ def getParentId(self):
"""
Return parent volume UUID
"""
@@ -490,7 +490,7 @@
try:
# We need to blank parent record in our metadata
# for parent to become leaf successfully.
- puuid = self.getParent()
+ puuid = self.getParentId()
self.setParent(volume.BLANK_UUID)
if puuid and puuid != volume.BLANK_UUID:
pvol = BlockVolume(self.repoPath, self.sdUUID, self.imgUUID,
diff --git a/vdsm/storage/fileVolume.py b/vdsm/storage/fileVolume.py
index c5b8667..2dad91f 100644
--- a/vdsm/storage/fileVolume.py
+++ b/vdsm/storage/fileVolume.py
@@ -150,7 +150,7 @@
return out
- def getParent(self):
+ def getParentId(self):
"""
Return parent volume UUID
"""
@@ -452,7 +452,7 @@
try:
# We need to blank parent record in our metadata
# for parent to become leaf successfully.
- puuid = self.getParent()
+ puuid = self.getParentId()
self.setParent(volume.BLANK_UUID)
if puuid and puuid != volume.BLANK_UUID:
pvol = FileVolume(self.repoPath, self.sdUUID,
diff --git a/vdsm/storage/image.py b/vdsm/storage/image.py
index fa0770c..43e08e5 100644
--- a/vdsm/storage/image.py
+++ b/vdsm/storage/image.py
@@ -232,7 +232,7 @@
chain.insert(0, srcVol)
seen.add(srcVol.volUUID)
- parentUUID = srcVol.getParent()
+ parentUUID = srcVol.getParentId()
if parentUUID == volume.BLANK_UUID:
break
@@ -578,7 +578,7 @@
raise se.VolumeNotSparse()
srcVolume = self._getSparsifyVolume(tmpSdUUID, tmpImgUUID,
- tmpVolume.getParent())
+ tmpVolume.getParentId())
tmpVolume.prepare()
try:
@@ -898,7 +898,7 @@
successor = chain[-1]
tmpVol = volclass(self.repoPath, sdDom.sdUUID, imgUUID, successor)
dstParent = volclass(self.repoPath, sdDom.sdUUID, imgUUID,
- ancestor).getParent()
+ ancestor).getParentId()
# Mark all volumes as illegal
while tmpVol and dstParent != tmpVol.volUUID:
@@ -926,7 +926,7 @@
successor = chain[-1]
srcVol = volclass(self.repoPath, sdUUID, imgUUID, successor)
dstParent = volclass(self.repoPath, sdUUID, imgUUID,
- ancestor).getParent()
+ ancestor).getParentId()
while srcVol and dstParent != srcVol.volUUID:
try:
@@ -953,7 +953,7 @@
successor = chain[-1]
srcVol = volclass(self.repoPath, sdDom.sdUUID, imgUUID, successor)
dstParent = volclass(self.repoPath, sdDom.sdUUID, imgUUID,
- ancestor).getParent()
+ ancestor).getParentId()
while srcVol and dstParent != srcVol.volUUID:
self.log.info("Remove volume %s from image %s", srcVol.volUUID,
@@ -1143,12 +1143,12 @@
"""
chain = []
accumulatedChainSize = 0
- endVolName = vols[ancestor].getParent() # TemplateVolName or None
+ endVolName = vols[ancestor].getParentId() # TemplateVolName or None
currVolName = successor
while (currVolName != endVolName):
chain.insert(0, currVolName)
accumulatedChainSize += vols[currVolName].getVolumeSize()
- currVolName = vols[currVolName].getParent()
+ currVolName = vols[currVolName].getParentId()
return accumulatedChainSize, chain
@@ -1169,7 +1169,7 @@
self.log.debug("unlinking subchain: %s" % subChain)
sdDom = sdCache.produce(sdUUID=sdUUID)
- dstParent = sdDom.produceVolume(imgUUID, subChain[0]).getParent()
+ dstParent = sdDom.produceVolume(imgUUID, subChain[0]).getParentId()
subChainTailVol = sdDom.produceVolume(imgUUID, subChain[-1])
if subChainTailVol.isLeaf():
self.log.debug("Leaf volume is being removed from the chain. "
@@ -1247,10 +1247,10 @@
srcVolParams = srcVol.getVolumeParams()
srcVolParams['children'] = []
for vName, vol in vols.iteritems():
- if vol.getParent() == successor:
+ if vol.getParentId() == successor:
srcVolParams['children'].append(vol)
dstVol = vols[ancestor]
- dstParentUUID = dstVol.getParent()
+ dstParentUUID = dstVol.getParentId()
if dstParentUUID != sd.BLANK_UUID:
volParams = vols[dstParentUUID].getVolumeParams()
else:
diff --git a/vdsm/storage/sp.py b/vdsm/storage/sp.py
index 8574bac..b92f107 100644
--- a/vdsm/storage/sp.py
+++ b/vdsm/storage/sp.py
@@ -1838,7 +1838,7 @@
volUUID=srcVolUUID)
if not srcVol.isShared():
- if srcVol.getParent() == volume.BLANK_UUID:
+ if srcVol.getParentId() == volume.BLANK_UUID:
with rmanager.acquireResource(imageResourcesNamespace,
srcImgUUID,
rm.LockType.exclusive):
diff --git a/vdsm/storage/volume.py b/vdsm/storage/volume.py
index 951efe0..691d3b9 100644
--- a/vdsm/storage/volume.py
+++ b/vdsm/storage/volume.py
@@ -250,7 +250,7 @@
"disktype": meta.get(DISKTYPE, ""),
"voltype": meta.get(VOLTYPE, ""),
"size": int(meta.get(SIZE, "0")),
- "parent": self.getParent(),
+ "parent": self.getParentId(),
"description": meta.get(DESCRIPTION, ""),
"pool": meta.get(sd.DMDK_POOLS, ""),
"domain": meta.get(DOMAIN, ""),
@@ -310,7 +310,7 @@
volParams['size'] = self.getSize()
volParams['apparentsize'] = self.getVolumeSize(bs=bs)
volParams['truesize'] = self.getVolumeTrueSize(bs=bs)
- volParams['parent'] = self.getParent()
+ volParams['parent'] = self.getParentId()
volParams['descr'] = self.getDescription()
volParams['legality'] = self.getLegality()
return volParams
@@ -494,7 +494,7 @@
"""
Return parent volume object
"""
- puuid = self.getParent()
+ puuid = self.getParentId()
if puuid and puuid != BLANK_UUID:
return sdCache.produce(self.sdUUID).produceVolume(self.imgUUID,
puuid)
@@ -571,11 +571,11 @@
"""
return self.md.getMetadata(metaId)
- def getParent(self):
+ def getParentId(self):
"""
Return parent volume UUID
"""
- return self.md.getParent()
+ return self.md.getParentId()
def getChildren(self):
""" Return children volume UUIDs.
--
To view, visit https://gerrit.ovirt.org/44047
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie310d731709ebf1ba3589e92a7ae506ccdc8ae22
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke(a)redhat.com>
6 years, 9 months
Change in vdsm[master]: storage: Rename getParentVolume* to produceParent
by alitke@redhat.com
Adam Litke has uploaded a new change for review.
Change subject: storage: Rename getParentVolume* to produceParent
......................................................................
storage: Rename getParentVolume* to produceParent
The Volume object provides getParentVolume and the VolumeMetadata object
provides getParentVolumeMetadata. Both of these functions return an
instance of their same type which represents this volume's parent.
Since the logic is the same and both object types implement compatible
interfaces let's unify around the name produceParent. Once complete,
consumers of these objects can use either type without additional
modifications.
Change-Id: I4553e5bcc8a576abc6fb472148f744c66e5012ef
Signed-off-by: Adam Litke <alitke(a)redhat.com>
---
M vdsm/storage/image.py
M vdsm/storage/resourceFactories.py
M vdsm/storage/volume.py
3 files changed, 16 insertions(+), 16 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/48/44048/1
diff --git a/vdsm/storage/image.py b/vdsm/storage/image.py
index 43e08e5..bd79f6e 100644
--- a/vdsm/storage/image.py
+++ b/vdsm/storage/image.py
@@ -168,7 +168,7 @@
"""
chain = self.getChain(sdUUID, imgUUID, volUUID)
newsize = 0
- template = chain[0].getParentVolume()
+ template = chain[0].produceParent()
if template:
newsize = template.getVolumeSize()
for vol in chain:
@@ -241,7 +241,7 @@
imgUUID, srcVol.volUUID, parentUUID)
raise se.ImageIsNotLegalChain(imgUUID)
- srcVol = srcVol.getParentVolume()
+ srcVol = srcVol.produceParent()
self.log.info("sdUUID=%s imgUUID=%s chain=%s ", sdUUID, imgUUID, chain)
return chain
@@ -254,7 +254,7 @@
# Find all volumes of image (excluding template)
chain = self.getChain(sdUUID, imgUUID)
# check if the chain is build above a template, or it is a standalone
- pvol = chain[0].getParentVolume()
+ pvol = chain[0].produceParent()
if pvol:
tmpl = pvol
elif chain[0].isShared():
@@ -351,7 +351,7 @@
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()
+ pvol = srcChain[0].produceParent()
if pvol:
# find out parent volume parameters
volParams = pvol.getVolumeParams()
@@ -454,7 +454,7 @@
srcFormat = volume.fmt2str(srcVol.getFormat())
dstFormat = volume.fmt2str(dstVol.getFormat())
- parentVol = dstVol.getParentVolume()
+ parentVol = dstVol.produceParent()
if parentVol is not None:
backing = volume.getBackingVolumePath(
@@ -731,7 +731,7 @@
raise se.ImageIsNotLegalChain(imgUUID)
chain = self.getChain(sdUUID, imgUUID)
# check if the chain is build above a template, or it is a standalone
- pvol = chain[0].getParentVolume()
+ pvol = chain[0].produceParent()
if pvol:
if not pvol.isLegal() or pvol.isFake():
raise se.ImageIsNotLegalChain(imgUUID)
@@ -902,7 +902,7 @@
# Mark all volumes as illegal
while tmpVol and dstParent != tmpVol.volUUID:
- vol = tmpVol.getParentVolume()
+ vol = tmpVol.produceParent()
tmpVol.setLegality(volume.ILLEGAL_VOL)
tmpVol = vol
@@ -932,7 +932,7 @@
try:
self.log.info("Teardown volume %s from image %s",
srcVol.volUUID, imgUUID)
- vol = srcVol.getParentVolume()
+ vol = srcVol.produceParent()
srcVol.teardown(sdUUID=srcVol.sdUUID, volUUID=srcVol.volUUID,
justme=True)
srcVol = vol
@@ -958,7 +958,7 @@
while srcVol and dstParent != srcVol.volUUID:
self.log.info("Remove volume %s from image %s", srcVol.volUUID,
imgUUID)
- vol = srcVol.getParentVolume()
+ vol = srcVol.produceParent()
srcVol.delete(postZero=postZero, force=True)
chain.remove(srcVol.volUUID)
srcVol = vol
@@ -1321,7 +1321,7 @@
def _activateVolumeForImportExport(self, domain, imgUUID, volUUID=None):
chain = self.getChain(domain.sdUUID, imgUUID, volUUID)
- template = chain[0].getParentVolume()
+ template = chain[0].produceParent()
if template or len(chain) > 1:
self.log.error("Importing and exporting an image with more "
diff --git a/vdsm/storage/resourceFactories.py b/vdsm/storage/resourceFactories.py
index 98c362b..fb2522d 100644
--- a/vdsm/storage/resourceFactories.py
+++ b/vdsm/storage/resourceFactories.py
@@ -126,7 +126,7 @@
return []
# check if the chain is build above a template, or it is a standalone
- pvol = chain[0].getParentVolume()
+ pvol = chain[0].produceParent()
if pvol:
template = pvol.volUUID
elif chain[0].isShared():
diff --git a/vdsm/storage/volume.py b/vdsm/storage/volume.py
index 691d3b9..a098eb7 100644
--- a/vdsm/storage/volume.py
+++ b/vdsm/storage/volume.py
@@ -490,7 +490,7 @@
"""
pass # Do not remove this method or the V3 upgrade will fail.
- def getParentVolume(self):
+ def produceParent(self):
"""
Return parent volume object
"""
@@ -659,7 +659,7 @@
Rebase volume on top of new backing volume
"""
if rollback:
- pvol = self.getParentVolume()
+ pvol = self.produceParent()
if not pvol:
self.log.warn("Can't rebase volume %s, parent missing",
self.volUUID)
@@ -787,7 +787,7 @@
"volUUID=%s imageDir=%s" %
(repoPath, sdUUID, imgUUID, volUUID, imageDir))
vol = sdCache.produce(sdUUID).produceVolume(imgUUID, volUUID)
- pvol = vol.getParentVolume()
+ pvol = vol.produceParent()
# Remove volume
vol.delete(postZero=False, force=True)
if len(cls.getImageVolumes(repoPath, sdUUID, imgUUID)):
@@ -1120,7 +1120,7 @@
try:
if justme:
return True
- pvol = self.getParentVolume()
+ pvol = self.produceParent()
if pvol:
pvol.prepare(rw=chainrw, justme=False,
chainrw=chainrw, setrw=setrw)
@@ -1149,7 +1149,7 @@
def getInfo(self):
return self.md.getInfo()
- def getParentVolume(self):
+ def produceParent(self):
"""
Return parent volume object
"""
--
To view, visit https://gerrit.ovirt.org/44048
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4553e5bcc8a576abc6fb472148f744c66e5012ef
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke(a)redhat.com>
6 years, 9 months
Change in vdsm[master]: ImageManifest: move getChain
by alitke@redhat.com
Adam Litke has uploaded a new change for review.
Change subject: ImageManifest: move getChain
......................................................................
ImageManifest: move getChain
The implementation of getChain instantiates storagedomain and volume
objects. This must be fixed. We must fix all callers of getChain to
work with VolumeMetadata objects instead of Volume objects.
Change-Id: Iffd24be3ba74ccdea8dfc744b579c0cf63771cdb
Signed-off-by: Adam Litke <alitke(a)redhat.com>
---
M vdsm/storage/image.py
1 file changed, 71 insertions(+), 66 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/49/44049/1
diff --git a/vdsm/storage/image.py b/vdsm/storage/image.py
index bd79f6e..f852f3c 100644
--- a/vdsm/storage/image.py
+++ b/vdsm/storage/image.py
@@ -89,6 +89,8 @@
class ImageManifest(object):
+ log = logging.getLogger('Storage.ImageManifest')
+
def __init__(self, repoPath):
self.repoPath = repoPath
@@ -105,6 +107,74 @@
log.info("Create placeholder %s for image's volumes", img_dir)
os.mkdir(img_dir)
return img_dir
+
+ def getChain(self, sdUUID, imgUUID, volUUID=None):
+ """
+ Return the chain of volumes of image as a sorted list
+ (not including a shared base (template) if any)
+ """
+ chain = []
+ volclass = sdCache.produce(sdUUID).getVolumeClass()
+
+ # Use volUUID when provided
+ if volUUID:
+ srcVol = volclass(self.repoPath, sdUUID, imgUUID, volUUID)
+
+ # For template images include only one volume (the template itself)
+ # NOTE: this relies on the fact that in a template there is only
+ # one volume
+ if srcVol.isShared():
+ return [srcVol]
+
+ # Find all the volumes when volUUID is not provided
+ else:
+ # Find all volumes of image
+ uuidlist = volclass.getImageVolumes(self.repoPath, sdUUID, imgUUID)
+
+ if not uuidlist:
+ raise se.ImageDoesNotExistInSD(imgUUID, sdUUID)
+
+ srcVol = volclass(self.repoPath, sdUUID, imgUUID, uuidlist[0])
+
+ # For template images include only one volume (the template itself)
+ if len(uuidlist) == 1 and srcVol.isShared():
+ return [srcVol]
+
+ # Searching for the leaf
+ for vol in uuidlist:
+ srcVol = volclass(self.repoPath, sdUUID, imgUUID, vol)
+
+ if srcVol.isLeaf():
+ break
+
+ srcVol = None
+
+ if not srcVol:
+ self.log.error("There is no leaf in the image %s", imgUUID)
+ raise se.ImageIsNotLegalChain(imgUUID)
+
+ # We have seen corrupted chains that cause endless loops here.
+ # https://bugzilla.redhat.com/1125197
+ seen = set()
+
+ # Build up the sorted parent -> child chain
+ while not srcVol.isShared():
+ chain.insert(0, srcVol)
+ seen.add(srcVol.volUUID)
+
+ parentUUID = srcVol.getParentId()
+ if parentUUID == volume.BLANK_UUID:
+ break
+
+ if parentUUID in seen:
+ self.log.error("Image %s volume %s has invalid parent UUID %s",
+ imgUUID, srcVol.volUUID, parentUUID)
+ raise se.ImageIsNotLegalChain(imgUUID)
+
+ srcVol = srcVol.produceParent()
+
+ self.log.info("sdUUID=%s imgUUID=%s chain=%s ", sdUUID, imgUUID, chain)
+ return chain
class Image:
@@ -179,72 +249,7 @@
return newsize
def getChain(self, sdUUID, imgUUID, volUUID=None):
- """
- Return the chain of volumes of image as a sorted list
- (not including a shared base (template) if any)
- """
- chain = []
- volclass = sdCache.produce(sdUUID).getVolumeClass()
-
- # Use volUUID when provided
- if volUUID:
- srcVol = volclass(self.repoPath, sdUUID, imgUUID, volUUID)
-
- # For template images include only one volume (the template itself)
- # NOTE: this relies on the fact that in a template there is only
- # one volume
- if srcVol.isShared():
- return [srcVol]
-
- # Find all the volumes when volUUID is not provided
- else:
- # Find all volumes of image
- uuidlist = volclass.getImageVolumes(self.repoPath, sdUUID, imgUUID)
-
- if not uuidlist:
- raise se.ImageDoesNotExistInSD(imgUUID, sdUUID)
-
- srcVol = volclass(self.repoPath, sdUUID, imgUUID, uuidlist[0])
-
- # For template images include only one volume (the template itself)
- if len(uuidlist) == 1 and srcVol.isShared():
- return [srcVol]
-
- # Searching for the leaf
- for vol in uuidlist:
- srcVol = volclass(self.repoPath, sdUUID, imgUUID, vol)
-
- if srcVol.isLeaf():
- break
-
- srcVol = None
-
- if not srcVol:
- self.log.error("There is no leaf in the image %s", imgUUID)
- raise se.ImageIsNotLegalChain(imgUUID)
-
- # We have seen corrupted chains that cause endless loops here.
- # https://bugzilla.redhat.com/1125197
- seen = set()
-
- # Build up the sorted parent -> child chain
- while not srcVol.isShared():
- chain.insert(0, srcVol)
- seen.add(srcVol.volUUID)
-
- parentUUID = srcVol.getParentId()
- if parentUUID == volume.BLANK_UUID:
- break
-
- if parentUUID in seen:
- self.log.error("Image %s volume %s has invalid parent UUID %s",
- imgUUID, srcVol.volUUID, parentUUID)
- raise se.ImageIsNotLegalChain(imgUUID)
-
- srcVol = srcVol.produceParent()
-
- self.log.info("sdUUID=%s imgUUID=%s chain=%s ", sdUUID, imgUUID, chain)
- return chain
+ return self.manifest.getChain(sdUUID, imgUUID, volUUID)
def getTemplate(self, sdUUID, imgUUID):
"""
--
To view, visit https://gerrit.ovirt.org/44049
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iffd24be3ba74ccdea8dfc744b579c0cf63771cdb
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke(a)redhat.com>
6 years, 9 months
Change in vdsm[master]: fix: validate volumemetadata objects
by alitke@redhat.com
Adam Litke has uploaded a new change for review.
Change subject: fix: validate volumemetadata objects
......................................................................
fix: validate volumemetadata objects
Change-Id: I8330bb23c8109cee472904bde63caa75d10c0240
Signed-off-by: Adam Litke <alitke(a)redhat.com>
---
M vdsm/storage/volume.py
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/65/44565/1
diff --git a/vdsm/storage/volume.py b/vdsm/storage/volume.py
index a8211a2..d8cd3fb 100644
--- a/vdsm/storage/volume.py
+++ b/vdsm/storage/volume.py
@@ -142,6 +142,7 @@
raise se.InvalidParameterException("imgUUID", imgUUID)
if not volUUID or volUUID == BLANK_UUID:
raise se.InvalidParameterException("volUUID", volUUID)
+ self.validate()
@property
def imagePath(self):
@@ -176,7 +177,6 @@
def __init__(self, md):
self.md = md
- self.md.validate()
@property
def sdUUID(self):
--
To view, visit https://gerrit.ovirt.org/44565
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8330bb23c8109cee472904bde63caa75d10c0240
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke(a)redhat.com>
6 years, 9 months
Change in vdsm[master]: storage: Add garbage indicator to BlockSDVol namedtuple
by alitke@redhat.com
Adam Litke has uploaded a new change for review.
Change subject: storage: Add garbage indicator to BlockSDVol namedtuple
......................................................................
storage: Add garbage indicator to BlockSDVol namedtuple
Change-Id: I3e71b3d0ff7c76b815f84d895cd0cbddff251791
Signed-off-by: Adam Litke <alitke(a)redhat.com>
---
M vdsm/storage/blockSD.py
1 file changed, 27 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/68/44568/1
diff --git a/vdsm/storage/blockSD.py b/vdsm/storage/blockSD.py
index 8d571a6..77e162b 100644
--- a/vdsm/storage/blockSD.py
+++ b/vdsm/storage/blockSD.py
@@ -60,7 +60,7 @@
SPECIAL_LVS = (sd.METADATA, sd.LEASES, sd.IDS, sd.INBOX, sd.OUTBOX, MASTERLV)
MASTERLV_SIZE = "1024" # In MiB = 2 ** 20 = 1024 ** 2 => 1GiB
-BlockSDVol = namedtuple("BlockSDVol", "name, image, parent")
+BlockSDVol = namedtuple("BlockSDVol", "name, image, parent, garbage_meta_id")
log = logging.getLogger("Storage.BlockSD")
@@ -144,6 +144,24 @@
return f.tell()
+def _get_garbage_vol_meta_id(sdUUID, volUUID, tags):
+ """
+ If the LV contains TAG_VOL_GARBAGE then treat this volume as garbage. In
+ order to garbage collect the LV metadata associated with this volume we
+ need the metadata ID. We cannot call getMetadataId when the LV contains
+ TAG_VOL_UNINIT so we handle this case specially.
+ """
+ if blockVolume.TAG_VOL_GARBAGE not in tags:
+ return None
+ for tag in tags:
+ if tag.startswith(blockVolume.TAG_PREFIX_MD):
+ meta_offset = tag[len(blockVolume.TAG_PREFIX_MD):]
+ return sdUUID, meta_offset
+ log.error("missing offset tag on volume %s/%s", sdUUID, volUUID)
+ raise se.VolumeMetadataReadError("missing offset tag on volume %s/%s" %
+ (sdUUID, volUUID))
+
+
def _getVolsTree(sdUUID):
lvs = lvm.getLV(sdUUID)
vols = {}
@@ -156,7 +174,8 @@
elif tag.startswith(blockVolume.TAG_PREFIX_PARENT):
parent = tag[len(blockVolume.TAG_PREFIX_PARENT):]
if parent and image:
- vols[lv.name] = BlockSDVol(lv.name, image, parent)
+ gc_meta_id = _get_garbage_vol_meta_id(sdUUID, lv.name, lv.tags)
+ vols[lv.name] = BlockSDVol(lv.name, image, parent, gc_meta_id)
break
else:
if lv.name not in SPECIAL_LVS:
@@ -175,6 +194,12 @@
Template self image is the 1st term in template volume entry images.
"""
vols = _getVolsTree(sdUUID)
+
+ # Remove volumes awaiting garbage collection from the result
+ for vol_id in vols.iterkeys():
+ if vols[vol_id].garbage_meta_id is not None:
+ del vols[vol_id]
+
res = {}
for volName in vols.iterkeys():
res[volName] = {'imgs': [], 'parent': None}
--
To view, visit https://gerrit.ovirt.org/44568
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3e71b3d0ff7c76b815f84d895cd0cbddff251791
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke(a)redhat.com>
6 years, 9 months
Change in vdsm[master]: StorageDomainManifest: Move imageGarbageCollector
by alitke@redhat.com
Adam Litke has uploaded a new change for review.
Change subject: StorageDomainManifest: Move imageGarbageCollector
......................................................................
StorageDomainManifest: Move imageGarbageCollector
Change-Id: I6d608bed1a7add239aca3ffe96d9e9a118799511
Signed-off-by: Adam Litke <alitke(a)redhat.com>
---
M vdsm/storage/fileSD.py
M vdsm/storage/sd.py
2 files changed, 23 insertions(+), 20 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/70/44570/1
diff --git a/vdsm/storage/fileSD.py b/vdsm/storage/fileSD.py
index 2508216..2e828c3 100644
--- a/vdsm/storage/fileSD.py
+++ b/vdsm/storage/fileSD.py
@@ -325,6 +325,20 @@
return leasePath, fileVolume.LEASE_FILEOFFSET
return None, None
+ def imageGarbageCollector(self):
+ """
+ Image Garbage Collector
+ remove the remnants of the removed images (they could be left sometimes
+ (on NFS mostly) due to lazy file removal
+ """
+ removedPattern = os.path.join(self.domaindir, sd.DOMAIN_IMAGES,
+ sd.REMOVED_IMAGE_PREFIX + '*')
+ removedImages = self.oop.glob.glob(removedPattern)
+ self.log.debug("Removing remnants of deleted images %s" %
+ removedImages)
+ for imageDir in removedImages:
+ self.oop.fileUtils.cleanupdir(imageDir)
+
class FileStorageDomain(sd.StorageDomain):
manifestClass = FileStorageDomainManifest
@@ -639,20 +653,6 @@
mount.getMountFromTarget(self.mountpoint).umount()
raise se.FileStorageDomainStaleNFSHandle()
raise
-
- def imageGarbageCollector(self):
- """
- Image Garbage Collector
- remove the remnants of the removed images (they could be left sometimes
- (on NFS mostly) due to lazy file removal
- """
- removedPattern = os.path.join(self.domaindir, sd.DOMAIN_IMAGES,
- sd.REMOVED_IMAGE_PREFIX + '*')
- removedImages = self.oop.glob.glob(removedPattern)
- self.log.debug("Removing remnants of deleted images %s" %
- removedImages)
- for imageDir in removedImages:
- self.oop.fileUtils.cleanupdir(imageDir)
def templateRelink(self, imgUUID, volUUID):
"""
diff --git a/vdsm/storage/sd.py b/vdsm/storage/sd.py
index 5635e46..1ddcd45 100644
--- a/vdsm/storage/sd.py
+++ b/vdsm/storage/sd.py
@@ -470,6 +470,14 @@
if preallocate is not None and preallocate not in volume.VOL_TYPE:
raise se.IncorrectType(preallocate)
+ def imageGarbageCollector(self):
+ """
+ Image Garbage Collector
+ remove the remnants of the removed images (they could be left sometimes
+ (on NFS mostly) due to lazy file removal
+ """
+ pass
+
class StorageDomain(object):
log = logging.getLogger("Storage.StorageDomain")
@@ -964,9 +972,4 @@
return self._manifest.isData()
def imageGarbageCollector(self):
- """
- Image Garbage Collector
- remove the remnants of the removed images (they could be left sometimes
- (on NFS mostly) due to lazy file removal
- """
- pass
+ self._manifest.imageGarbageCollector()
--
To view, visit https://gerrit.ovirt.org/44570
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6d608bed1a7add239aca3ffe96d9e9a118799511
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke(a)redhat.com>
6 years, 9 months
Change in vdsm[master]: storage: block: getChildren: Do not count uninit LVs as chil...
by alitke@redhat.com
Adam Litke has uploaded a new change for review.
Change subject: storage: block: getChildren: Do not count uninit LVs as children
......................................................................
storage: block: getChildren: Do not count uninit LVs as children
Any LV with the tag TAG_VOL_UNINIT is not a real volume yet. It is
either in the process of being created or deleted. It should not appear
in the children list of its parent until the tag is removed.
Change-Id: I03e489df8478de26b01ce34f41e87aecc04512ed
Signed-off-by: Adam Litke <alitke(a)redhat.com>
---
M vdsm/storage/blockVolume.py
1 file changed, 2 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/71/44571/1
diff --git a/vdsm/storage/blockVolume.py b/vdsm/storage/blockVolume.py
index ee531f3..51f60ea 100644
--- a/vdsm/storage/blockVolume.py
+++ b/vdsm/storage/blockVolume.py
@@ -183,7 +183,8 @@
"""
lvs = lvm.lvsByTag(self.sdUUID,
"%s%s" % (TAG_PREFIX_PARENT, self.volUUID))
- return tuple(lv.name for lv in lvs)
+
+ return tuple(lv.name for lv in lvs if TAG_VOL_UNINIT not in lv.tags)
def getImage(self):
"""
--
To view, visit https://gerrit.ovirt.org/44571
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I03e489df8478de26b01ce34f41e87aecc04512ed
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke(a)redhat.com>
6 years, 9 months
Change in vdsm[master]: Garbage volumes are not part of an image
by alitke@redhat.com
Adam Litke has uploaded a new change for review.
Change subject: Garbage volumes are not part of an image
......................................................................
Garbage volumes are not part of an image
Change-Id: I8776a4b48cc8d16f420426fb28d4696b6f2bf357
Signed-off-by: Adam Litke <alitke(a)redhat.com>
---
M vdsm/storage/blockVolume.py
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/30/44830/1
diff --git a/vdsm/storage/blockVolume.py b/vdsm/storage/blockVolume.py
index 9baa3d2..af11725 100644
--- a/vdsm/storage/blockVolume.py
+++ b/vdsm/storage/blockVolume.py
@@ -334,7 +334,7 @@
(template)
"""
lvs = lvm.lvsByTag(sdUUID, "%s%s" % (TAG_PREFIX_IMAGE, imgUUID))
- return [lv.name for lv in lvs]
+ return [lv.name for lv in lvs if TAG_VOL_GARBAGE not in lv.tags]
@logskip("ResourceManager")
def llPrepare(self, rw=False, setrw=False):
--
To view, visit https://gerrit.ovirt.org/44830
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8776a4b48cc8d16f420426fb28d4696b6f2bf357
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke(a)redhat.com>
6 years, 9 months
Change in vdsm[master]: testing: Add support for failure injection
by alitke@redhat.com
Adam Litke has uploaded a new change for review.
Change subject: testing: Add support for failure injection
......................................................................
testing: Add support for failure injection
Change-Id: I30e562383fb08c4eeeeb91cca33d44a80bbff7f1
Signed-off-by: Adam Litke <alitke(a)redhat.com>
---
M vdsm/storage/misc.py
M vdsm/storage/storage_exception.py
2 files changed, 10 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/31/44831/1
diff --git a/vdsm/storage/misc.py b/vdsm/storage/misc.py
index b14fd26..c53f46d 100644
--- a/vdsm/storage/misc.py
+++ b/vdsm/storage/misc.py
@@ -1007,3 +1007,8 @@
def deprecated(f):
"""Used to mark exported methods as deprecated"""
return f
+
+
+def maybe_fail(chance=0.1):
+ if chance != 0 and random.random() <= chance:
+ raise se.InjectedFailure()
diff --git a/vdsm/storage/storage_exception.py b/vdsm/storage/storage_exception.py
index 3a4d33f..4ca0b56 100644
--- a/vdsm/storage/storage_exception.py
+++ b/vdsm/storage/storage_exception.py
@@ -1724,3 +1724,8 @@
code = 855
message = ("Could not acquire resource. "
"Probably resource factory threw an exception.")
+
+
+class InjectedFailure(GeneralException):
+ code = 999
+ message = "Injected Failure"
--
To view, visit https://gerrit.ovirt.org/44831
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I30e562383fb08c4eeeeb91cca33d44a80bbff7f1
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke(a)redhat.com>
6 years, 9 months