Skip to content

Migrated from Debian 11 to 12 with ansible playbook

Hi all,

I'm writing this problem to share my experience of upgrading this program. But in the end, I have a problem that I don't know how to solve. Maybe someone can help me.

Debian full-upgrade

Make the full-upgrade steps describe by debian projet.

Upgrade funkwhales via this ansible

Checkout this branch:

  • git checkout test-debian-12

Define the target version of funkwhales:

  • Bump latest version by define : funkwhale_version: 1.3.3

And I got this issue:

[17:01:41] ansible-funkwhale : Setup virtualenv | hifi.foobar.network | FAILED | 679ms
{
  - msg: :stderr: Could not find platform independent libraries <prefix>
         Could not find platform dependent libraries <exec_prefix>
         Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
         Python path configuration:
           PYTHONHOME = (not set)
           PYTHONPATH = (not set)
           program name = '/srv/funkwhale/virtualenv/bin/python3'
           isolated = 0
           environment = 1
           user site = 1
           import site = 1
           sys._base_executable = '/srv/funkwhale/virtualenv/bin/python3'
           sys.base_prefix = '/usr'
           sys.base_exec_prefix = '/usr'
           sys.platlibdir = 'lib'
           sys.executable = '/srv/funkwhale/virtualenv/bin/python3'
           sys.prefix = '/usr'
           sys.exec_prefix = '/usr'
           sys.path = [
             '/usr/lib/python39.zip',
             '/usr/lib/python3.9',
             '/usr/lib/lib-dynload',
           ]
         Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
         Python runtime state: core initialized
         ModuleNotFoundError: No module named 'encodings'
         
         Current thread 0x00007fe3fad37740 (most recent call first):
         <no Python frame>
  - cmd: [ 
    - /srv/funkwhale/virtualenv/bin/pip3
    - freeze
   ]
  - changed: False
}

Solved by : upgrade python-venv from 3.9 to 3.11.

