Bug 49972 - top/query: NoSuchProcess: psutil.NoSuchProcess process no longer exists (pid=18137)
top/query: NoSuchProcess: psutil.NoSuchProcess process no longer exists (pid=...
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UMC - Process overview
UCS 4.4
Other Linux
: P5 normal (vote)
: UCS 4.4-5-errata
Assigned To: Christian Castens
UMC maintainers
https://jenkins.knut.univention.de:81...
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2019-08-07 12:43 CEST by Florian Best
Modified: 2020-09-09 16:48 CEST (History)
3 users (show)

See Also:
What kind of report is it?: ---
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Best univentionstaff 2019-08-07 12:43:11 CEST
Today the Jenkins test failed:

Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/univention/management/console/base.py", line 260, in execute
    function.__func__(self, request, *args, **kwargs)
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/decorators.py", line 181, in _response
    return function(self, request)
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/decorators.py", line 321, in _response
    result = _multi_response(self, request)
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/decorators.py", line 181, in _response
    return function(self, request)
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/decorators.py", line 443, in _response
    return list(function(self, iterator, *nones))
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/decorators.py", line 289, in _fake_func
    yield function(self, *args)
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/top/__init__.py", line 58, in query
    username = process.username()
  File "/usr/lib/python2.7/dist-packages/psutil/__init__.py", line 712, in username
    real_uid = self.uids().real
  File "/usr/lib/python2.7/dist-packages/psutil/_common.py", line 293, in wrapper
    return fun(self)
  File "/usr/lib/python2.7/dist-packages/psutil/__init__.py", line 750, in uids
    return self._proc.uids()
  File "/usr/lib/python2.7/dist-packages/psutil/_pslinux.py", line 1090, in wrapper
    raise NoSuchProcess(self.pid, self._name)
NoSuchProcess: psutil.NoSuchProcess process no longer exists (pid=18137)
Comment 4 Christian Castens univentionstaff 2020-08-27 15:04:57 CEST
The traceback is reliably reproducible by increasing the probability of a process not being existent during a call from psutil. This is achieved by modifying the top module's __init__.py and creating some additional short-lived processes on the vm while the test which produces the traceback is running. 

in /usr/lib/python2.7/dist-packages/univention/management/console/modules/top/__init__.py change line 59 to:
for process in list(psutil.process_iter()):

After that the /usr/share/ucs-test/86_selenium/160_process_overview_module test can be started. While the test is running create additional processes in the background.
The traceback should occur shortly after.

The traceback can be found in:
/var/log/univention/management-console-web-server.log

creates additional short-lived processes:
while true; do for ((i=0; i<=100; i++)); do /bin/sleep 0.2 & done; sleep 0.2; done
Comment 5 Christian Castens univentionstaff 2020-08-28 14:07:31 CEST
Package: univention-management-console-module-top
Version: 8.0.1-4A~4.4.0.202008281325
Branch: ucs_4.4-0
Scope: errata4.4-5

changed files:
doc/errata/staging/univention-management-console-module-top.yaml
management/univention-management-console-module-top/debian/changelog
management/univention-management-console-module-top/umc/python/top/__init__.py

commits (4.4-5):
commit 9e232408b08097256a5eac91085df61394a1b818 (file changes)
commit d3a5555fb8e4a234aede2fd5cd1c0c7a02aa1e0c (yaml)



Notes regarding changes:

- There was some code clean-up. A workaround for psutil version 2.2 and below has been removed completely since we are using version 5.

- The NoSuchProcess exception is now caught and will no longer cause a traceback in UMC.




QA: Please take note of my previous comment on how to reproduce the traceback.
Same procedure can be used to test the working version. With the new version the psutil.NoSuchProcess traceback should no longer occur in the given context.
Comment 6 Felix Botner univentionstaff 2020-09-03 11:42:58 CEST
OK - fix looks good
OK - univention-management-console-module-top
OK - yaml