Bug 56198 - Handle aborted long running requests in requests to UMC modules
Handle aborted long running requests in requests to UMC modules
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UMC (Generic)
UCS 5.0
Other Linux
: P5 normal (vote)
: UCS 5.0-4-errata
Assigned To: Florian Best
Christian Castens
:
Depends on:
Blocks: 56336 56391
  Show dependency treegraph
 
Reported: 2023-06-26 14:22 CEST by Florian Best
Modified: 2023-08-02 11:32 CEST (History)
1 user (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 2023-06-26 14:22:31 CEST
If long running requests are aborted e.g. because of connection timeouts (by apache) those requests aren't detected as aborted in the UMC-Server and therefore the request to the UMC module is still waited for until completion and prevents session timeout for that module.

To make UMC behave like before we should detect aborted requests and close the connection to the module process, so that modules can run into session timeout and exit itself.
Comment 1 Florian Best univentionstaff 2023-06-26 14:35:04 CEST
Easy to test and reproduce via:

ucr set umc/module/timeout=30
systemctl restart univention-management-console-server
touch /var/run/univention-appcenter.lock
curl http://Administrator:univention@localhost:8090/command/appcenter/keep_alive -X POST
^C  # after some seconds just exit that request
pgrep -fl 'univention-management-console-module.*appcenter'  # should run
tail -f /var/log/univention/management-console-{module-appcenter,server}.log &
sleep 31
pgrep -fl 'univention-management-console-module.*appcenter'  # should not run anymore
Comment 2 Florian Best univentionstaff 2023-06-26 17:56:32 CEST
univention-management-console.yaml
2319287ada50 | fix(umc): handle connection timeouts during requests to UMC modules

univention-management-console (12.0.31-2)
2319287ada50 | fix(umc): handle connection timeouts during requests to UMC modules
Comment 3 Arvid Requate univentionstaff 2023-06-26 18:57:05 CEST
python-univention-management-console (12.0.31-2) wird eingerichtet ...
SyntaxError: 'return' with argument inside generator (resources.py, line 272)

dpkg: Fehler beim Bearbeiten des Paketes python-univention-management-console (--configure):
 »installiertes python-univention-management-console-Skript des Paketes post-installation«-Unterprozess gab den Fehlerwert 101 zurück
Comment 4 Florian Best univentionstaff 2023-06-26 20:12:14 CEST
(In reply to Arvid Requate from comment #3)
> python-univention-management-console (12.0.31-2) wird eingerichtet ...
> SyntaxError: 'return' with argument inside generator (resources.py, line 272)
> 
> dpkg: Fehler beim Bearbeiten des Paketes
> python-univention-management-console (--configure):
>  »installiertes python-univention-management-console-Skript des Paketes
> post-installation«-Unterprozess gab den Fehlerwert 101 zurück

Oh, yes, thanks.
I used that occurrence to remove all Python3-only used modules from the Python 2 package and migrate those modules to use Python-3 ready syntax.

univention-management-console (12.0.31-3)
1c169b5aad65 | refactor(umc): migrate UMC-Server only parts to Python 3 syntax
5c4bd0295af3 | fix(umc): remove UMC-Server only modules from python 2 package
Comment 5 Christian Castens univentionstaff 2023-06-27 15:12:17 CEST
QA:
timed out requests don't prevent session timeout (tested as described in Comment 1):    OK
advisories: OK



occasionally this traceback appears in management-console-server.log:

    Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/tornado/http1connection.py", line 735, in _server_request_loop
        ret = yield conn.read_response(request_delegate)
      File "/usr/lib/python3/dist-packages/tornado/gen.py", line 1133, in run
        value = future.result()
      File "/usr/lib/python3/dist-packages/tornado/gen.py", line 1147, in run
        yielded = self.gen.send(value)
      File "/usr/lib/python3/dist-packages/tornado/http1connection.py", line 245, in _read_message
        self.stream.set_close_callback(self._on_connection_close)
      File "/usr/lib/python3/dist-packages/tornado/iostream.py", line 606, in set_close_callback
        self._maybe_add_error_listener()
      File "/usr/lib/python3/dist-packages/tornado/iostream.py", line 1128, in _maybe_add_error_listener
        self._add_io_state(ioloop.IOLoop.READ)
      File "/usr/lib/python3/dist-packages/tornado/iostream.py", line 1158, in _add_io_state
        self.fileno(), self._handle_events, self._state)
      File "/usr/lib/python3/dist-packages/tornado/platform/asyncio.py", line 76, in add_handler
        raise ValueError("fd %s added twice" % fd)
    ValueError: fd 18 added twice

The error is ignored in the main loop so it does not cause any problems.