Change in vdsm[master]: monitor: Convert valid to read-only property
nsoffer at redhat.com
nsoffer at redhat.com
Tue Mar 24 12:06:07 UTC 2015
Nir Soffer has uploaded a new change for review.
Change subject: monitor: Convert valid to read-only property
......................................................................
monitor: Convert valid to read-only property
Status.valid was a duplicate of Status.error. This could lead to
inconsistent state if one of the attributes is not synced with the
other. Now valid is a property based on Status.error.
Change-Id: Iff27081041bbaa1e319539df67abb31f38367e7d
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
---
M tests/storageMonitorTests.py
M vdsm/storage/monitor.py
2 files changed, 20 insertions(+), 3 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/88/39088/1
diff --git a/tests/storageMonitorTests.py b/tests/storageMonitorTests.py
index bbd152f..9518239 100644
--- a/tests/storageMonitorTests.py
+++ b/tests/storageMonitorTests.py
@@ -41,3 +41,18 @@
def test_deleting_attribute_raises(self):
for name in self.status.__slots__:
self.assertRaises(AssertionError, delattr, self.frozen, name)
+
+ def test_valid(self):
+ self.assertTrue(self.frozen.valid)
+
+
+class StatusValidTests(VdsmTestCase):
+
+ def test_valid(self):
+ s = monitor.Status()
+ self.assertTrue(s.valid)
+
+ def test_invalid(self):
+ s = monitor.Status()
+ s.error = Exception()
+ self.assertFalse(s.valid)
diff --git a/vdsm/storage/monitor.py b/vdsm/storage/monitor.py
index 053897b..6aea29b 100644
--- a/vdsm/storage/monitor.py
+++ b/vdsm/storage/monitor.py
@@ -33,7 +33,7 @@
class Status(object):
__slots__ = (
- "error", "checkTime", "valid", "readDelay", "masterMounted",
+ "error", "checkTime", "readDelay", "masterMounted",
"masterValid", "diskUtilization", "vgMdUtilization",
"vgMdHasEnoughFreeSpace", "vgMdFreeBelowThreashold", "hasHostId",
"isoPrefix", "version", "actual",
@@ -43,7 +43,6 @@
self.actual = actual
self.error = None
self.checkTime = time.time()
- self.valid = True
self.readDelay = 0
self.diskUtilization = (None, None)
self.masterMounted = False
@@ -61,6 +60,10 @@
# report its prefix (it might be unreachable).
self.isoPrefix = None
self.version = -1
+
+ @property
+ def valid(self):
+ return self.error is None
class FrozenStatus(Status):
@@ -250,7 +253,6 @@
nextStatus.error = e
nextStatus.checkTime = time.time()
- nextStatus.valid = (nextStatus.error is None)
if self._statusDidChange(nextStatus):
self._notifyStatusChanges(nextStatus)
--
To view, visit https://gerrit.ovirt.org/39088
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iff27081041bbaa1e319539df67abb31f38367e7d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer at redhat.com>
More information about the vdsm-patches
mailing list