Yaniv Bronhaim has uploaded a new change for review.
Change subject: Moving pidStat function to utils ......................................................................
Moving pidStat function to utils
As in general it doesn't serve only the storage part
Change-Id: Iad76fd978283c9dc55635075ff195211cced2d64 Signed-off-by: Yaniv Bronhaim ybronhei@redhat.com --- M tests/miscTests.py M tests/utilsTests.py M vdsm/storage/blockSD.py M vdsm/storage/misc.py 4 files changed, 21 insertions(+), 32 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/32/10932/1
diff --git a/tests/miscTests.py b/tests/miscTests.py index cfa2f90..a949a09 100644 --- a/tests/miscTests.py +++ b/tests/miscTests.py @@ -101,20 +101,6 @@ sproc.wait()
-class PidStatTests(TestCaseBase): - def test(self): - args = [EXT_SLEEP, "3"] - sproc = misc.execCmd(args, sync=False, sudo=False) - stats = misc.pidStat(sproc.pid) - pid = int(stats[0]) - # procName comes in the format of (procname) - name = stats[1] - self.assertEquals(pid, sproc.pid) - self.assertEquals(name, args[0]) - sproc.kill() - sproc.wait() - - class EventTests(TestCaseBase): def testEmit(self): ev = threading.Event() @@ -1039,7 +1025,7 @@ proc = misc.execCmd(cmd, sudo=False, nice=10, sync=False)
def test(): - nice = misc.pidStat(proc.pid)[18] + nice = utils.pidStat(proc.pid)[18] self.assertEquals(nice, 10)
utils.retry(AssertionError, test, tries=10, sleep=0.1) diff --git a/tests/utilsTests.py b/tests/utilsTests.py index 745754d..cb32c65 100644 --- a/tests/utilsTests.py +++ b/tests/utilsTests.py @@ -19,6 +19,7 @@ # from testrunner import VdsmTestCase as TestCaseBase from vdsm import utils +from storage import misc
class RetryTests(TestCaseBase): @@ -43,3 +44,17 @@ sleep=0, stopCallback=stopCallback) # Make sure we had the proper amount of iterations before failing self.assertEquals(counter[0], limit) + + +class PidStatTests(TestCaseBase): + def test(self): + args = ["sleep", "3"] + sproc = misc.execCmd(args, sync=False, sudo=False) + stats = utils.pidStat(sproc.pid) + pid = int(stats[0]) + # procName comes in the format of (procname) + name = stats[1] + self.assertEquals(pid, sproc.pid) + self.assertEquals(name, args[0]) + sproc.kill() + sproc.wait() diff --git a/vdsm/storage/blockSD.py b/vdsm/storage/blockSD.py index a63f2b3..8f596fe 100644 --- a/vdsm/storage/blockSD.py +++ b/vdsm/storage/blockSD.py @@ -33,6 +33,7 @@
from vdsm.config import config from vdsm import constants +from vdsm import utils import misc import fileUtils import sd @@ -1087,7 +1088,7 @@
for umountPid in umountPids: try: - state = misc.pidStat(umountPid)[2] + state = utils.pidStat(umountPid)[2] mountPoint = misc.getCmdArgs(umountPid)[-1] except: # Process probably exited diff --git a/vdsm/storage/misc.py b/vdsm/storage/misc.py index 81cb9e7..5ec13e4 100644 --- a/vdsm/storage/misc.py +++ b/vdsm/storage/misc.py @@ -56,6 +56,7 @@ import inspect
from vdsm import constants +from vdsm import utils import storage_exception as se from vdsm.betterPopen import BetterPopen import fileUtils @@ -1117,7 +1118,7 @@ continue
try: - procName = pidStat(pid)[1] + procName = utils.pidStat(pid)[1] if procName == name: res.append(pid) except (OSError, IOError): @@ -1136,26 +1137,12 @@ # Retrying seems to solve it. while len(res) == 0: # cmdline is empty for zombie processes - if pidStat(pid)[2] in ("Z", "z"): + if utils.pidStat(pid)[2] in ("Z", "z"): return tuple()
res = _parseCmdLine(pid)
return res - - -def pidStat(pid): - res = [] - with open("/proc/%d/stat" % pid, "r") as f: - statline = f.readline() - procNameStart = statline.find("(") - procNameEnd = statline.rfind(")") - res.append(int(statline[:procNameStart])) - res.append(statline[procNameStart + 1:procNameEnd]) - args = statline[procNameEnd + 2:].split() - res.append(args[0]) - res.extend([int(item) for item in args[1:]]) - return tuple(res)
def tmap(func, iterable):
-- To view, visit http://gerrit.ovirt.org/10932 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange Gerrit-Change-Id: Iad76fd978283c9dc55635075ff195211cced2d64 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Yaniv Bronhaim ybronhei@redhat.com
oVirt Jenkins CI Server has posted comments on this change.
Change subject: Moving pidStat function to utils ......................................................................
Patch Set 1:
Build Started http://jenkins.ovirt.org/job/vdsm_unit_tests_manual_gerrit/694/ (2/2)
-- To view, visit http://gerrit.ovirt.org/10932 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: Iad76fd978283c9dc55635075ff195211cced2d64 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Yaniv Bronhaim ybronhei@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: Moving pidStat function to utils ......................................................................
Patch Set 1:
Build Started http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/659/ (1/2)
-- To view, visit http://gerrit.ovirt.org/10932 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: Iad76fd978283c9dc55635075ff195211cced2d64 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Yaniv Bronhaim ybronhei@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: Moving pidStat function to utils ......................................................................
Patch Set 1: Fails
Build Failed
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/659/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_manual_gerrit/694/ : FAILURE
-- To view, visit http://gerrit.ovirt.org/10932 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: Iad76fd978283c9dc55635075ff195211cced2d64 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Yaniv Bronhaim ybronhei@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: Moving pidStat function to utils ......................................................................
Patch Set 2:
Build Started http://jenkins.ovirt.org/job/vdsm_unit_tests_manual_gerrit/695/ (1/2)
-- To view, visit http://gerrit.ovirt.org/10932 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: Iad76fd978283c9dc55635075ff195211cced2d64 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Yaniv Bronhaim ybronhei@redhat.com Gerrit-Reviewer: Yaniv Bronhaim ybronhei@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: Moving pidStat function to utils ......................................................................
Patch Set 2:
Build Started http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/660/ (2/2)
-- To view, visit http://gerrit.ovirt.org/10932 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: Iad76fd978283c9dc55635075ff195211cced2d64 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Yaniv Bronhaim ybronhei@redhat.com Gerrit-Reviewer: Yaniv Bronhaim ybronhei@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: Moving pidStat function to utils ......................................................................
Patch Set 2:
Build Successful
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/660/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_manual_gerrit/695/ : SUCCESS
-- To view, visit http://gerrit.ovirt.org/10932 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: Iad76fd978283c9dc55635075ff195211cced2d64 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Yaniv Bronhaim ybronhei@redhat.com Gerrit-Reviewer: Yaniv Bronhaim ybronhei@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
Saggi Mizrahi has posted comments on this change.
Change subject: Moving pidStat function to utils ......................................................................
Patch Set 2: Looks good to me, but someone else must approve
-- To view, visit http://gerrit.ovirt.org/10932 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: Iad76fd978283c9dc55635075ff195211cced2d64 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Yaniv Bronhaim ybronhei@redhat.com Gerrit-Reviewer: Douglas Schilling Landgraf dougsland@redhat.com Gerrit-Reviewer: Royce Lv lvroyce@linux.vnet.ibm.com Gerrit-Reviewer: Saggi Mizrahi smizrahi@redhat.com Gerrit-Reviewer: Yaniv Bronhaim ybronhei@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
Saggi Mizrahi has posted comments on this change.
Change subject: Moving pidStat function to utils ......................................................................
Patch Set 2: Looks good to me, approved
-- To view, visit http://gerrit.ovirt.org/10932 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: Iad76fd978283c9dc55635075ff195211cced2d64 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Yaniv Bronhaim ybronhei@redhat.com Gerrit-Reviewer: Douglas Schilling Landgraf dougsland@redhat.com Gerrit-Reviewer: Royce Lv lvroyce@linux.vnet.ibm.com Gerrit-Reviewer: Saggi Mizrahi smizrahi@redhat.com Gerrit-Reviewer: Yaniv Bronhaim ybronhei@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
Douglas Schilling Landgraf has posted comments on this change.
Change subject: Moving pidStat function to utils ......................................................................
Patch Set 2: Looks good to me, but someone else must approve
-- To view, visit http://gerrit.ovirt.org/10932 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: Iad76fd978283c9dc55635075ff195211cced2d64 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Yaniv Bronhaim ybronhei@redhat.com Gerrit-Reviewer: Douglas Schilling Landgraf dougsland@redhat.com Gerrit-Reviewer: Royce Lv lvroyce@linux.vnet.ibm.com Gerrit-Reviewer: Saggi Mizrahi smizrahi@redhat.com Gerrit-Reviewer: Yaniv Bronhaim ybronhei@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
Royce Lv has posted comments on this change.
Change subject: Moving pidStat function to utils ......................................................................
Patch Set 2: Verified; Looks good to me, but someone else must approve
-- To view, visit http://gerrit.ovirt.org/10932 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: Iad76fd978283c9dc55635075ff195211cced2d64 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Yaniv Bronhaim ybronhei@redhat.com Gerrit-Reviewer: Douglas Schilling Landgraf dougsland@redhat.com Gerrit-Reviewer: Royce Lv lvroyce@linux.vnet.ibm.com Gerrit-Reviewer: Saggi Mizrahi smizrahi@redhat.com Gerrit-Reviewer: Yaniv Bronhaim ybronhei@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: Moving pidStat function to utils ......................................................................
Patch Set 3:
Build Started http://jenkins.ovirt.org/job/vdsm_unit_tests_manual_gerrit/751/ (1/2)
-- To view, visit http://gerrit.ovirt.org/10932 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: Iad76fd978283c9dc55635075ff195211cced2d64 Gerrit-PatchSet: 3 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Yaniv Bronhaim ybronhei@redhat.com Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Douglas Schilling Landgraf dougsland@redhat.com Gerrit-Reviewer: Royce Lv lvroyce@linux.vnet.ibm.com Gerrit-Reviewer: Saggi Mizrahi smizrahi@redhat.com Gerrit-Reviewer: Yaniv Bronhaim ybronhei@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: Moving pidStat function to utils ......................................................................
Patch Set 3:
Build Started http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/716/ (2/2)
-- To view, visit http://gerrit.ovirt.org/10932 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: Iad76fd978283c9dc55635075ff195211cced2d64 Gerrit-PatchSet: 3 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Yaniv Bronhaim ybronhei@redhat.com Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Douglas Schilling Landgraf dougsland@redhat.com Gerrit-Reviewer: Royce Lv lvroyce@linux.vnet.ibm.com Gerrit-Reviewer: Saggi Mizrahi smizrahi@redhat.com Gerrit-Reviewer: Yaniv Bronhaim ybronhei@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: Moving pidStat function to utils ......................................................................
Patch Set 3:
Build Successful
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/716/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_manual_gerrit/751/ : SUCCESS
-- To view, visit http://gerrit.ovirt.org/10932 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: Iad76fd978283c9dc55635075ff195211cced2d64 Gerrit-PatchSet: 3 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Yaniv Bronhaim ybronhei@redhat.com Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Douglas Schilling Landgraf dougsland@redhat.com Gerrit-Reviewer: Royce Lv lvroyce@linux.vnet.ibm.com Gerrit-Reviewer: Saggi Mizrahi smizrahi@redhat.com Gerrit-Reviewer: Yaniv Bronhaim ybronhei@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
Dan Kenigsberg has posted comments on this change.
Change subject: Moving pidStat function to utils ......................................................................
Patch Set 3: Verified; Looks good to me, approved
copying former scores by Saggi and Royce.
-- To view, visit http://gerrit.ovirt.org/10932 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: Iad76fd978283c9dc55635075ff195211cced2d64 Gerrit-PatchSet: 3 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Yaniv Bronhaim ybronhei@redhat.com Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Douglas Schilling Landgraf dougsland@redhat.com Gerrit-Reviewer: Royce Lv lvroyce@linux.vnet.ibm.com Gerrit-Reviewer: Saggi Mizrahi smizrahi@redhat.com Gerrit-Reviewer: Yaniv Bronhaim ybronhei@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
Dan Kenigsberg has submitted this change and it was merged.
Change subject: Moving pidStat function to utils ......................................................................
Moving pidStat function to utils
As in general it doesn't serve only the storage part
Change-Id: Iad76fd978283c9dc55635075ff195211cced2d64 Signed-off-by: Yaniv Bronhaim ybronhei@redhat.com --- M tests/miscTests.py M tests/utilsTests.py M vdsm/storage/blockSD.py M vdsm/storage/misc.py M vdsm/utils.py 5 files changed, 35 insertions(+), 32 deletions(-)
Approvals: Dan Kenigsberg: Verified; Looks good to me, approved
-- To view, visit http://gerrit.ovirt.org/10932 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: merged Gerrit-Change-Id: Iad76fd978283c9dc55635075ff195211cced2d64 Gerrit-PatchSet: 3 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Yaniv Bronhaim ybronhei@redhat.com Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Douglas Schilling Landgraf dougsland@redhat.com Gerrit-Reviewer: Royce Lv lvroyce@linux.vnet.ibm.com Gerrit-Reviewer: Saggi Mizrahi smizrahi@redhat.com Gerrit-Reviewer: Yaniv Bronhaim ybronhei@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
vdsm-patches@lists.fedorahosted.org