Nir Soffer has uploaded a new change for review.

Change subject: domainMonitor: notify on the first status check
......................................................................

domainMonitor: notify on the first status check

Domain monitor thread was not reporting when going from unknown state to
known state. The thread would start with a bogus valid state, before
checking the domain. If the first domain check found the domain as
valid, no notification was emitted. If there were paused vms while
connecting to the pool, they were not unpaused as they should.

This patch initialize lastCheck to invalid value, marking the status as
not checked yet. The monitor thread use this special value to detect the
first sample, and emit the missing notification.

To get the new event when monitor thread start, domain state change
callbacks passed now to StoragePool.connect(), and registered with the
domainMonitor before the monitor thread is started.

Change-Id: I56c468edb967de5bcf15259029ace84333fc4b7e
Bug-Url: https://bugzilla.redhat.com/1003588
Signed-off-by: Nir Soffer <nsof...@redhat.com>
---
M vdsm/storage/domainMonitor.py
M vdsm/storage/hsm.py
M vdsm/storage/sp.py
3 files changed, 16 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/49/21649/1

diff --git a/vdsm/storage/domainMonitor.py b/vdsm/storage/domainMonitor.py
index 4f4b823..8ccb88b 100644
--- a/vdsm/storage/domainMonitor.py
+++ b/vdsm/storage/domainMonitor.py
@@ -27,6 +27,8 @@
 from vdsm.config import config
 from sdc import sdCache
 
+NOT_CHECKED_YET = 0
+
 
 class DomainMonitorStatus(object):
     __slots__ = (
@@ -41,7 +43,7 @@
 
     def clear(self):
         self.error = None
-        self.lastCheck = time()
+        self.lastCheck = NOT_CHECKED_YET
         self.valid = True
         self.readDelay = 0
         self.diskUtilization = (None, None)
@@ -236,10 +238,9 @@
         self.nextStatus.lastCheck = time()
         self.nextStatus.valid = (self.nextStatus.error is None)
 
-        if self.status.valid != self.nextStatus.valid:
+        if self._statusDidChange():
             self.log.debug("Domain %s changed its status to %s", self.sdUUID,
                            "Valid" if self.nextStatus.valid else "Invalid")
-
             try:
                 self.domainMonitor.onDomainStateChange.emit(
                     self.sdUUID, self.nextStatus.valid)
@@ -258,3 +259,7 @@
                                self.sdUUID, exc_info=True)
 
         self.status.update(self.nextStatus)
+
+    def _statusDidChange(self):
+        return (self.status.lastCheck == NOT_CHECKED_YET or
+                self.status.valid != self.nextStatus.valid)
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 73f9f43..caa8b4c 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -1058,12 +1058,10 @@
             pool = sp.StoragePool(spUUID, self.domainMonitor, self.taskMng)
             if not hostID or not scsiKey or not msdUUID or not masterVersion:
                 hostID, scsiKey, msdUUID, masterVersion = pool.getPoolParams()
-            res = pool.connect(hostID, scsiKey, msdUUID, masterVersion)
+            res = pool.connect(hostID, scsiKey, msdUUID, masterVersion,
+                               tuple(self.domainStateChangeCallbacks))
             if res:
                 self.pools[spUUID] = pool
-                for callback in self.domainStateChangeCallbacks:
-                    self.pools[spUUID].domainMonitor.\
-                        onDomainStateChange.register(callback)
             return res
 
     @public
diff --git a/vdsm/storage/sp.py b/vdsm/storage/sp.py
index 0e23e1d..0d78459 100644
--- a/vdsm/storage/sp.py
+++ b/vdsm/storage/sp.py
@@ -666,7 +666,7 @@
             f.writelines(pers)
 
     @unsecured
-    def connect(self, hostID, scsiKey, msdUUID, masterVersion):
+    def connect(self, hostID, scsiKey, msdUUID, masterVersion, callbacks=()):
         """
         Connect a Host to a specific storage pool.
 
@@ -692,6 +692,11 @@
         # Make sure SDCache doesn't have stale data (it can be in case of FC)
         sdCache.invalidateStorage()
         sdCache.refresh()
+        # Must register domain state change callbacks *before* rebuilding the
+        # pool, which starts domain monitor threads. Otherwise we will miss the
+        # first event from the monitor thread.
+        for cb in callbacks:
+            self.domainMonitor.onDomainStateChange.register(cb)
         # Rebuild whole Pool
         self.__rebuild(msdUUID=msdUUID, masterVersion=masterVersion)
         self.__createMailboxMonitor()


-- 
To view, visit http://gerrit.ovirt.org/21649
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I56c468edb967de5bcf15259029ace84333fc4b7e
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsof...@redhat.com>
_______________________________________________
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to