Bug 38738 - top: NoSuchProcess(pid) Traceback
top: NoSuchProcess(pid) Traceback
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UMC - Process overview
UCS 4.1
Other Linux
: P5 normal (vote)
: UCS 4.2-1-errata
Assigned To: Johannes Keiser
Florian Best
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2015-06-22 09:36 CEST by Philipp Hahn
Modified: 2017-07-12 16:49 CEST (History)
1 user (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 3: Simply Wrong: The implementation doesn't match the docu
Who will be affected by this bug?: 2: Will only affect a few installed domains
How will those affected feel about the bug?: 2: A Pain – users won’t like this once they notice it
User Pain: 0.069
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional): Error handling, Usability
Max CVSS v3 score:
best: Patch_Available+


Attachments
Catch NoSuchProcess exception (3.48 KB, patch)
2015-06-22 09:36 CEST, Philipp Hahn
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Philipp Hahn univentionstaff 2015-06-22 09:36:18 CEST
Created attachment 6975 [details]
Catch NoSuchProcess exception

One of our jenkins tests fails from time to time: <http://jenkins.knut.univention.de:8080/job/UCS-3.2/job/UCS-3.2-6/job/Autotest%20MultiEnv/SambaVersion=s3,Systemrolle=backup/34/testReport/junit/60_umc-system/22_umc-service-proc-killing/test/>

> 60_umc-system.22_umc-service-proc-killing.test
> Testing UMC process killing with signal 'SIGTERM'
> ### FAIL ###
> Exception while making 'top/query' request: 500 on backup092 (top/query): {"status": 591, "message": "Die Ausführung des Kommandos top/query ist fehlgeschlagen:
> Traceback (most recent call last):
>   File "PY2.6/univention/management/console/modules/__init__.py", line 218, in execute
>     func( request )
>   File "PY2.6/univention/management/console/modules/decorators.py", line 178, in _response
>     return function(self, request)
>   File "PY2.6/univention/management/console/modules/top/__init__.py", line 78, in query
>     listEntry['mem'] = process.get_memory_percent()
>   File "PY2.6/psutil/__init__.py", line 342, in get_memory_percent
>     rss = _platform_impl.get_memory_info(self.pid)[0]
>   File "PY2.6/psutil/_pslinux.py", line 111, in wrapper
>     raise NoSuchProcess(pid)
> NoSuchProcess: 29728"}
> ###      ###
> Created process with pid '29708' was not terminated, forcing kill

Note that the "process to kill"=29708 differs from the "process not found"=29728.

The for-loop in management/univention-management-console-module-top/umc/python/top/__init__.py:66 iterates over all processes, but queries the data in a non-atomic way: If *any* process terminates while the loop is iterated, the whole query fails because of a thrown NoSuchProcess exception.

All calls to psutils should be wrapped in a try-catch-block.
Comment 1 Johannes Keiser univentionstaff 2017-07-07 10:52:08 CEST
(In reply to Philipp Hahn from comment #0)
> Created attachment 6975 [details]
> Catch NoSuchProcess exception
>

Applied rebased patch:

r 80948
univention-management-console-module-top (6.0.1-2) 
* Bug #38738: Applied patch from Philipp Hahn - Catch NoSuchProcess
exception

YAML: r 80951
Comment 2 Florian Best univentionstaff 2017-07-07 15:59:38 CEST
OK: race condition doesn't cause errors anymore
OK: YAML (adjusted in r80977)
Comment 3 Janek Walkenhorst univentionstaff 2017-07-12 16:49:25 CEST
<http://errata.software-univention.de/ucs/4.2/91.html>