Eduardo has uploaded a new change for review.
Change subject: getVolumeInfo() new implementation. ......................................................................
getVolumeInfo() new implementation.
BC compatibility preserved but in broken behaviours.
Required to reduce the volume size functions proliferation.
Change-Id: Iedcfd84cd0848fbe3aca9f9af45c44c17722055e Signed-off-by: Eduardo ewarszaw@redhat.com --- M vdsm/storage/blockVolume.py M vdsm/storage/fileVolume.py M vdsm/storage/hsm.py M vdsm/storage/volume.py 4 files changed, 35 insertions(+), 48 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/33/18233/1
diff --git a/vdsm/storage/blockVolume.py b/vdsm/storage/blockVolume.py index 3ccb9d5..38b7930 100644 --- a/vdsm/storage/blockVolume.py +++ b/vdsm/storage/blockVolume.py @@ -618,17 +618,6 @@
getVolumeTrueSize = getVolumeSize
- def getVolumeMtime(self): - """ - Return the volume mtime in msec epoch - """ - try: - mtime = self.getMetaParam(volume.MTIME) - except se.MetaDataKeyNotFoundError: - mtime = 0 - - return mtime - def _extendSizeRaw(self, newSize): # Since this method relies on lvm.extendLV (lvextend) when the # requested size is equal or smaller than the current size, the diff --git a/vdsm/storage/fileVolume.py b/vdsm/storage/fileVolume.py index 0217859..5620500 100644 --- a/vdsm/storage/fileVolume.py +++ b/vdsm/storage/fileVolume.py @@ -541,16 +541,6 @@ volPath = self.getVolumePath() return int(int(self.oop.os.stat(volPath).st_blocks) * BLOCK_SIZE / bs)
- def getVolumeMtime(self): - """ - Return the volume mtime in msec epoch - """ - volPath = self.getVolumePath() - try: - return self.getMetaParam(volume.MTIME) - except se.MetaDataKeyNotFoundError: - return self.oop.os.stat(volPath).st_mtime - def _extendSizeRaw(self, newSize): volPath = self.getVolumePath() curSizeBytes = self.oop.os.stat(volPath).st_size diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py index 8a6612a..2d9f224 100644 --- a/vdsm/storage/hsm.py +++ b/vdsm/storage/hsm.py @@ -3070,10 +3070,25 @@ :rtype: dict """ vars.task.getSharedLock(STORAGE, sdUUID) - info = sdCache.produce( - sdUUID=sdUUID).produceVolume(imgUUID=imgUUID, - volUUID=volUUID).getInfo() - return dict(info=info) + dom = sdCache.produce(sdUUID=sdUUID) + info = dom.produceVolume(imgUUID, volUUID).getInfo() + + # Get the backing-volume size on disk + try: + info['apparentsize'] = str(dom.getVSize(imgUUID, volUUID, bs=1)) + info['truesize'] = str(dom.getVTrueSize(imgUUID, volUUID,bs=1)) + except (OSError, IOError, se.LogicalVolumeDoesNotExistError): + self.log.error("Can't determine volume %s %s %s size", + sdUUID, imgUUID, volUUID, exc_info=True) + info['apparentsize'] = "0" + info['truesize'] = "0" + info['status'] = "INVALID" + + # Both engine and dumpStorageTable don't use this option so + # only keeping it to not break existing scripts that look for the key + info['children'] = [] + + return dict(info=info)
@public def getVolumePath(self, sdUUID, spUUID, imgUUID, volUUID, options=None): diff --git a/vdsm/storage/volume.py b/vdsm/storage/volume.py index a49c4de..81b7e03 100644 --- a/vdsm/storage/volume.py +++ b/vdsm/storage/volume.py @@ -884,33 +884,26 @@ """ self.log.info("Info request: sdUUID=%s imgUUID=%s volUUID = %s ", self.sdUUID, self.imgUUID, self.volUUID) - image_corrupted = False - info = {} try: meta = self.getMetadata() - info = self.metadata2info(meta) - info["capacity"] = str(int(info["size"]) * BLOCK_SIZE) - del info["size"] - # Get the image actual size on disk - vsize = self.getVolumeSize(bs=1) - avsize = self.getVolumeTrueSize(bs=1) - info['apparentsize'] = str(vsize) - info['truesize'] = str(avsize) - info['mtime'] = self.getVolumeMtime() - info['status'] = "OK" - except se.StorageException as e: - self.log.debug("exception: %s:%s" % (str(e.message), str(e.value))) - info['apparentsize'] = "0" - info['truesize'] = "0" - info['mtime'] = "0" + except se.VolumeMetadataReadError: + self.log.error("Read MD failed for volume %s %s %s", self.sdUUID, + self.imgUUID, self.volUUID, exc_info=True) + info = self.metadata2info({}) info['status'] = "INVALID" + else: + info = self.metadata2info(meta) + info["capacity"] = str(int(info["size"]) * BLOCK_SIZE) # Virtual + del info["size"] # Remove the virtual (by volMD) size [blocks] + if info['mtime'] == "" and self.__class__.__name__ == "FileVolume": + info ['mtime'] = self.oop.os.stat(volPath).st_mtime + # If image was set to illegal, mark the status same + # (because of VDC constraints) + if info['legality'] == ILLEGAL_VOL: + info['status'] = ILLEGAL_VOL + else: + info['status'] = "OK"
- info['children'] = self.getChildrenList() - - # If image was set to illegal, mark the status same - # (because of VDC constraints) - if info.get('legality', None) == ILLEGAL_VOL or image_corrupted: - info['status'] = ILLEGAL_VOL self.log.info("%s/%s/%s info is %s", self.sdUUID, self.imgUUID, self.volUUID, str(info)) return info
oVirt Jenkins CI Server has posted comments on this change.
Change subject: getVolumeInfo() new implementation. ......................................................................
Patch Set 1: Code-Review-1 Verified-1
Build Failed
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/3991/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/3908/ : UNSTABLE
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/3102/ : FAILURE
oVirt Jenkins CI Server has posted comments on this change.
Change subject: getVolumeInfo() new implementation. ......................................................................
Patch Set 2: Code-Review-1 Verified-1
Build Failed
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/4203/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/3308/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/4124/ : UNSTABLE
oVirt Jenkins CI Server has posted comments on this change.
Change subject: getVolumeInfo() new implementation. ......................................................................
Patch Set 3: Verified-1
Build Failed
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/4456/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/3559/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/4375/ : SUCCESS
Ayal Baron has posted comments on this change.
Change subject: getVolumeInfo() new implementation. ......................................................................
Patch Set 3: Code-Review-1
(2 comments)
.................................................... Commit Message Line 5: CommitDate: 2013-09-16 04:46:09 +0300 Line 6: Line 7: getVolumeInfo() new implementation. Line 8: Line 9: BC compatibility preserved but in broken behaviours. I don't understand the meaning of this sentence Line 10: Line 11: Required to reduce the volume size functions proliferation. Line 12: Line 13: Change-Id: Iedcfd84cd0848fbe3aca9f9af45c44c17722055e
.................................................... File vdsm/storage/volume.py Line 895: else: Line 896: info = self.metadata2info(meta) Line 897: info["capacity"] = str(int(info["size"]) * BLOCK_SIZE) # Virtual Line 898: del info["size"] # Remove the virtual (by volMD) size [blocks] Line 899: if info['mtime'] == "" and self.__class__.__name__ == "FileVolume": move this into getMetadata (i.e. include mtime in the returned dictionary) Line 900: info['mtime'] = self.oop.os.stat(self.volumePath).st_mtime Line 901: # If image was set to illegal, mark the status same Line 902: # (because of VDC constraints) Line 903: if info['legality'] == ILLEGAL_VOL:
Eduardo has posted comments on this change.
Change subject: getVolumeInfo() new implementation. ......................................................................
Patch Set 3:
(2 comments)
.................................................... Commit Message Line 5: CommitDate: 2013-09-16 04:46:09 +0300 Line 6: Line 7: getVolumeInfo() new implementation. Line 8: Line 9: BC compatibility preserved but in broken behaviours. The former semantic was incosistent but preserved.
Logical impossibilities were removed if it was possible. Line 10: Line 11: Required to reduce the volume size functions proliferation. Line 12: Line 13: Change-Id: Iedcfd84cd0848fbe3aca9f9af45c44c17722055e
.................................................... File vdsm/storage/volume.py Line 895: else: Line 896: info = self.metadata2info(meta) Line 897: info["capacity"] = str(int(info["size"]) * BLOCK_SIZE) # Virtual Line 898: del info["size"] # Remove the virtual (by volMD) size [blocks] Line 899: if info['mtime'] == "" and self.__class__.__name__ == "FileVolume": They are operating on different files. Therefore we should not unify.
Unfortunately this info dict is created only here and mix information of multiple sources and is created only here. Line 900: info['mtime'] = self.oop.os.stat(self.volumePath).st_mtime Line 901: # If image was set to illegal, mark the status same Line 902: # (because of VDC constraints) Line 903: if info['legality'] == ILLEGAL_VOL:
Eduardo has posted comments on this change.
Change subject: getVolumeInfo() new implementation. ......................................................................
Patch Set 3: Verified+1
* Verified for block volumes *
# vdsClient -s 0 getConnectedStoragePoolsList
# vdsClient -s 0 getVolumeInfo d0dccb15-bc4e-4815-889a-c116028f30b0 00000000-0000-0000-0000-000000000000 95aa8eec-32bb-42e8-8853-f4e094a1060a 5416128c-7bf6-4917-90de-05588bdd1712 status = OK domain = d0dccb15-bc4e-4815-889a-c116028f30b0 capacity = 4294967296 voltype = LEAF description = parent = 6301335b-9444-4f49-a817-cfc5ef0879a4 format = COW image = 95aa8eec-32bb-42e8-8853-f4e094a1060a uuid = 5416128c-7bf6-4917-90de-05588bdd1712 disktype = 2 legality = LEGAL mtime = 1380810703 apparentsize = 1073741824 truesize = 1073741824 type = SPARSE children = [] pool = ctime = 1380810703
# vdsClient -s 0 getVolumeInfo d0dccb15-bc4e-4815-889a-c116028f30b0 00000000-0000-0000-0000-000000000000 79f93e4e-6b22-4b8a-9567-ea9b6b3093ff b48ba89a-6b90-41c5-b73d-9e7c2e313a51 status = OK domain = d0dccb15-bc4e-4815-889a-c116028f30b0 capacity = 5368709120 voltype = LEAF description = t_child_1 parent = d979e09c-0a7b-47fb-8235-d2872928ef04 format = COW image = 79f93e4e-6b22-4b8a-9567-ea9b6b3093ff uuid = b48ba89a-6b90-41c5-b73d-9e7c2e313a51 disktype = 0 legality = LEGAL mtime = 1381262616 apparentsize = 1073741824 truesize = 1073741824 type = SPARSE children = [] pool = ctime = 1381262616
# vdsClient -s 0 getVolumeInfo d0dccb15-bc4e-4815-889a-c116028f30b0 00000000-0000-0000-0000-000000000000 f8ca3be1-3aad-4785-a938-2b29bb499a40 d979e09c-0a7b-47fb-8235-d2872928ef04 status = OK domain = d0dccb15-bc4e-4815-889a-c116028f30b0 capacity = 5368709120 voltype = SHARED description = Active VM parent = 00000000-0000-0000-0000-000000000000 format = COW image = f8ca3be1-3aad-4785-a938-2b29bb499a40 uuid = d979e09c-0a7b-47fb-8235-d2872928ef04 disktype = 2 legality = LEGAL mtime = 1380800450 apparentsize = 2147483648 truesize = 2147483648 type = SPARSE children = [] pool = ctime = 1380800444
Eduardo has posted comments on this change.
Change subject: getVolumeInfo() new implementation. ......................................................................
Patch Set 4: Verified+1
# vdsClient -s 0 getVolumeInfo d0dccb15-bc4e-4815-889a-c116028f30b0 00000000-0000-0000-0000-000000000000 95aa8eec-32bb-42e8-8853-f4e094a1060a 5416128c-7bf6-4917-90de-05588bdd1712 status = OK domain = d0dccb15-bc4e-4815-889a-c116028f30b0 capacity = 4294967296 voltype = LEAF description = parent = 6301335b-9444-4f49-a817-cfc5ef0879a4 format = COW image = 95aa8eec-32bb-42e8-8853-f4e094a1060a uuid = 5416128c-7bf6-4917-90de-05588bdd1712 disktype = 2 legality = LEGAL mtime = 1380810703 apparentsize = 1073741824 truesize = 1073741824 type = SPARSE children = [] pool = ctime = 1380810703
# vdsClient -s 0 getConnectedStoragePoolsList
[root@localhost ~]# vdsClient -s 0 getVolumeInfo d0dccb15-bc4e-4815-889a-c116028f30b0 00000000-0000-0000-0000-000000000000 79f93e4e-6b22-4b8a-9567-ea9b6b3093ff b48ba89a-6b90-41c5-b73d-9e7c2e313a51 status = OK domain = d0dccb15-bc4e-4815-889a-c116028f30b0 capacity = 5368709120 voltype = LEAF description = t_child_1 parent = d979e09c-0a7b-47fb-8235-d2872928ef04 format = COW image = 79f93e4e-6b22-4b8a-9567-ea9b6b3093ff uuid = b48ba89a-6b90-41c5-b73d-9e7c2e313a51 disktype = 0 legality = LEGAL mtime = 1381262616 apparentsize = 1073741824 truesize = 1073741824 type = SPARSE children = [] pool = ctime = 1381262616
# vdsClient -s 0 getVolumeInfo d0dccb15-bc4e-4815-889a-c116028f30b0 00000000-0000-0000-0000-000000000000 f8ca3be1-3aad-4785-a938-2b29bb499a40 d979e09c-0a7b-47fb-8235-d2872928ef04 status = OK domain = d0dccb15-bc4e-4815-889a-c116028f30b0 capacity = 5368709120 voltype = SHARED description = Active VM parent = 00000000-0000-0000-0000-000000000000 format = COW image = f8ca3be1-3aad-4785-a938-2b29bb499a40 uuid = d979e09c-0a7b-47fb-8235-d2872928ef04 disktype = 2 legality = LEGAL mtime = 1380800450 apparentsize = 2147483648 truesize = 2147483648 type = SPARSE children = [] pool = ctime = 1380800444
Eduardo has posted comments on this change.
Change subject: getVolumeInfo() new implementation. ......................................................................
Patch Set 5: Verified+1
As before.
oVirt Jenkins CI Server has posted comments on this change.
Change subject: getVolumeInfo() new implementation. ......................................................................
Patch Set 4: Verified-1
Build Failed
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/5015/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/4128/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/4938/ : SUCCESS
oVirt Jenkins CI Server has posted comments on this change.
Change subject: getVolumeInfo() new implementation. ......................................................................
Patch Set 6: Verified-1
Build Failed
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/5002/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/4198/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/5076/ : FAILURE
oVirt Jenkins CI Server has posted comments on this change.
Change subject: getVolumeInfo() new implementation. ......................................................................
Patch Set 7: Verified-1
Build Failed
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/5012/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/4208/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/5086/ : FAILURE
Dan Kenigsberg has posted comments on this change.
Change subject: getVolumeInfo() new implementation. ......................................................................
Patch Set 7:
(1 comment)
.................................................... File vdsm/storage/volume.py Line 894: else: Line 895: info = self.metadata2info(meta) Line 896: info["capacity"] = str(int(info["size"]) * BLOCK_SIZE) # Virtual Line 897: del info["size"] # Remove the virtual (by volMD) size [blocks] Line 898: if info['mtime'] == "" and self.__class__.__name__ == "FileVolume": This breaks for GlusterVolume that inherits from FileVolume. I'd rather you fix FileVolume.getVolumeMtime() instead of in-lining it, possibly raising NotImplemented in BlockVolume.getVolumeMtime(). Line 899: info['mtime'] = self.oop.os.stat(self.volumePath).st_mtime Line 900: # If image was set to illegal, mark the status same Line 901: # (because of VDC constraints) Line 902: if info['legality'] == ILLEGAL_VOL:
Dan Kenigsberg has posted comments on this change.
Change subject: getVolumeInfo() new implementation. ......................................................................
Patch Set 7: Code-Review-1
please rebase on master to avoid
AttributeError: 'FileDomainMockObject' object has no attribute 'getVSize'
Eduardo has posted comments on this change.
Change subject: getVolumeInfo() new implementation. ......................................................................
Patch Set 7:
(1 comment)
.................................................... File vdsm/storage/volume.py Line 894: else: Line 895: info = self.metadata2info(meta) Line 896: info["capacity"] = str(int(info["size"]) * BLOCK_SIZE) # Virtual Line 897: del info["size"] # Remove the virtual (by volMD) size [blocks] Line 898: if info['mtime'] == "" and self.__class__.__name__ == "FileVolume": Already discussed by phone. Line 899: info['mtime'] = self.oop.os.stat(self.volumePath).st_mtime Line 900: # If image was set to illegal, mark the status same Line 901: # (because of VDC constraints) Line 902: if info['legality'] == ILLEGAL_VOL:
oVirt Jenkins CI Server has posted comments on this change.
Change subject: getVolumeInfo() new implementation. ......................................................................
Patch Set 8:
Build Successful
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/4375/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/5179/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/5255/ : SUCCESS
Itamar Heim has abandoned this change.
Change subject: getVolumeInfo() new implementation. ......................................................................
Abandoned
old. not touched for a while. please restore if relevant
vdsm-patches@lists.fedorahosted.org