Bug 33792 - UMC printer quota: displaying the quota takes very long if there are many users
UMC printer quota: displaying the quota takes very long if there are many users
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UMC - Printer administration
UCS 4.0
Other Linux
: P5 normal (vote)
: UCS 4.1-1-errata
Assigned To: Felix Botner
Florian Best
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-12-20 10:19 CET by Felix Botner
Modified: 2016-04-27 17:31 CEST (History)
5 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): Large environments
Max CVSS v3 score:


Attachments
umc-printers.patch (3.45 KB, patch)
2016-04-20 18:01 CEST, Felix Botner
Details | Diff
suggestions (5.73 KB, patch)
2016-04-26 08:37 CEST, Florian Best
Details | Diff
umc-printers.patch (5.41 KB, patch)
2016-04-26 18:35 CEST, Felix Botner
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Felix Botner univentionstaff 2013-12-20 10:19:59 CET
univention-printserver/umc/python/printers/__init__.py runs 

 /usr/bin/pkusers --list

to get all users and than

 repykota -P printer user

for every user to get the print quota settings for a printer. 

This takes a very long time if there are many users (1200).

Better run 

 repykota -P printer 

once and parse the output, which contains the quota settings for all users.


-> repykota -P printer2
Report für user Kontingent auf Drucker printer2 ()
Schonfrist: 7 Tage
Preis pro Auftrag: 3.000
Preis pro Seite: 1.000
User           overcharge   used    soft    hard    balance grace         total       paid warn
-----------------------------------------------------------------------------------------------
test1           -Q   1.0       3      10      20     -12.00                   3       0.00    0
test2           -Q   1.0       4      10      20     -16.00                   4       0.00    0
                                                              Gesamt :         7       0.00
                                                               Real :         6
Comment 1 Felix Botner univentionstaff 2013-12-20 10:20:22 CET
Ticket: #2013121721002391
Comment 2 Christina Scheinig univentionstaff 2016-04-19 08:40:20 CEST
Happened now again, in a UCS@School environment.

Ticket#2016041521000208
Comment 3 Michael Grandjean univentionstaff 2016-04-19 09:10:52 CEST
AFAIK there is no real version "UNSTABLE". Setting Version to 4.0 because that's what is used in the last mentioned ticket (probably also valid for 4.1, but I didn't test that).
Comment 4 Christina Scheinig univentionstaff 2016-04-20 10:46:11 CEST
first we need a patch for the customer, that fixes the long access time in the UMC module
Comment 5 Felix Botner univentionstaff 2016-04-20 18:01:44 CEST
Created attachment 7607 [details]
umc-printers.patch

apply patch with:
-> patch -p1 /usr/share/pyshared/univention/management/console/modules/printers/__init__.py umc-printers.patch
-> /etc/init.d/univention-management-console-server restart
Comment 6 Felix Botner univentionstaff 2016-04-20 18:36:37 CEST
Modified list_quota() in printers/__init__.py.

repykota can't be used here (truncates usernames after 15 characters). Instead the PyKotaTool and pykota.reporter python libs are used to generate a html report (with full usernames, repykota does not support html reports).
lxml.html is used to parse the html ouput.

univention-printserver: r68843

YAML: univention-printserver.yaml
Comment 7 Florian Best univentionstaff 2016-04-26 08:18:44 CEST
The patch works and is much faster.

But in case postgres is down the error message is the following:

"""
Die Anfrage konnte nicht ausgeführt werden.

Fehlernachricht des Servers:

Die Verbindung zur Print-Quota Postgres Datenbank konnte nicht hergestellt werden: konnte nicht mit dem Server verbinden: Verbindungsaufbau abgelehnt
Läuft der Server auf dem Host »localhost« (::1) und akzeptiert er
TCP/IP-Verbindungen auf Port 5432?
konnte nicht mit dem Server verbinden: Verbindungsaufbau abgelehnt
Läuft der Server auf dem Host »localhost« (127.0.0.1) und akzeptiert er
TCP/IP-Verbindungen auf Port 5432?
--- the most probable cause of your problem is that PostgreSQL is down, or doesn't accept incoming connections because you didn't configure it as explained in PyKota's documentation.
"""
→ The message contains duplicated sentences and blames the user, that's not good.

Please only log the exception to MODULE.error() but don't expose it to the user. The first sentence is enough. Maybe add 'Please make sure the postgres service is running and reachable.'.
Comment 8 Florian Best univentionstaff 2016-04-26 08:37:52 CEST
Created attachment 7617 [details]
suggestions
Comment 9 Felix Botner univentionstaff 2016-04-26 18:33:37 CEST
(In reply to Florian Best from comment #8)
> Created attachment 7617 [details]
> suggestions

OK,

And another thing, reportTool.deferredInit() calls os.seteuid(pykota), so after opening the quota page the umc process is owned by the pykota user, this is not good. Added a "finally: reportTool.regainPriv()" after the pykota stuff.
Comment 10 Felix Botner univentionstaff 2016-04-26 18:35:59 CEST
Created attachment 7624 [details]
umc-printers.patch

new version of the patch with fixed pykota call (reportTool.regainPriv())
Comment 11 Florian Best univentionstaff 2016-04-27 10:46:01 CEST
(In reply to Felix Botner from comment #10)
> Created attachment 7624 [details]
> umc-printers.patch
OK
> new version of the patch with fixed pykota call (reportTool.regainPriv())
OK: owner of the process is set back to "0".
Comment 12 Janek Walkenhorst univentionstaff 2016-04-27 17:31:58 CEST
<http://errata.software-univention.de/ucs/4.1/160.html>