su - funkwhales -s /bin/bash
python3 -m venv --upgrade ./virtualenv`

Second ansible run, I got another issue:

[17:22:52] ansible-funkwhale : Check if requirements.txt exists | hifi.foobar.network | FAILED | 364ms
{
  - msg: Permission denied
  - changed: False
}

Solved by : add become vars to task

- name: "Setup virtualenv"
  become: true
  become_user: "{{ funkwhale_username }}"
  pip:
    name:
      - "wheel"
      - "pip>=21.3"
      - "setuptools>=64"
    virtualenv: "{{ funkwhale_install_path }}/virtualenv"
    virtualenv_python: python3

Now, I stack on this issue:

Oct 17 17:48:58 hifi systemd[1]: funkwhale-server.service: Sending signal SIGHUP to process 5927 (gunicorn) on client request.
Oct 17 17:48:58 hifi gunicorn[5925]: [2023-10-17 17:48:58 +0200] [5925] [WARNING] Worker with pid 5927 was terminated due to signal 1
Oct 17 17:48:58 hifi gunicorn[5937]: [2023-10-17 17:48:58 +0200] [5937] [INFO] Booting worker with pid: 5937
Oct 17 17:48:58 hifi gunicorn[5937]: 2023-10-17 17:48:58,784 funkwhale_api.config INFO     Loaded env file at /srv/funkwhale/config/.env
Oct 17 17:48:58 hifi gunicorn[5937]: 2023-10-17 17:48:58,784 funkwhale_api.config INFO     Running with the following plugins enabled: funkwhale_api.contrib.scrobbler, funkwhale_api.contrib.listenbrainz, funkwhale_api.contrib.maloja
Oct 17 17:49:00 hifi gunicorn[5937]: [2023-10-17 15:49:00 +0000] [5937] [INFO] Started server process [5937]
Oct 17 17:49:00 hifi gunicorn[5937]: [2023-10-17 15:49:00 +0000] [5937] [INFO] Waiting for application startup.
Oct 17 17:49:00 hifi gunicorn[5937]: [2023-10-17 15:49:00 +0000] [5937] [INFO] ASGI 'lifespan' protocol appears unsupported.
Oct 17 17:49:00 hifi gunicorn[5937]: [2023-10-17 15:49:00 +0000] [5937] [INFO] Application startup complete.
Oct 17 17:49:16 hifi gunicorn[5937]: [2023-10-17 15:49:16 +0000] [5937] [INFO] ('10.0.0.1', 0) - "WebSocket /api/v1/activity?token=null" 403
Oct 17 17:49:16 hifi gunicorn[5937]: [2023-10-17 15:49:16 +0000] [5937] [INFO] connection failed (403 Forbidden)
Oct 17 17:49:16 hifi gunicorn[5937]: [2023-10-17 15:49:16 +0000] [5937] [INFO] connection closed
Oct 17 17:49:16 hifi gunicorn[5937]: [2023-10-17 15:49:16 +0000] [5937] [ERROR] Exception in ASGI application
Oct 17 17:49:16 hifi gunicorn[5937]: Traceback (most recent call last):
Oct 17 17:49:16 hifi gunicorn[5937]:   File "/srv/funkwhale/virtualenv/lib/python3.11/site-packages/uvicorn/protocols/websockets/websockets_impl.py", line 238, in run_asgi
Oct 17 17:49:16 hifi gunicorn[5937]:     result = await self.app(self.scope, self.asgi_receive, self.asgi_send)
Oct 17 17:49:16 hifi gunicorn[5937]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 17 17:49:16 hifi gunicorn[5937]:   File "/srv/funkwhale/virtualenv/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
Oct 17 17:49:16 hifi gunicorn[5937]:     return await self.app(scope, receive, send)
Oct 17 17:49:16 hifi gunicorn[5937]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 17 17:49:16 hifi gunicorn[5937]:   File "/srv/funkwhale/virtualenv/lib/python3.11/site-packages/channels/routing.py", line 62, in __call__
Oct 17 17:49:16 hifi gunicorn[5937]:     return await application(scope, receive, send)
Oct 17 17:49:16 hifi gunicorn[5937]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 17 17:49:16 hifi gunicorn[5937]:   File "/srv/funkwhale/virtualenv/lib/python3.11/site-packages/channels/sessions.py", line 47, in __call__
Oct 17 17:49:16 hifi gunicorn[5937]:     return await self.inner(dict(scope, cookies=cookies), receive, send)
Oct 17 17:49:16 hifi gunicorn[5937]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 17 17:49:16 hifi gunicorn[5937]:   File "/srv/funkwhale/virtualenv/lib/python3.11/site-packages/channels/sessions.py", line 263, in __call__
Oct 17 17:49:16 hifi gunicorn[5937]:     return await self.inner(wrapper.scope, receive, wrapper.send)
Oct 17 17:49:16 hifi gunicorn[5937]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 17 17:49:16 hifi gunicorn[5937]:   File "/srv/funkwhale/virtualenv/lib/python3.11/site-packages/channels/auth.py", line 185, in __call__
Oct 17 17:49:16 hifi gunicorn[5937]:     return await super().__call__(scope, receive, send)
Oct 17 17:49:16 hifi gunicorn[5937]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 17 17:49:16 hifi gunicorn[5937]:   File "/srv/funkwhale/virtualenv/lib/python3.11/site-packages/channels/middleware.py", line 24, in __call__
Oct 17 17:49:16 hifi gunicorn[5937]:     return await self.inner(scope, receive, send)
Oct 17 17:49:16 hifi gunicorn[5937]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 17 17:49:16 hifi gunicorn[5937]:   File "/srv/funkwhale/virtualenv/lib/python3.11/site-packages/channels/routing.py", line 116, in __call__
Oct 17 17:49:16 hifi gunicorn[5937]:     return await application(
Oct 17 17:49:16 hifi gunicorn[5937]:            ^^^^^^^^^^^^^^^^^^
Oct 17 17:49:16 hifi gunicorn[5937]:   File "/srv/funkwhale/virtualenv/lib/python3.11/site-packages/channels/consumer.py", line 94, in app
Oct 17 17:49:16 hifi gunicorn[5937]:     return await consumer(scope, receive, send)
Oct 17 17:49:16 hifi gunicorn[5937]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 17 17:49:16 hifi gunicorn[5937]:   File "/srv/funkwhale/virtualenv/lib/python3.11/site-packages/channels/consumer.py", line 58, in __call__
Oct 17 17:49:16 hifi gunicorn[5937]:     await await_many_dispatch(
Oct 17 17:49:16 hifi gunicorn[5937]:   File "/srv/funkwhale/virtualenv/lib/python3.11/site-packages/channels/utils.py", line 50, in await_many_dispatch
Oct 17 17:49:16 hifi gunicorn[5937]:     await dispatch(result)
Oct 17 17:49:16 hifi gunicorn[5937]:   File "/srv/funkwhale/virtualenv/lib/python3.11/site-packages/asgiref/sync.py", line 479, in __call__
Oct 17 17:49:16 hifi gunicorn[5937]:     ret: _R = await loop.run_in_executor(
Oct 17 17:49:16 hifi gunicorn[5937]:               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 17 17:49:16 hifi gunicorn[5937]:   File "/usr/lib/python3.11/concurrent/futures/thread.py", line 58, in run
Oct 17 17:49:16 hifi gunicorn[5937]:     result = self.fn(*self.args, **self.kwargs)
Oct 17 17:49:16 hifi gunicorn[5937]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 17 17:49:16 hifi gunicorn[5937]:   File "/srv/funkwhale/virtualenv/lib/python3.11/site-packages/channels/db.py", line 13, in thread_handler
Oct 17 17:49:16 hifi gunicorn[5937]:     return super().thread_handler(loop, *args, **kwargs)
Oct 17 17:49:16 hifi gunicorn[5937]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 17 17:49:16 hifi gunicorn[5937]:   File "/srv/funkwhale/virtualenv/lib/python3.11/site-packages/asgiref/sync.py", line 538, in thread_handler
Oct 17 17:49:16 hifi gunicorn[5937]:     return func(*args, **kwargs)
Oct 17 17:49:16 hifi gunicorn[5937]:            ^^^^^^^^^^^^^^^^^^^^^
Oct 17 17:49:16 hifi gunicorn[5937]:   File "/srv/funkwhale/virtualenv/lib/python3.11/site-packages/channels/consumer.py", line 125, in dispatch
Oct 17 17:49:16 hifi gunicorn[5937]:     handler(message)
Oct 17 17:49:16 hifi gunicorn[5937]:   File "/srv/funkwhale/virtualenv/lib/python3.11/site-packages/channels/generic/websocket.py", line 105, in websocket_disconnect
Oct 17 17:49:16 hifi gunicorn[5937]:     self.disconnect(message["code"])
Oct 17 17:49:16 hifi gunicorn[5937]:   File "/srv/funkwhale/api/funkwhale_api/common/consumers.py", line 22, in disconnect
Oct 17 17:49:16 hifi gunicorn[5937]:     groups = self.scope["user"].get_channels_groups() + self.groups
Oct 17 17:49:16 hifi gunicorn[5937]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 17 17:49:16 hifi gunicorn[5937]:   File "/srv/funkwhale/virtualenv/lib/python3.11/site-packages/django/utils/functional.py", line 247, in inner
Oct 17 17:49:16 hifi gunicorn[5937]:     return func(self._wrapped, *args)
Oct 17 17:49:16 hifi gunicorn[5937]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 17 17:49:16 hifi gunicorn[5937]: AttributeError: 'AnonymousUser' object has no attribute 'get_channels_groups'
Oct 17 17:50:22 hifi gunicorn[5937]: [2023-10-17 15:50:22 +0000] [5937] [INFO] ('10.0.0.1', 0) - "WebSocket /api/v1/activity?token=null" 403
Oct 17 17:50:22 hifi gunicorn[5937]: [2023-10-17 15:50:22 +0000] [5937] [INFO] connection failed (403 Forbidden)
Oct 17 17:50:22 hifi gunicorn[5937]: [2023-10-17 15:50:22 +0000] [5937] [INFO] connection closed

Cheers