Bug 55752 - Python-2-code tries to import code only available with Python 3
Python-2-code tries to import code only available with Python 3
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UMC - App-Center
UCS 5.0
Other Linux
: P5 normal (vote)
: UCS 5.0-3-errata
Assigned To: Florian Best
Philipp Hahn
https://git.knut.univention.de/univen...
:
Depends on:
Blocks: 55776
  Show dependency treegraph
 
Reported: 2023-02-23 19:30 CET by Philipp Hahn
Modified: 2023-03-02 17:23 CET (History)
1 user (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 1: Cosmetic issue or missing function but workaround exists
Who will be affected by this bug?: 3: Will affect average number of installed domains
How will those affected feel about the bug?: 1: Nuisance – not a big deal but noticeable
User Pain: 0.017
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional): API change
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philipp Hahn univentionstaff 2023-02-23 19:30:11 CET
UDL and `sdnotify` are Python-3-only, but UMC respective "univention.lib.ldap_extension" is executed in Python-2-context and tries to import it during USS:

Vorbereitung zum Entpacken von .../052-univention-management-console-module-apps_9.0.7-2A~5.0.0.202302061623_all.deb ...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/univention/management/console/modules/__init__.py", line 39, in <module>
    import univention.management.console.protocol  # noqa: F401
  File "/usr/lib/python2.7/dist-packages/univention/management/console/protocol/__init__.py", line 216, in <module>
    from .modserver import *  # noqa: F403,F401
  File "/usr/lib/python2.7/dist-packages/univention/management/console/protocol/modserver.py", line 58, in <module>
    from .server import Server
  File "/usr/lib/python2.7/dist-packages/univention/management/console/protocol/server.py", line 54, in <module>
    from sdnotify import SystemdNotifier
ImportError: No module named sdnotify
...
univention-management-console-module-appcenter (9.0.7-2A~5.0.0.202302061623) wird eingerichtet ...
Setting umc/web/cache_bust
File: /var/www/univention/meta.json
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/univention/appcenter/actions/__init__.py", line 261, in get_action
    _import()
  File "/usr/lib/python2.7/dist-packages/univention/appcenter/actions/__init__.py", line 279, in _import
    __import__('univention.appcenter.actions.%s' % pymodule_name)
  File "/usr/lib/python2.7/dist-packages/univention/appcenter/actions/install.py", line 41, in <module>
    from univention.appcenter.actions.install_base import InstallRemoveUpgrade
  File "/usr/lib/python2.7/dist-packages/univention/appcenter/actions/install_base.py", line 51, in <module>
    from univention.appcenter.actions.register import Register
  File "/usr/lib/python2.7/dist-packages/univention/appcenter/actions/register.py", line 66, in <module>
    from univention.lib.ldap_extension import UniventionLDAPSchema, get_handler_message
  File "/usr/lib/python2.7/dist-packages/univention/lib/ldap_extension.py", line 65, in <module>
    import listener
ImportError: No module named listener


So far no bad consequences.
Comment 1 Florian Best univentionstaff 2023-02-24 11:19:29 CET
The bad consequence is that we break our "promise" to support Python 2 UMC modules (and maybe more). They cannot be imported anymore due to missing "sdnotify".
Comment 2 Florian Best univentionstaff 2023-02-24 12:25:52 CET
(In reply to Philipp Hahn from comment #0)
> UDL and `sdnotify` are Python-3-only, but UMC respective
> "univention.lib.ldap_extension" is executed in Python-2-context and tries to
> import it during USS:
> 
> Vorbereitung zum Entpacken von
> .../052-univention-management-console-module-apps_9.0.7-2A~5.0.0.
> 202302061623_all.deb ...
> Traceback (most recent call last):
> ImportError: No module named sdnotify
→ The dependency is available for Python2. Add it in https://git.knut.univention.de/univention/ucs/-/merge_requests/681

> ...
> univention-management-console-module-appcenter (9.0.7-2A~5.0.0.202302061623)
> wird eingerichtet ...
> Setting umc/web/cache_bust
> File: /var/www/univention/meta.json
> Traceback (most recent call last):
> ImportError: No module named listener

This is:
management/univention-appcenter/debian/univention-management-console-module-appcenter.postinst
> 38 if [ -z "$2" ]; then
> 39 ›   # new installation. update local files once as there might be
> 40 ›   # meta files already in the cache that did not undergo
> 41 ›   # _update_local_files routine
> 42 ›   # See Bug#46813
> 43 ›   python -c "from univention.appcenter.actions import get_action; get_action('update')()._update_local_files()"
> 44 fi
It seems parts of the App-Center Python 2 support is already broken in UCS 5.0-2 git:01d1f57fa5eb7053b66d16524e7f757f48df0e12.
Or specifically "import univention.lib.ldap_extension" does not work anymore with Python 2.7.
We didn't detect this, we also had no feedback from any customers. Maybe we can drop our promise to have Python2 support for the App-Center until UCS 5.1 then.

The specific Python 2 call in the postinst will be changed to Python 3 in Bug #55632.
Comment 3 Florian Best univentionstaff 2023-02-24 16:02:29 CET
Added dependency on python-sdnotify:
python -c 'import univention.management.console.protocol.server' works again.

univention-management-console.yaml
5719d731d5ea | fix(umc): add missing Python 2.7 dependency

univention-management-console (12.0.17-6)
5719d731d5ea | fix(umc): add missing Python 2.7 dependency
Comment 4 Philipp Hahn univentionstaff 2023-02-24 16:08:26 CET
Package: univention-management-console
Version: 12.0.17-6A~5.0.0.202302241559
Branch: ucs_5.0-0
Scope: errata5.0-3

OK: python2 -c 'import univention.management.console.protocol'
IGN: python2 -c 'from univention.lib.ldap_extension import UniventionLDAPSchema'