Adam Litke has uploaded a new change for review.
Change subject: storage: export volume lease state in getVolumeInfo
......................................................................
storage: export volume lease state in getVolumeInfo
In order to support an entity-based polling methodology (ie. in the new
SDM verbs) we must know whether a volume is currently locked by a long
running operation. Extend the getVolumeInfo API to report whether the
lease is free or held.
Change-Id: I55f062a4be15593fdc98518fd0a113976cbe0ae7
Signed-off-by: Adam Litke <alitke(a)redhat.com>
---
M vdsm/rpc/vdsmapi-schema.json
M vdsm/storage/volume.py
2 files changed, 31 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/23/38623/1
diff --git a/vdsm/rpc/vdsmapi-schema.json b/vdsm/rpc/vdsmapi-schema.json
index 988ce64..cba1008 100644
--- a/vdsm/rpc/vdsmapi-schema.json
+++ b/vdsm/rpc/vdsmapi-schema.json
@@ -7897,6 +7897,19 @@
{'enum': 'VolumeStatus', 'data': ['OK',
'INVALID', 'ILLEGAL']}
##
+# @VolumeLeaseState:
+#
+# An enumeration of Volume lease states.
+#
+# @FREE: The lease is free
+#
+# @HELD: The lease is held
+#
+# Since: 4.10.0
+##
+{'enum': 'VolumeLeaseState', 'data': ['FREE',
'HELD']}
+
+##
# @VolumeInfo:
#
# Information about a Volume.
@@ -7937,6 +7950,8 @@
#
# @children: A list of decendent Volumes that depend on this Volume
#
+# @leaseState: #optional The state of the volume lease
+#
# Since: 4.10.0
##
{'type': 'VolumeInfo',
@@ -7946,7 +7961,8 @@
'description': 'str', 'pool': 'UUID',
'domain': 'UUID',
'image': 'UUID', 'ctime': 'int',
'*mtime': 'uint',
'legality': 'VolumeLegality', 'apparentsize':
'uint',
- 'truesize': 'uint', 'status': 'VolumeStatus',
'children': ['UUID']}}
+ 'truesize': 'uint', 'status': 'VolumeStatus',
'children': ['UUID'],
+ '*leaseState': 'VolumeLeaseState'}}
##
# @Volume.getInfo:
diff --git a/vdsm/storage/volume.py b/vdsm/storage/volume.py
index 980b6e3..2e16efc 100644
--- a/vdsm/storage/volume.py
+++ b/vdsm/storage/volume.py
@@ -33,6 +33,7 @@
import fileUtils
import task
from threadLocal import vars
+from clusterlock import InquireNotSupportedError
import resourceFactories
import resourceManager as rm
rmanager = rm.ResourceManager.getInstance()
@@ -85,6 +86,10 @@
ILLEGAL_VOL = "ILLEGAL"
LEGAL_VOL = "LEGAL"
FAKE_VOL = "FAKE"
+
+# Volume lease states
+LEASE_FREE = "FREE"
+LEASE_HELD = "HELD"
log = logging.getLogger('Storage.Volume')
@@ -839,6 +844,11 @@
cls.createMetadata(metaId, meta)
return meta
+ def getLeaseState(self):
+ ver, owners = sdCache.produce(self.sdUUID).inquireVolumeLease(
+ self.imgUUID, self.volUUID)
+ return LEASE_HELD if owners else LEASE_FREE
+
def getInfo(self):
"""
Get volume info
@@ -857,6 +867,10 @@
info['apparentsize'] = str(vsize)
info['truesize'] = str(avsize)
info['status'] = "OK"
+ try:
+ info['leaseState'] = self.getLeaseState()
+ except InquireNotSupportedError:
+ pass
except se.StorageException as e:
self.log.debug("exception: %s:%s" % (str(e.message),
str(e.value)))
info['apparentsize'] = "0"
--
To view, visit
https://gerrit.ovirt.org/38623
To unsubscribe, visit
https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I55f062a4be15593fdc98518fd0a113976cbe0ae7
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke(a)redhat.com>