Change in vdsm[ovirt-3.3]: Move zombieReaper to its own package
ybronhei at redhat.com
ybronhei at redhat.com
Mon Jan 13 12:52:06 UTC 2014
Hello Saggi Mizrahi, Dan Kenigsberg,
I'd like you to do a code review. Please visit
http://gerrit.ovirt.org/23213
to review the following change.
Change subject: Move zombieReaper to its own package
......................................................................
Move zombieReaper to its own package
It is not vdsm specific so it's a prime candidate for extraction.
Change-Id: I58e9c834820d98fb3dcffdf06bfc05eb68ea6827
Signed-off-by: Saggi Mizrahi <smizrahi at redhat.com>
Reviewed-on: http://gerrit.ovirt.org/19253
Reviewed-by: Dan Kenigsberg <danken at redhat.com>
Tested-by: Dan Kenigsberg <danken at redhat.com>
---
M configure.ac
M lib/Makefile.am
A lib/zombiereaper/Makefile.am
R lib/zombiereaper/__init__.py
R lib/zombiereaper/tests.py
M tests/Makefile.am
M tests/testrunner.py
M vdsm.spec.in
M vdsm/Makefile.am
M vdsm/storage/remoteFileHandler.py
M vdsm/vdsm
11 files changed, 63 insertions(+), 16 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/13/23213/1
diff --git a/configure.ac b/configure.ac
index 52105e9..8748af1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -258,6 +258,7 @@
lib/vdsm/Makefile
lib/vdsm/tool/Makefile
lib/yajsonrpc/Makefile
+ lib/zombiereaper/Makefile
tests/Makefile
tests/functional/Makefile
vds_bootstrap/Makefile
diff --git a/lib/Makefile.am b/lib/Makefile.am
index b1a1a12..77414eb 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -19,4 +19,4 @@
#
include $(top_srcdir)/build-aux/Makefile.subs
-SUBDIRS = vdsm cpopen yajsonrpc
+SUBDIRS = vdsm cpopen yajsonrpc zombiereaper
diff --git a/lib/zombiereaper/Makefile.am b/lib/zombiereaper/Makefile.am
new file mode 100644
index 0000000..ec01a0d
--- /dev/null
+++ b/lib/zombiereaper/Makefile.am
@@ -0,0 +1,32 @@
+#
+# Copyright 2008-2011 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+
+zombiereaperdir = $(pythondir)/zombiereaper
+
+dist_zombiereaper_PYTHON = \
+ __init__.py \
+ $(NULL)
+
+dist_noinst_PYTHON = \
+ tests.py \
+ $(NULL)
+
+check-local:
+ nosetests tests.py
diff --git a/vdsm/zombieReaper.py b/lib/zombiereaper/__init__.py
similarity index 100%
rename from vdsm/zombieReaper.py
rename to lib/zombiereaper/__init__.py
diff --git a/tests/zombieReaperTests.py b/lib/zombiereaper/tests.py
similarity index 86%
rename from tests/zombieReaperTests.py
rename to lib/zombiereaper/tests.py
index ff5c641..3a85a11 100644
--- a/tests/zombieReaperTests.py
+++ b/lib/zombiereaper/tests.py
@@ -20,15 +20,18 @@
from time import sleep
import os
-from testrunner import VdsmTestCase as TestCaseBase
-import zombieReaper
+import zombiereaper
from cpopen import CPopen as BetterPopen
+from unittest import TestCase
-class zombieReaperTests(TestCaseBase):
+zombiereaper.registerSignalHandler()
+
+
+class zombieReaperTests(TestCase):
def testProcessDiesAfterBeingTracked(self):
p = BetterPopen(["sleep", "1"])
- zombieReaper.autoReapPID(p.pid)
+ zombiereaper.autoReapPID(p.pid)
# wait for the grim reaper to arrive
sleep(4)
@@ -40,7 +43,7 @@
# wait for the process to die
sleep(1)
- zombieReaper.autoReapPID(p.pid)
+ zombiereaper.autoReapPID(p.pid)
# Throws error because pid is not found or is not child
self.assertRaises(OSError, os.waitpid, p.pid, os.WNOHANG)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 5efae38..9233e7b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -66,7 +66,6 @@
vmTestsData.py \
vmTests.py \
volumeTests.py \
- zombieReaperTests.py \
$(NULL)
nodist_vdsmtests_PYTHON = \
diff --git a/tests/testrunner.py b/tests/testrunner.py
index bf49dd1..1f3b38e 100644
--- a/tests/testrunner.py
+++ b/tests/testrunner.py
@@ -40,8 +40,8 @@
from testValidation import SlowTestsPlugin, StressTestsPlugin
-import zombieReaper
-zombieReaper.registerSignalHandler()
+import zombiereaper
+zombiereaper.registerSignalHandler()
PERMUTATION_ATTR = "_permutations_"
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 8d3ba09..c9eba50 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -98,6 +98,7 @@
Requires: python-inotify
Requires: python-argparse
Requires: python-ethtool >= 0.6-3
+Requires: %{name}-python-zombiereaper = %{version}-%{release}
Requires: rpm-python
Requires: nfs-utils
Requires: m2crypto
@@ -287,6 +288,15 @@
%description yajsonrpc
A JSON RPC server and client implementation.
+
+%package python-zombiereaper
+Summary: Collects zombie processes automatically
+BuildArch: noarch
+
+Requires: python >= 2.6
+
+%description python-zombiereaper
+Collects zombie processes automatically so you don't have to
%package bootstrap
Summary: VDSM bootstrapping package
@@ -858,7 +868,6 @@
%{_datadir}/%{vdsm_name}/vdsm-restore-net-config
%{_datadir}/%{vdsm_name}/vdsm-store-net-config
%{_datadir}/%{vdsm_name}/vm.py*
-%{_datadir}/%{vdsm_name}/zombieReaper.py*
%config(noreplace) %{_sysconfdir}/%{vdsm_name}/logger.conf
%config(noreplace) %{_sysconfdir}/%{vdsm_name}/svdsm.logger.conf
%config(noreplace) %{_sysconfdir}/%{vdsm_name}/mom.conf
@@ -1247,6 +1256,9 @@
%{python_sitelib}/yajsonrpc/protonReactor.py*
%{python_sitelib}/yajsonrpc/client.py*
+%files python-zombiereaper
+%{python_sitelib}/zombiereaper/__init__.py*
+
%files bootstrap
%defattr(-, root, root, -)
%doc COPYING
diff --git a/vdsm/Makefile.am b/vdsm/Makefile.am
index 5ab291e..31965af 100644
--- a/vdsm/Makefile.am
+++ b/vdsm/Makefile.am
@@ -53,7 +53,6 @@
vdsmDebugPlugin.py \
vmChannels.py \
vm.py \
- zombieReaper.py \
$(NULL)
dist_vdsmexec_SCRIPTS = \
diff --git a/vdsm/storage/remoteFileHandler.py b/vdsm/storage/remoteFileHandler.py
index f01461f..ec05a25 100644
--- a/vdsm/storage/remoteFileHandler.py
+++ b/vdsm/storage/remoteFileHandler.py
@@ -46,7 +46,7 @@
import misc
import fileUtils
-import zombieReaper
+import zombiereaper
from vdsm import utils
@@ -260,9 +260,9 @@
out, err)
try:
- zombieReaper.autoReapPID(self.process.pid)
+ zombiereaper.autoReapPID(self.process.pid)
except AttributeError:
- if zombieReaper is not None:
+ if zombiereaper is not None:
raise
def __del__(self):
diff --git a/vdsm/vdsm b/vdsm/vdsm
index 4fc11c7..8c60c4c 100755
--- a/vdsm/vdsm
+++ b/vdsm/vdsm
@@ -21,8 +21,9 @@
from logging import config as lconfig
from vdsm import constants
-import zombieReaper
+import zombiereaper
import dsaversion
+
if sys.version_info[0] == 2:
# as long as we work with Python 2, we need to monkey-patch threading
# module before it is ever used.
@@ -53,7 +54,7 @@
signal.signal(signal.SIGTERM, sigtermHandler)
signal.signal(signal.SIGUSR1, sigusr1Handler)
- zombieReaper.registerSignalHandler()
+ zombiereaper.registerSignalHandler()
from clientIF import clientIF # must import after config is read
cif = clientIF.getInstance(log)
--
To view, visit http://gerrit.ovirt.org/23213
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I58e9c834820d98fb3dcffdf06bfc05eb68ea6827
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.3
Gerrit-Owner: Yaniv Bronhaim <ybronhei at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Saggi Mizrahi <smizrahi at redhat.com>
More information about the vdsm-patches
mailing list