Nir Soffer has uploaded a new change for review. Change subject: domainMonitor: Fix unsafe iteration of domain monitor status ......................................................................
domainMonitor: Fix unsafe iteration of domain monitor status When we generate repoStat response, we used to iterate over the monitored domains, getting the status for each monitor. This naïve approach does not consider that a monitor may be removed from the domain monitor dict during the iteration. Since the only usage now is getting the status for all domains, I changed getStatus to return an iterator returning all domains status in a safe manner. Change-Id: I083c4b1925ee529c0993a291cad6076539d4ea66 Signed-off-by: Nir Soffer <[email protected]> --- M vdsm/storage/domainMonitor.py M vdsm/storage/hsm.py 2 files changed, 4 insertions(+), 5 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/09/29009/1 diff --git a/vdsm/storage/domainMonitor.py b/vdsm/storage/domainMonitor.py index 8a50b4f..c8207d9 100644 --- a/vdsm/storage/domainMonitor.py +++ b/vdsm/storage/domainMonitor.py @@ -118,8 +118,9 @@ del self._domains[sdUUID] - def getStatus(self, sdUUID): - return self._domains[sdUUID].getStatus() + def getMonitoredDomainsStatus(self): + for sdUUID, monitor in self._domains.items(): + yield sdUUID, monitor.getStatus() def close(self): self.log.info("Stopping domain monitors") diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py index cc2d8a0..f0c3afb 100644 --- a/vdsm/storage/hsm.py +++ b/vdsm/storage/hsm.py @@ -3538,9 +3538,7 @@ repoStats = {} statsGenTime = time.time() - for sdUUID in domainMonitor.monitoredDomains: - domStatus = domainMonitor.getStatus(sdUUID) - + for sdUUID, domStatus in domainMonitor.getMonitoredDomainsStatus(): if domStatus.error is None: code = 0 elif isinstance(domStatus.error, se.StorageException): -- To view, visit http://gerrit.ovirt.org/29009 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I083c4b1925ee529c0993a291cad6076539d4ea66 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
