Hello Antoni Segura Puimedon, Francesco Romani,

I'd like you to do a code review.  Please visit

    http://gerrit.ovirt.org/31649

to review the following change.

Change subject: virt: keep on sampling before /var/run/vdsm/client.log exists
......................................................................

virt: keep on sampling before /var/run/vdsm/client.log exists

My commit 24c8e24 has introduced a serious bug: if vdsm is started
before /var/run/vdsm/client.log is created (which is the common case for
new installations), the host-sampling thread would stop when it fails to
find it.

This patch explicitly handles the case of a missing
/var/run/vdsm/client.log on the two locations that attempted to read its
time.

Change-Id: Ibb7d380882f5a93e5c75eda80598f382744b178c
Bug-Url: https://bugzilla.redhat.com/1111234
Signed-off-by: Dan Kenigsberg <[email protected]>
Reviewed-on: http://gerrit.ovirt.org/31619
Reviewed-by: Antoni Segura Puimedon <[email protected]>
Reviewed-by: Francesco Romani <[email protected]>
---
M vdsm/network/api.py
M vdsm/virt/sampling.py
2 files changed, 18 insertions(+), 5 deletions(-)


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

diff --git a/vdsm/network/api.py b/vdsm/network/api.py
index f24c9ba..0565624 100755
--- a/vdsm/network/api.py
+++ b/vdsm/network/api.py
@@ -18,6 +18,7 @@
 #
 
 from functools import wraps
+import errno
 import inspect
 import sys
 import os
@@ -446,8 +447,14 @@
 def clientSeen(timeout):
     start = time.time()
     while timeout >= 0:
-        if os.stat(constants.P_VDSM_CLIENT_LOG).st_mtime > start:
-            return True
+        try:
+            if os.stat(constants.P_VDSM_CLIENT_LOG).st_mtime > start:
+                return True
+        except OSError as e:
+            if e.errno == errno.ENOENT:
+                pass  # P_VDSM_CLIENT_LOG is not yet there
+            else:
+                raise
         time.sleep(1)
         timeout -= 1
     return False
diff --git a/vdsm/virt/sampling.py b/vdsm/virt/sampling.py
index 7e19e86..4cefc19 100644
--- a/vdsm/virt/sampling.py
+++ b/vdsm/virt/sampling.py
@@ -280,9 +280,15 @@
         self.cpuCores = CpuCoreSample()
         self.numaNodeMem = NumaNodeMemorySample()
         ENGINE_DEFAULT_POLL_INTERVAL = 15
-        self.recentClient = (
-            self.timestamp - os.stat(P_VDSM_CLIENT_LOG).st_mtime <
-            2 * ENGINE_DEFAULT_POLL_INTERVAL)
+        try:
+            self.recentClient = (
+                self.timestamp - os.stat(P_VDSM_CLIENT_LOG).st_mtime <
+                2 * ENGINE_DEFAULT_POLL_INTERVAL)
+        except OSError as e:
+            if e.errno == errno.ENOENT:
+                self.recentClient = False
+            else:
+                raise
 
     def to_connlog(self):
         text = ', '.join(


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibb7d380882f5a93e5c75eda80598f382744b178c
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Dan Kenigsberg <[email protected]>
Gerrit-Reviewer: Antoni Segura Puimedon <[email protected]>
Gerrit-Reviewer: Francesco Romani <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to