Problem:UCS@school - Import ServerError: Received status_code=502 with reason='Proxy Error'

Problem

It is not possible to successfully complete an import for students via the UMC. Instead, the following error occurs and you receive this traceback.

Bildschirmfoto-UCS

Interner Server-Fehler in "schoolimport/dry-run/progress".
Request: schoolimport/dry-run/progress

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/univention/management/console/base.py", line 387, in __error_handling
    six.reraise(etype, exc, etraceback)
  File "/usr/lib/python3/dist-packages/six.py", line 693, in reraise
    raise value
  File "/usr/lib/python3/dist-packages/univention/management/console/base.py", line 285, in execute
    function.__func__(self, request, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/univention/management/console/modules/decorators.py", line 805, in _decorated
    return function(self, request, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/univention/management/console/modules/decorators.py", line 478, in _response
    result = _multi_response(self, request)
  File "/usr/lib/python3/dist-packages/univention/management/console/modules/decorators.py", line 189, in _response
    return function(self, request)
  File "/usr/lib/python3/dist-packages/univention/management/console/modules/decorators.py", line 602, in _response
    return list(function(self, iterator, *nones))
  File "/usr/lib/python3/dist-packages/univention/management/console/modules/decorators.py", line 444, in _fake_func
    yield function(self, *args)
  File "/usr/lib/python3/dist-packages/univention/management/console/modules/schoolimport/__init__.py", line 245, in poll_dry_run
    return progress.poll()
  File "/usr/lib/python3/dist-packages/univention/management/console/modules/mixins.py", line 105, in poll
    six.reraise(*self.exc_info)
  File "/usr/lib/python3/dist-packages/six.py", line 692, in reraise
    raise value.with_traceback(tb)
ucsschool.http_api.client.ServerError: Received status_code=502 with reason='Proxy Error' for requests.post(**url='https://ucs01.univention-schule.de/api/v1/imports/users/', data={'dryrun': True, 'school': 'https://ucs01.univention-schule.de/api/v1/schools/UniventionUCS/', 'user_role': 'student'}, files={'input_file': 'Univention-Schüler-Import.csv'}, params=None, auth=('admin-import', '****************'), headers={'Accept': 'application/json'}, verify=False).

Solution

In my case the auth user admin-import showing in the traceback was missing in the rabbitmq, so the user don’t have the authorization to perfom the import.
params=None, auth=('admin-import', '****************')

To get the user admin-import into the rabbitmq db you could use the following join-script, in my case that solve the issue.

univention-run-join-scripts --run-scripts 40ucs-school-import-http-api.inst --force


Investigation

Check the status of services for the import and if necessary, restart them.

  1. systemctl status apache2.service ucs-school-import-http-api.service postgresql.service rabbitmq-server.service

  2. systemctl restart apache2.service ucs-school-import-http-api.service postgresql.service rabbitmq-server.service

See also:


In my case, the service for the rabbitmq was not running and would not start correctly, because the permissions from the rabbitmq dir was not set correct, like shown in the following outputs.

root@dc0:~/univention-support# systemctl status rabbitmq-server.service
● rabbitmq-server.service - RabbitMQ Messaging Server
   Loaded: loaded (/lib/systemd/system/rabbitmq-server.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Thu 2024-09-26 05:04:24 CEST; 6s ago
  Process: 497 ExecStart=/usr/sbin/rabbitmq-server (code=exited, status=200/CHDIR)
 Main PID: 497 (code=exited, status=200/CHDIR)
root@dc0:~/univention-support# ls -lah /var/lib/rabbitmq/
insgesamt 16K
dr--r--r--  3 rabbitmq rabbitmq 4,0K Jun 24  2022 .
drwxr-xr-x 86 root     root     4,0K Sep  4 20:55 ..
-r--------  1 rabbitmq rabbitmq   20 Jun 24  2022 .erlang.cookie
dr--r-----  4 rabbitmq rabbitmq 4,0K Sep 19 15:55 mnesia

I was able to get the service running again by setting the correct permissions under /var/lib/rabbitmq/ and running a diagnostic rabbitmq-diagnostics status.

  1. chmod -R 750 /var/lib/rabbitmq/
  2. chmod 100 /var/lib/rabbitmq/.erlang.cookie
root@dc0:~/univention-support# ls -lah /var/lib/rabbitmq/
insgesamt 16K
drwxr-x---  3 rabbitmq rabbitmq 4,0K Jun 24  2022 .
drwxr-xr-x 86 root     root     4,0K Sep  4 20:55 ..
-r--------  1 rabbitmq rabbitmq   20 Jun 24  2022 .erlang.cookie
drwxr-x---  4 rabbitmq rabbitmq 4,0K Sep 26 05:14 mnesia
  1. rabbitmq-diagnostics status
root@dc0:~/univention-support# rabbitmq-diagnostics status
Status of node rabbit@dc0 ...  
Runtime

OS PID: 8637
OS: Linux
Uptime (seconds): 13
RabbitMQ version: 3.8.2
Node name: rabbit@dc0
Erlang configuration: Erlang/OTP 22 [erts-10.6.4] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:64]
Erlang processes: 286 used, 1048576 limit
Scheduler run queue: 1
Cluster heartbeat timeout (net_ticktime): 60

Plugins

Enabled plugin file: /etc/rabbitmq/enabled_plugins
Enabled plugins:


Data directory

Node data directory: /var/lib/rabbitmq/mnesia/rabbit@dc0

Config files

 * /etc/rabbitmq/rabbitmq.config

Log file(s)

 * /var/log/rabbitmq/rabbit@dc0.log
 * /var/log/rabbitmq/rabbit@dc0_upgrade.log

Alarms

(none)

Memory

Calculation strategy: rss
Memory high watermark setting: 0.4 of available memory, computed to: 3.334 gb
other_proc: 0.0273 gb (29.56 %)
code: 0.0268 gb (29.03 %)
reserved_unallocated: 0.0134 gb (14.58 %)
other_system: 0.0116 gb (12.59 %)
allocated_unused: 0.0085 gb (9.19 %)
other_ets: 0.0027 gb (2.91 %)  
atom: 0.0014 gb (1.56 %)
metrics: 0.0002 gb (0.21 %)
binary: 0.0001 gb (0.11 %)
mnesia: 0.0001 gb (0.1 %)
msg_index: 0.0001 gb (0.06 %)  
queue_procs: 0.0 gb (0.05 %)   
quorum_ets: 0.0 gb (0.05 %)
plugins: 0.0 gb (0.01 %)
connection_channels: 0.0 gb (0.0 %)
connection_other: 0.0 gb (0.0 %)
connection_readers: 0.0 gb (0.0 %)
connection_writers: 0.0 gb (0.0 %)
mgmt_db: 0.0 gb (0.0 %)
queue_slave_procs: 0.0 gb (0.0 %)
quorum_queue_procs: 0.0 gb (0.0 %)

File Descriptors

Total: 6, limit: 65439
Sockets: 0, limit: 58893

Free Disk Space

Low free disk space watermark: 0.05 gb
Free disk space: 19.6606 gb

Totals

Connection count: 0
Queue count: 2
Virtual host count: 2

Listeners

Interface: [::], port: 25672, protocol: clustering, purpose: inter-node and CLI tool communication
Interface: 127.0.0.1, port: 5672, protocol: amqp, purpose: AMQP 0-9-1 and AMQP 1.0
Interface: [::1], port: 5672, protocol: amqp, purpose: AMQP 0-9-1 and AMQP 1.0
  1. systemctl stop rabbitmq-server.service
  2. systemctl start rabbitmq-server.service
  3. systemctl status rabbitmq-server.service
root@dc0:~/univention-support# systemctl status rabbitmq-server.service
● rabbitmq-server.service - RabbitMQ Messaging Server
   Loaded: loaded (/lib/systemd/system/rabbitmq-server.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2024-09-26 05:21:37 CEST; 11s ago
 Main PID: 10250 (beam.smp)
   Status: "Initialized"
    Tasks: 87 (limit: 4915)
   Memory: 76.1M
   CGroup: /system.slice/rabbitmq-server.service
           ├─10246 /bin/sh /usr/sbin/rabbitmq-server
           ├─10250 /usr/lib/erlang/erts-10.6.4/bin/beam.smp -W w -A 64 -MBas ageffcbf -MHas ageffcbf -MBlmbcs 512 -MHlmbcs 512 -MMmcs 30 -P 1048576 -t 5000000 -stbt db -zdbbl 128000 -K true -- -root /usr/lib/erl
           ├─10507 erl_child_setup 65536
           ├─10553 inet_gethost 4
           └─10554 inet_gethost 4

Sep 26 05:21:30 dc0 systemd[1]: Starting RabbitMQ Messaging Server...
Sep 26 05:21:37 dc0 systemd[1]: rabbitmq-server.service: Supervising process 10250 which is not our child. We'll most likely not notice when it exits.
Sep 26 05:21:37 dc0 systemd[1]: Started RabbitMQ Messaging Server.
Mastodon