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, 7 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, 7 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, 7 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, 7 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, 7 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, 7 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, 7 months
Change in vdsm[master]: inject failures into create container
by alitke@redhat.com
Adam Litke has uploaded a new change for review.
Change subject: inject failures into create container
......................................................................
inject failures into create container
Change-Id: I1fb5f18be6434ee21ac7550fe14c166b5e82b11e
Signed-off-by: Adam Litke <alitke(a)redhat.com>
---
M vdsm/storage/sdm.py
1 file changed, 20 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/32/44832/1
diff --git a/vdsm/storage/sdm.py b/vdsm/storage/sdm.py
index 7a53e04..af4d479 100644
--- a/vdsm/storage/sdm.py
+++ b/vdsm/storage/sdm.py
@@ -31,6 +31,8 @@
from vdsm import qemuimg
+from misc import maybe_fail
+
log = logging.getLogger('sdm')
rmanager = rm.ResourceManager.getInstance()
@@ -43,40 +45,58 @@
def create_volume_container(dom_manifest, img_id, size, vol_format, disk_type,
vol_id, desc, src_img_id, src_vol_id):
+ maybe_fail(0.005)
hostId = get_domain_host_id(dom_manifest.sdUUID)
+ maybe_fail(0.02)
dom_manifest.acquireDomainLock(hostId)
imageResourcesNamespace = sd.getNamespace(dom_manifest.sdUUID,
IMAGE_NAMESPACE)
try:
+ maybe_fail(0.02)
with rmanager.acquireResource(imageResourcesNamespace, img_id,
rm.LockType.exclusive):
+ maybe_fail(0.02)
image_manifest = ImageManifest(dom_manifest.getRepoPath())
+ maybe_fail(0.02)
img_path = image_manifest.create_image_dir(dom_manifest.sdUUID,
img_id)
+ maybe_fail(0.02)
vol_parent_md = None
+ maybe_fail(0.02)
if src_vol_id != volume.BLANK_UUID:
+ maybe_fail(0.02)
# When the src_img_id isn't specified we assume it's the same
# as img_id
if src_img_id == volume.BLANK_UUID:
+ maybe_fail(0.02)
src_img_id = img_id
+ maybe_fail(0.02)
vol_parent_md = dom_manifest.produceVolume(src_img_id,
src_vol_id)
+ maybe_fail(0.02)
size = vol_parent_md.getSize()
+ maybe_fail(0.02)
dom_manifest.create_volume_artifacts(img_id, vol_id, size,
vol_format, disk_type,
desc, src_vol_id)
+ maybe_fail(0.02)
if src_vol_id != volume.BLANK_UUID:
+ maybe_fail(0.02)
_prepare_volume_for_parenthood(vol_parent_md, src_img_id,
src_vol_id, img_id, img_path)
+ maybe_fail(0.02)
# TODO: get actual size from create_volume_artifacts retval
size = volume.VolumeMetadata.adjust_new_volume_size(
dom_manifest, img_id, vol_id, size, vol_format)
+ maybe_fail(0.02)
vol_path = os.path.join(img_path, vol_id)
+ maybe_fail(0.02)
_initialize_volume_contents(img_id, vol_id, vol_path, vol_format,
size, vol_parent_md)
+ maybe_fail(0.02)
dom_manifest.commit_volume_artifacts(img_path, img_id, vol_id)
finally:
dom_manifest.releaseDomainLock()
--
To view, visit https://gerrit.ovirt.org/44832
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1fb5f18be6434ee21ac7550fe14c166b5e82b11e
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke(a)redhat.com>
6 years, 7 months
Change in vdsm[master]: blockVolume: Add classmethod helper to clear a metadata slot
by alitke@redhat.com
Adam Litke has uploaded a new change for review.
Change subject: blockVolume: Add classmethod helper to clear a metadata slot
......................................................................
blockVolume: Add classmethod helper to clear a metadata slot
Change-Id: I338f3fe5f232b1e6e7e8a2474efabcf56333e1cc
Signed-off-by: Adam Litke <alitke(a)redhat.com>
---
M vdsm/storage/blockVolume.py
1 file changed, 7 insertions(+), 6 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/33/44833/1
diff --git a/vdsm/storage/blockVolume.py b/vdsm/storage/blockVolume.py
index 79061e5..c6c3938 100644
--- a/vdsm/storage/blockVolume.py
+++ b/vdsm/storage/blockVolume.py
@@ -296,16 +296,17 @@
# tags
self.setMetaParam(volume.IMAGE, imgUUID)
- def removeMetadata(self, metaId):
- """
- Just wipe meta.
- """
+ @classmethod
+ def clearMetadataSlot(cls, metaId):
try:
- self._putMetadata(metaId, {"NONE": "#" * (sd.METASIZE - 10)})
+ cls._putMetadata(metaId, {"NONE": "#" * (sd.METASIZE - 10)})
except Exception as e:
- self.log.error(e, exc_info=True)
+ cls.log.exception(e)
raise se.VolumeMetadataWriteError("%s: %s" % (metaId, e))
+ def removeMetadata(self, metaId):
+ self.clearMetadataSlot(metaId)
+
@classmethod
def newVolumeLease(cls, metaId, sdUUID, volUUID):
cls.log.debug("Initializing volume lease volUUID=%s sdUUID=%s, "
--
To view, visit https://gerrit.ovirt.org/44833
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I338f3fe5f232b1e6e7e8a2474efabcf56333e1cc
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke(a)redhat.com>
6 years, 7 months
Change in vdsm[master]: vm: Cleaner vm stats thread initialization
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: vm: Cleaner vm stats thread initialization
......................................................................
vm: Cleaner vm stats thread initialization
The vm stats thread was initialized too late, leading to unneeded checks
and unclear try except blocks when trying to stop the thread.
This patch changes AdvancedStatsThread so it keeps a thread instance
instead of inheriting from Thread, and initialize it in Vm.__init__, so
it is always available when we access it.
Change-Id: I2917de42b76ee3dc8b27bdc23b33f3c984a7cc68
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M vdsm/virt/sampling.py
M vdsm/virt/vm.py
2 files changed, 11 insertions(+), 18 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/99/39299/1
diff --git a/vdsm/virt/sampling.py b/vdsm/virt/sampling.py
index 3206b97..848bb36 100644
--- a/vdsm/virt/sampling.py
+++ b/vdsm/virt/sampling.py
@@ -401,7 +401,7 @@
return self._samples.last()
-class AdvancedStatsThread(threading.Thread):
+class AdvancedStatsThread(object):
"""
A thread that runs the registered AdvancedStatsFunction objects
for statistic and monitoring purpose.
@@ -412,9 +412,8 @@
"""
Initialize an AdvancedStatsThread object
"""
- threading.Thread.__init__(self)
self.daemon = daemon
-
+ self._thread = None
self._log = log
self._stopEvent = threading.Event()
self._contEvent = threading.Event()
@@ -426,7 +425,7 @@
"""
Register the functions listed as arguments
"""
- if self.isAlive():
+ if self._thread is not None:
raise RuntimeError("AdvancedStatsThread is started")
for statsFunction in args:
@@ -437,7 +436,9 @@
Start the execution of the thread and exit
"""
self._log.debug("Start statistics collection")
- threading.Thread.start(self)
+ self._thread = threading.Thread(target=self._run)
+ self._thread.daemon = self.daemon
+ self._thread.start()
def stop(self):
"""
@@ -464,7 +465,7 @@
def getLastSampleTime(self):
return self._statsTime
- def run(self):
+ def _run(self):
self._log.debug("Stats thread started")
self._contEvent.set()
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 28054bf..1bc04e7 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -779,7 +779,7 @@
self._initTimeRTC = long(self.conf.get('timeOffset', 0))
self._guestEvent = vmstatus.POWERING_UP
self._guestEventTime = 0
- self._vmStats = None
+ self._vmStats = VmStatsThread(self)
self._guestCpuRunning = False
self._guestCpuLock = threading.Lock()
self._startTime = time.time() - \
@@ -1269,7 +1269,7 @@
return
toSave = self.status()
toSave['startTime'] = self._startTime
- if self.lastStatus != vmstatus.DOWN and self._vmStats:
+ if self.lastStatus != vmstatus.DOWN:
guestInfo = self.guestAgent.getGuestInfo()
toSave['username'] = guestInfo['username']
toSave['guestIPs'] = guestInfo['guestIPs']
@@ -1758,7 +1758,7 @@
decStats = {}
try:
- if self._vmStats and self._vmStats.getLastSampleTime() is not None:
+ if self._vmStats.getLastSampleTime() is not None:
decStats = self._vmStats.get()
self._setUnresponsiveIfTimeout(
stats,
@@ -2001,19 +2001,11 @@
return domxml.toxml()
def startVmStats(self):
- self._vmStats = VmStatsThread(self)
self._vmStats.start()
self._guestEventTime = self._startTime
def stopVmStats(self):
- # this is less clean that it could be, but we can get here from
- # many flows and with various locks held
- # (_releaseLock, _shutdownLock)
- # _vmStats may be None already, and we're good with that.
- try:
- self._vmStats.stop()
- except AttributeError:
- pass
+ self._vmStats.stop()
@staticmethod
def _guestSockCleanup(sock):
--
To view, visit https://gerrit.ovirt.org/39299
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2917de42b76ee3dc8b27bdc23b33f3c984a7cc68
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
6 years, 7 months