Bug 54232 - UDM REST API client should cache LDAP base for all sessions
UDM REST API client should cache LDAP base for all sessions
Status: CLOSED FIXED
Product: Components
Classification: Unclassified
Component: udm-rest-api-client
unspecified
Other Linux
: P5 normal (vote)
: ---
Assigned To: Daniel Tröder
Tobias Wenzel
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2021-12-09 20:08 CET by Daniel Tröder
Modified: 2022-01-05 10:26 CET (History)
1 user (show)

See Also:
What kind of report is it?: Feature Request
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 Daniel Tröder univentionstaff 2021-12-09 20:08:32 CET
The UDM REST API client currently caches the LDAP base in an instance of the Session object.
But as the UDM REST API client is best used as a context manager, it has to get the LDAP base from the UDM REST API rather often (every time a new session is started).

Cache the LDAP base, so new connections do not require fetching it again and again.
Comment 1 Daniel Tröder univentionstaff 2021-12-09 20:45:36 CET
Retrieving the LDAP base requires making two HTTP queries:

301 GET /udm/ldap/base/
200 GET /udm/container/dc/dc=$LDAP,dc=$BASE

While those are responded to very fast, they still sum up to >=35ms each time.
When the UDM REST client is used in another REST service like the Kelvin REST API, that time will be added to each call!

The LDAP base cannot simply be cached for the whole process, as the client could be used to connect to different servers (with different LDAP bases).

But it can safely be assumed, that the LDAP base will not change on a host.
So the LDAP base cache can be a process wide mapping from host name to LDAP base.

----------------------------------------------------------------------------------

[master da8b96a] add process wide cache for the LDAP base of each host (Bug #54232)

A git tag "1.0.5" was added.

* Coverage (100%): https://app.codecov.io/gh/univention/python-udm-rest-api-client
* Docs (Published): https://udm-rest-client.readthedocs.io/en/latest/
* Travis CI (success): https://app.travis-ci.com/github/univention/python-udm-rest-api-client
* GH Actions - Linting (success): https://github.com/univention/python-udm-rest-api-client/actions?query=workflow%3A%22Code+Linting%22
* GH Actions - Integration tests (success, but wrong badge): https://github.com/univention/python-udm-rest-api-client/actions?query=workflow%3A%22Integration+tests%22

The package was released on https://test.pypi.org/project/udm-rest-client/1.0.5/
When approved by QA, I'll release it via production PyPI.
Comment 2 Tobias Wenzel univentionstaff 2022-01-03 16:49:05 CET
QA

- code OK
- pipelines + docu 

https://udm-rest-client.readthedocs.io/en/latest/history.html#history
starts with

>1.0.5 ()


- installation OK
- tests pass with lxd OK
Comment 3 Daniel Tröder univentionstaff 2022-01-05 08:39:23 CET
The changelog was fixed, a new tag created and a new version released.

[tags/1.0.6] be1a971 bump version to 1.0.6
Comment 4 Tobias Wenzel univentionstaff 2022-01-05 09:33:22 CET
Looks good & released on pypi
-> verify
Comment 5 Daniel Tröder univentionstaff 2022-01-05 10:26:02 CET
Has been released on pypi.