Bug 57049 - pkg_resources.DistributionNotFound: The 'univention-management-console==12.0.31.post18' distribution was not found and is required by the application
pkg_resources.DistributionNotFound: The 'univention-management-console==12.0....
Status: NEW
Product: UCS
Classification: Unclassified
Component: UMC (Generic)
UCS 5.0
Other Linux
: P5 normal (vote)
: ---
Assigned To: UMC maintainers
UMC maintainers
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2024-02-09 11:11 CET by Florian Best
Modified: 2024-02-24 16:29 CET (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 2024-02-09 11:11:50 CET
https://univention-dist-jenkins.k8s.knut.univention.de/job/UCS-5.0/job/UCS-5.0-6/job/AutotestUpgrade/SambaVersion=s4,Systemrolle=member/lastCompletedBuild/testReport/99_end/01_var_log_tracebacks/test_fetch_logfiles_on_dc_master/
reveals some tracebacks:


Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 583, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 900, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 791, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.VersionConflict: (univention-management-console 12.0.31.post13 (/usr/lib/python3/dist-packages), Requirement.parse('univention-management-console==12.0.31.post18'))


Traceback (most recent call last):
  File "/usr/sbin/univention-management-console-server", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3191, in <module>
    @_call_aside
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3175, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3204, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 585, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 598, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 786, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'univention-management-console==12.0.31.post18' distribution was not found and is required by the application


Since Bug #43633 / git:f65f51cd0c3327b174e7e0d72d59e924baed503d we specify the UMC server script as setuptools setup.py entrypoint instead of a regular script:

-    scripts=['scripts/univention-management-console-server', 'scripts/univention-management-console-module', 'scripts/univention-management-console-client', 'scripts/univention-management-console-acls'],
+    scripts=['scripts/univention-management-console-module', 'scripts/univention-management-console-client', 'scripts/univention-management-console-acls'],
+    entry_points={
+        'console_scripts': ['univention-management-console-server = univention.management.console.server:main'],
+    },


I suspect that this traceback is printed during package upgrades when the umc-server is restarted or somehow otherwise invoked. If the entrypoint doesn't match the new version I suspect this to happen.

If true, that questions me if we should use entrypoint-scripts at all instead of just importing the module and calling the main function.
Comment 1 Philipp Hahn univentionstaff 2024-02-09 12:02:17 CET
(In reply to Florian Best from comment #0)
> Requirement.parse('univention-management-console==12.0.31.post18'))
> pkg_resources.DistributionNotFound: The
> 'univention-management-console==12.0.31.post18' distribution was not found
> and is required by the application
...
> If true, that questions me if we should use entrypoint-scripts at all
> instead of just importing the module and calling the main function.

This is only the messenger: One process does an upgrade, while another process restarts that service *when it is not yet installed completely*. Reverting back will not fix anything as you might always get into the situation, where packages are half-unpacked only. Declare proper "Depends"!
Comment 2 Philipp Hahn univentionstaff 2024-02-24 16:29:32 CET
https://jenkins2022.knut.univention.de/job/UCS-5.0/job/UCS-5.0-6/job/AutotestUpgrade/ws/SambaVersion/no-samba/Systemrolle/member/test/member076/journalctl.log

Feb 21 02:50:38 member076 systemd[1]: Stopped Univention Management Console Server.
Feb 21 02:50:38 member076 systemd[1]: apache2.service: Succeeded.
Feb 21 02:50:38 member076 systemd[1]: Stopped The Apache HTTP Server.
Feb 21 02:50:38 member076 systemd[1]: Starting Univention Management Console Server...
Feb 21 02:50:39 member076 univention-management-console-server[26428]: Traceback (most recent call last):
Feb 21 02:50:39 member076 univention-management-console-server[26428]:   File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 583, in _build_master
Feb 21 02:50:39 member076 univention-management-console-server[26428]:     ws.require(__requires__)
Feb 21 02:50:39 member076 univention-management-console-server[26428]:   File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 900, in require
Feb 21 02:50:39 member076 univention-management-console-server[26428]:     needed = self.resolve(parse_requirements(requirements))
Feb 21 02:50:39 member076 univention-management-console-server[26428]:   File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 791, in resolve
Feb 21 02:50:39 member076 univention-management-console-server[26428]:     raise VersionConflict(dist, req).with_context(dependent_req)
Feb 21 02:50:39 member076 univention-management-console-server[26428]: pkg_resources.VersionConflict: (univention-management-console 12.0.31.post1 (/usr/lib/python3/dist-packages), Requirement.parse('univention-management-console==12.0.31.post13'))
Feb 21 02:50:39 member076 univention-management-console-server[26428]: During handling of the above exception, another exception occurred:
Feb 21 02:50:39 member076 univention-management-console-server[26428]: Traceback (most recent call last):
Feb 21 02:50:39 member076 univention-management-console-server[26428]:   File "/usr/sbin/univention-management-console-server", line 6, in <module>
Feb 21 02:50:39 member076 univention-management-console-server[26428]:     from pkg_resources import load_entry_point
Feb 21 02:50:39 member076 univention-management-console-server[26428]:   File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3191, in <module>
Feb 21 02:50:39 member076 univention-management-console-server[26428]:     @_call_aside
Feb 21 02:50:39 member076 univention-management-console-server[26428]:   File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3175, in _call_aside
Feb 21 02:50:39 member076 univention-management-console-server[26428]:     f(*args, **kwargs)
Feb 21 02:50:39 member076 univention-management-console-server[26428]:   File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3204, in _initialize_master_working_set
Feb 21 02:50:39 member076 univention-management-console-server[26428]:     working_set = WorkingSet._build_master()
Feb 21 02:50:39 member076 univention-management-console-server[26428]:   File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 585, in _build_master
Feb 21 02:50:39 member076 univention-management-console-server[26428]:     return cls._build_from_requirements(__requires__)
Feb 21 02:50:39 member076 univention-management-console-server[26428]:   File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 598, in _build_from_requirements
Feb 21 02:50:39 member076 univention-management-console-server[26428]:     dists = ws.resolve(reqs, Environment())
Feb 21 02:50:39 member076 univention-management-console-server[26428]:   File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 786, in resolve
Feb 21 02:50:39 member076 univention-management-console-server[26428]:     raise DistributionNotFound(req, requirers)
Feb 21 02:50:39 member076 univention-management-console-server[26428]: pkg_resources.DistributionNotFound: The 'univention-management-console==12.0.31.post13' distribution was not found and is required by the application
Feb 21 02:50:39 member076 systemd[1]: univention-management-console-server.service: Main process exited, code=exited, status=1/FAILURE
Feb 21 02:50:39 member076 systemd[1]: univention-management-console-server.service: Failed with result 'exit-code'.
Feb 21 02:50:39 member076 systemd[1]: Failed to start Univention Management Console Server.


https://jenkins2022.knut.univention.de/job/UCS-5.0/job/UCS-5.0-6/job/AutotestUpgrade/ws/SambaVersion/no-samba/Systemrolle/member/test/member076/dpkg.log
2024-02-21 02:50:39 upgrade python3-univention-management-console:all 12.0.31-1 12.0.31-13