Change in vdsm[ovirt-3.6]: periodic: add __str__ methods

fromani at redhat.com fromani at redhat.com
Wed Nov 25 08:52:05 UTC 2015


Hello Dan Kenigsberg, Milan Zamazal,

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

    https://gerrit.ovirt.org/49143

to review the following change.

Change subject: periodic: add __str__ methods
......................................................................

periodic: add __str__ methods

We want to make as easy as possible to debug
thread leaks from executor, so we make the periodic
framework support provide meaningful str() representation,
to be used by Executor.

Backport notice:
add to set new change-id to avoid weird error
  remote: Processing changes: refs: 1, done
  To gerrit.ovirt.org:vdsm
   ! [remote rejected] HEAD -> refs/for/ovirt-3.6 (change 48416 closed)
  error: failed to push some refs to 'gerrit.ovirt.org:vdsm'

Change-Id: Id0a0be2704f4b46093cd02406644121fc3c5fa5b
Original-Change-Id: If8d1180b727571cce34e8304ac48390ed2135f79
Bug-Url: https://bugzilla.redhat.com/1250839
Backport-To: 3.6
Signed-off-by: Francesco Romani <fromani at redhat.com>
Reviewed-on: https://gerrit.ovirt.org/48193
Reviewed-by: Milan Zamazal <mzamazal at redhat.com>
Continuous-Integration: Jenkins CI
Reviewed-by: Dan Kenigsberg <danken at redhat.com>
---
M vdsm/virt/periodic.py
M vdsm/virt/sampling.py
2 files changed, 20 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/43/49143/1

diff --git a/vdsm/virt/periodic.py b/vdsm/virt/periodic.py
index 632f0ce..4d64522 100644
--- a/vdsm/virt/periodic.py
+++ b/vdsm/virt/periodic.py
@@ -194,6 +194,11 @@
         self._executor.dispatch(self, self._timeout)
         self._step()
 
+    def __str__(self):
+        return '<Operation action=%s at 0x%x>' % (
+            self._func, id(self)
+        )
+
 
 class VmDispatcher(object):
     """
@@ -241,8 +246,7 @@
 
             except Exception:
                 # we want to make sure to have VM UUID logged
-                self._log.exception("while dispatching %s to VM '%s'",
-                                    self._create, vm_id)
+                self._log.exception("while dispatching %s", op)
             else:
                 try:
                     self._executor.dispatch(op, self._timeout)
@@ -254,8 +258,12 @@
                               self._create, skipped)
         return skipped  # for testing purposes
 
-    def __repr__(self):
-        return 'VmDispatcher(%s)' % self._create
+    def __str__(self):
+        return '<VmDispatcher operation=%s at 0x%x>' % (
+            self._create, id(self)
+        )
+
+    __repr__ = __str__
 
 
 class _RunnableOnVm(object):
@@ -279,6 +287,11 @@
     def _execute(self):
         raise NotImplementedError
 
+    def __str__(self):
+        return '<%s vm=%s at 0x%x>' % (
+            self.__class__.__name__, self._vm.id, id(self)
+        )
+
 
 class UpdateVolumes(_RunnableOnVm):
 
diff --git a/vdsm/virt/sampling.py b/vdsm/virt/sampling.py
index fac10d1..63192a2 100644
--- a/vdsm/virt/sampling.py
+++ b/vdsm/virt/sampling.py
@@ -558,6 +558,9 @@
                 doms.append(vm_obj._dom._dom)
         return doms
 
+    def __str__(self):
+        return "<VMBulkSampler at 0x%x>" % id(self)
+
 
 class HostStatsThread(threading.Thread):
     """


-- 
To view, visit https://gerrit.ovirt.org/49143
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id0a0be2704f4b46093cd02406644121fc3c5fa5b
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.6
Gerrit-Owner: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Milan Zamazal <mzamazal at redhat.com>


More information about the vdsm-patches mailing list