Problem: ucs-school-import-http-api.service is not starting

Problem:

ucs-school-import-http-api.service is not starting

[2022-02-02 12:25:25 +0000] [16102] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 557, in spawn_worker
    worker.init_process()
  File "/usr/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 126, in init_process
    self.load_wsgi()
  File "/usr/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 136, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/usr/lib/python2.7/dist-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/usr/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 65, in load
    return self.load_wsgiapp()
  File "/usr/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/usr/lib/python2.7/dist-packages/gunicorn/util.py", line 384, in import_app
    __import__(module)
  File "/usr/lib/python2.7/dist-packages/ucsschool/http_api/app/wsgi.py", line 44, in <module>
    _application = get_wsgi_application()
  File "/usr/lib/python2.7/dist-packages/django/core/wsgi.py", line 13, in get_wsgi_application
    django.setup(set_prefix=False)
  File "/usr/lib/python2.7/dist-packages/django/__init__.py", line 22, in setup
    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
  File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 53, in __getattr__
    self._setup(name)
  File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 41, in _setup
    self._wrapped = Settings(settings_module)
  File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 97, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/usr/lib/python2.7/dist-packages/ucsschool/http_api/app/settings.py", line 40, in <module>
    res = imp.load_module("settings", *info)
  File "/etc/ucsschool-import/settings.py", line 45, in <module>
    from ucsschool.lib.models.utils import CMDLINE_LOG_FORMATS, LOG_DATETIME_FORMAT
  File "/usr/lib/python2.7/dist-packages/ucsschool/lib/models/__init__.py", line 35, in <module>
    from .computer import *  # noqa: F401, F403
  File "/usr/lib/python2.7/dist-packages/ucsschool/lib/models/computer.py", line 51, in <module>
    from .base import MultipleObjectsError, RoleSupportMixin, UCSSchoolHelperAbstractClass
  File "/usr/lib/python2.7/dist-packages/ucsschool/lib/models/base.py", line 53, in <module>
    from .meta import UCSSchoolHelperMetaClass
  File "/usr/lib/python2.7/dist-packages/ucsschool/lib/models/meta.py", line 50, in <module>
    udm_modules.update()
  File "/usr/lib/python2.7/dist-packages/univention/admin/modules.py", line 123, in update
    _walk(root, w_root, w_files)
  File "/usr/lib/python2.7/dist-packages/univention/admin/modules.py", line 110, in _walk
    m = importlib.import_module('univention.admin.handlers.%s' % (modulepackage,))  # type: Any
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/usr/lib/python2.7/dist-packages/univention/admin/handlers/ms/gpsi-package-registration.py", line 126, in <module>
    syntax=univention.admin.syntax.SignedInteger,
AttributeError: 'module' object has no attribute 'SignedInteger'
[2022-02-02 12:25:25 +0000] [16102] [INFO] Worker exiting (pid: 16102)

Investigation:

This is a UDM traceback. The file gpsi-package-registration.py comes from the s4-connector. So does the not loadable syntax.
Helpful questions:
is the s4-connector installed and is this correct? Does the syntax file exist and what is its contened?

dpkg -l |grep connector
ii  python-univention-connector-s4                      13.0.2-88A~4.4.0.202103231539                                       all   

dpkg -S gpsi-package-registration.py
python-univention-connector-s4: /usr/lib/python2.7/dist-packages/univention/admin/handlers/ms/gpsi-package-registration.py

Is admin/syntax.d/s4_connector.py missing?

rgrep SignedInteger /usr/lib/python2.7/dist-packages/univention/admin/syntax.d/
/usr/lib/python2.7/dist-packages/univention/admin/syntax.d/s4_connector.py:class SignedInteger(integer):  # Workaround for Bug #50591
Übereinstimmungen in Binärdatei /usr/lib/python2.7/dist-packages/univention/admin/syntax.d/s4_connector.pyc

Is the syntax import generally possible?

python2.7 -c 'import univention.admin.syntax; print(univention.admin.syntax.SignedInteger)
Ausgabe
<class 'univention.admin.syntax.SignedInteger'>`

Unespected but very helpful is having a look in the /var/log/univention/listener.log
You find these lines

IOError: [Errno 13] Permission denied: ‘/usr/lib/python2.7/dist-packages/univention/admin/syntax.d/50_ox.py’
IOError: [Errno 13] Permission denied: ‘/usr/lib/python2.7/dist-packages/univention/admin/syntax.d/app_syntax.py’
IOError: [Errno 13] Permission denied: ‘/usr/lib/python2.7/dist-packages/univention/admin/syntax.d/univention-virtual-machine-manager-schema.py’
IOError: [Errno 13] Permission denied: ‘/usr/lib/python2.7/dist-packages/univention/admin/syntax.d/syntax.ucs-school-import.py’
IOError: [Errno 13] Permission denied: ‘/usr/lib/python2.7/dist-packages/univention/admin/syntax.d/s4_connector.py’
IOError: [Errno 13] Permission denied: ‘/usr/lib/python2.7/dist-packages/univention/admin/syntax.d/samlserviceprovider.py’
IOError: [Errno 13] Permission denied: ‘/usr/lib/python2.7/dist-packages/univention/admin/syntax.d/example.py’
IOError: [Errno 13] Permission denied: ‘/usr/lib/python2.7/dist-packages/univention/admin/hooks.d/ucsschool_role_computers.py’
IOError: [Errno 13] Permission denied: ‘/usr/lib/python2.7/dist-packages/univention/admin/hooks.d/oxUserDefaults.py’
IOError: [Errno 13] Permission denied: ‘/usr/lib/python2.7/dist-packages/univention/admin/hooks.d/oxContextRW.py’
IOError: [Errno 13] Permission denied: ‘/usr/lib/python2.7/dist-packages/univention/admin/hooks.d/ucsschool_purge_timestamp.py’
IOError: [Errno 13] Permission denied: ‘/usr/lib/python2.7/dist-packages/univention/admin/hooks.d/schoolOU.py’
IOError: [Errno 13] Permission denied: ‘/usr/lib/python2.7/dist-packages/univention/admin/hooks.d/oxGroupHook.py’
IOError: [Errno 13] Permission denied: ‘/usr/lib/python2.7/dist-packages/univention/admin/hooks.d/ucsschool_user_options.py’
IOError: [Errno 13] Permission denied: ‘/usr/lib/python2.7/dist-packages/univention/admin/hooks.d/schoolAdminGroup.py’
IOError: [Errno 13] Permission denied: ‘/usr/lib/python2.7/dist-packages/univention/admin/hooks.d/oxAccess.py’

Solution:

So the root cause could be file permissions. Checking them we see that the user uas-import has no read permissions for
/usr/lib/python2.7/dist-packages/univention/admin/hooks.d/
and below this and could not access
/usr/lib/python2.7/dist-packages/univention/admin/syntax.d/

Mastodon