YunoHost-Apps / synapse_ynh

Matrix server (synapse) package for YunoHost
https://matrix.org/
GNU General Public License v3.0
79 stars 42 forks source link

venv needs to be recreated/regenerated when migrating to bullseye #302

Closed autra closed 11 months ago

autra commented 2 years ago

Describe the bug

When beta-testing the bullseye migration as described here on an instance with synapse_ynh installed, the synapse server fails to start after the serveur reboot.

Context

Steps to reproduce

Expected behavior

The service restarts correctly, the server is working

Actual behavior

The service does not start until the venv is recreated

Logs

the start error is:

Mar 09 20:46:16 trancart.eu python[31856]: /opt/yunohost/matrix-synapse/bin/python: Error while finding module specification for 'synapse.app.homeserver' (ModuleNotFoundError: No module named 'synapse')

Analysis

Migrating to bullseye involves recreating the venv of synapse, as synapse uses the system python3 (and it is updated when migrating to bullseye).

One possible fix would be to recreate the venv if python version is 3.9 and /opt/yunohost/matrix-synapse/lib/python3.7/ exists during an upgrade. Admin would need to upgrade the app after bullseye migration, but it'll work.

As discussed on the app channel, another possible fix is to implement a "distro upgrade" hook in yunohost core, and implement the venv recreation in this hook. The advantage of such approach is that admin won't need to do anything to have synapse in a working state after the upgrade. Another advantage is that the work would be done for next debian release (after bullseye). But it needs some work on yunohost itself.

Josue-T commented 2 years ago

Hello,

We already recreate the venv if needed but only if we upgrade the source. And in the debian upgrade the package don't need at all case an upgrade of the package. Maybe I need to force to reinstall the source if the python version changed.

Josue-T commented 2 years ago

Well normally the upgrade should work as I already force to recreate the venv when the python version changed here: https://github.com/YunoHost-Apps/synapse_ynh/blob/master/scripts/upgrade#L165

autra commented 2 years ago

We already recreate the venv if needed but only if we upgrade the source.

Yes, if there is an upgrade, it will work.

I think the hook would still be necessary to trigger such a reinstallation, what do you think?

Josue-T commented 2 years ago

Well yes in restoration we could add something to restore the venv if python version changed.

autra commented 2 years ago

I don't get how the restoration script would help in case of a migration to another debian distro.