ucphhpc / docker-migrid

Containerized MiG
GNU General Public License v2.0
3 stars 6 forks source link

Bug: Cannot load modules/mod_wsgi_python3.so #19

Closed benibr closed 1 year ago

benibr commented 1 year ago

I experience a bug with the current version:

When I clone the repo and run make I get the error below. I had look inside the container, the file is missing, only mod_wsgi.so exists.

I also had the problem the other way around but I'm not sure how this is triggered. I guess this has something todo with PREFER_PYTHON3 and WITH_PY3, which are both set to False in the default example.

Any ideas how to fix this permanently?

migrid  | INFO: Enforcing timezone Europe/Copenhagen (/usr/share/zoneinfo/Europe/Copenhagen)
migrid  | Creating or renewing user: test@migrid.testing
migrid  | Created or updated /C=DK/ST=NA/L=NA/O=Test Org/OU=NA/CN=Test User/emailAddress=test@migrid.testing in user database and in file system
migrid  | Ensure correct permissions for test@migrid.testing
migrid  | chown: changing ownership of ‘/home/mig/state/vgrid_files_readonly’: Read-only file system
migrid  | Add sftp password login for test@migrid.testing
migrid  | Traceback (most recent call last):
migrid  |   File "/home/mig/mig/cgi-bin/fakecgi.py", line 87, in <module>
migrid  |     client_id, csrf_limit)
migrid  |   File "/home/mig/mig/shared/pwhash.py", line 532, in make_csrf_token
migrid  |     xor_id = "%s" % (int(salt, 16) ^ int(b16encode(force_utf8(merged)), 16))
migrid  | ValueError: invalid literal for int() with base 16: ''
migrid  | Failed to set sftp password login
migrid  | Add ftps password login for test@migrid.testing
migrid  | Traceback (most recent call last):
migrid  |   File "/home/mig/mig/cgi-bin/fakecgi.py", line 87, in <module>
migrid  |     client_id, csrf_limit)
migrid  |   File "/home/mig/mig/shared/pwhash.py", line 532, in make_csrf_token
migrid  |     xor_id = "%s" % (int(salt, 16) ^ int(b16encode(force_utf8(merged)), 16))
migrid  | ValueError: invalid literal for int() with base 16: ''
migrid  | Failed to set ftps password login
migrid  | Add webdavs password login for test@migrid.testing
migrid  | Traceback (most recent call last):
migrid  |   File "/home/mig/mig/cgi-bin/fakecgi.py", line 87, in <module>
migrid  |     client_id, csrf_limit)
migrid  |   File "/home/mig/mig/shared/pwhash.py", line 532, in make_csrf_token
migrid  |     xor_id = "%s" % (int(salt, 16) ^ int(b16encode(force_utf8(merged)), 16))
migrid  | ValueError: invalid literal for int() with base 16: ''
migrid  | Failed to set webdavs password login
migrid  | Run services: httpd script monitor sshmux events cron transfers imnotify vmproxy rsyslogd
migrid  | httpd: Syntax error on line 50 of /etc/httpd/conf/httpd.conf: Cannot load modules/mod_wsgi_python3.so into server: /etc/httpd/modules/mod_wsgi_python3.so: cannot open shared object file: No such file or directory
migrid  | Failed to start httpd: 1
migrid exited with code 1
jonasbardino commented 1 year ago

mod_wsgi_python3.so is the python3 version of the WSGI module, which offers a persistent python interpreter instance inside Apache rather than full process launch every time. It should of course only be loaded when available/enabled in the container. AFAIK we already have some logic to handle that, but something may be missing for the simple case. I'll take a look.

The initial errors look like missing or invalid digest_salt and password_salt values e.g. from pointing to non-existing salt files.

jonasbardino commented 1 year ago

AFAICT the underlying generateconfs.py script correctly comments/uncomments the relevant module load lines depending on the --prefer_python3=Boolean value in the mimic-deb.conf, which docker build copies into httpd/conf/httpd.conf .

... --prefer_python3=False > /dev/null
0|~/mig/install > grep wsgi generated-confs/mimic-deb.conf
LoadModule wsgi_module modules/mod_wsgi.so
#LoadModule wsgi_module modules/mod_wsgi_python3.so

vs.

... --prefer_python3=True > /dev/null
0|~/mig/install > grep wsgi generated-confs/mimic-deb.conf
#LoadModule wsgi_module modules/mod_wsgi.so
LoadModule wsgi_module modules/mod_wsgi_python3.so
jonasbardino commented 1 year ago

I can't reproduce that error here. Please double check docker setup and caches, and provide more details about the platform and versions if the problem persists. The fact that you get those empty string salt errors might indicate that you somehow don't use the clean defaults as salt vars are left unset there and therefore get auto-filled to valid random values in MiGserver.conf like in my test now:

0|~/docker-migrid > grep salt mig/server/MiGserver.conf|grep -v '#'
digest_salt = 79C7BCCD4C6D7A33DB53206DC34AECCC
crypto_salt = E866230380076CD9F87FCB7C42888F3F
benibr commented 1 year ago

Thanks for investigating!

I found out that the error occours when docker volumes from another setup are still existing. Since make distclean does not remove the named volumes, they might still point to an old httpd folder.

I guess we should discuss about how we use volumes in this repo. But thats for another time.

jonasbardino commented 1 year ago

You're welcome, and yes, there might be some work on the matter. Again this is an area where you might have better insight and ideas than the 'it sort of works' solution we have now :-)