goauthentik / authentik

The authentication glue you need.
https://goauthentik.io
Other
13.29k stars 887 forks source link

2023.8.2 update error #6842

Closed boesr closed 1 year ago

boesr commented 1 year ago

Describe the bug I updated a Authentik 2023.6.2 version to 2023.8.2. Afterwards it couldn't start anymore. The same problem exists with a new instance. I use a separate Postgresql instance (15).

To Reproduce Steps to reproduce the behavior:

  1. Change Authentik Tag to 2023.8.2
  2. docker compose up -d

Expected behavior Running the new version with external postgres db.

Logs

{"event": "Internal Server Error: /api/v3/outposts/instances/", "exception": [{"exc_type": "OperationalError", "exc_value": "consuming input failed: unable to execute Describe\nDETAIL:  unable to get the bind message\nserver closed the connection unexpectedly\n\tThis probably means the server terminated abnormally\n\tbefore or while processing the request.", "frames": [{"filename": "/usr/local/lib/python3.11/site-packages/asgiref/sync.py", "line": "", "lineno": 534, "locals": {"__traceback_hide__": "True", "args": "'(functools.partial(<function response_for_exception at 0xffff8b1dd580>, <ASGIReq'+298", "current_thread": "<Thread(ThreadPoolExecutor-83_0, started 281472199881120)>", "exc_info": "\"(<class 'django.db.utils.OperationalError'>, OperationalError('consuming input f\"+257", "func": "<built-in method run of _contextvars.Context object at 0xffff7a039100>", "kwargs": "{}", "loop": "<uvloop.Loop running=True closed=False debug=False>", "parent_set": "True", "self": "<asgiref.sync.SyncToAsync object at 0xffff7a038910>", "source_task": "None"}, "name": "thread_handler"}, {"filename": "/usr/local/lib/python3.11/site-packages/django/core/handlers/exception.py", "line": "", "lineno": 42, "locals": {"exc": "\"OperationalError('consuming input failed: unable to execute Describe\\\\nDETAIL:  u\"+173", "get_response": "'<bound method BaseHandler._get_response_async of <django.core.handlers.asgi.ASGI'+34", "request": "<ASGIRequest: GET '/api/v3/outposts/instances/'>"}, "name": "inner"}, {"filename": "/usr/local/lib/python3.11/site-packages/asgiref/sync.py", "line": "", "lineno": 534, "locals": {"__traceback_hide__": "True", "args": "'(functools.partial(<bound method BaseHandler.process_exception_by_middleware of '+373", "current_thread": "<Thread(ThreadPoolExecutor-81_0, started 281472182972832)>", "exc_info": "\"(<class 'django.db.utils.OperationalError'>, OperationalError('consuming input f\"+257", "func": "<built-in method run of _contextvars.Context object at 0xffff78700dc0>", "kwargs": "{}", "loop": "<uvloop.Loop running=True closed=False debug=False>", "parent_set": "False", "self": "<asgiref.sync.SyncToAsync object at 0xffff7a0b2a90>", "source_task": "None"}, "name": "thread_handler"}, {"filename": "/usr/local/lib/python3.11/site-packages/django/core/handlers/base.py", "line": "", "lineno": 253, "locals": {"callback": "<function OutpostViewSet at 0xffff7c56a480>", "callback_args": "()", "callback_kwargs": "{}", "middleware_method": "<asgiref.sync.SyncToAsync object at 0xffff7c41d7d0>", "request": "<ASGIRequest: GET '/api/v3/outposts/instances/'>", "response": "None", "self": "<django.core.handlers.asgi.ASGIHandler object at 0xffff7ca15250>", "wrapped_callback": "<asgiref.sync.SyncToAsync object at 0xffff7a109190>"}, "name": "_get_response_async"}, {"filename": "/usr/local/lib/python3.11/site-packages/asgiref/sync.py", "line": "", "lineno": 479, "locals": {"__traceback_hide__": "True", "args": "(<ASGIRequest: GET '/api/v3/outposts/instances/'>,)", "child": "'functools.partial(<function OutpostViewSet at 0xffff7c56a480>, <ASGIRequest: GET'+32", "context": "<_contextvars.Context object at 0xffff7a0bdb40>", "executor": "<asgiref.current_thread_executor.CurrentThreadExecutor object at 0xffff786f6d50>", "func": "<built-in method run of _contextvars.Context object at 0xffff7a0bdb40>", "kwargs": "{}", "loop": "<uvloop.Loop running=True closed=False debug=False>", "self": "<asgiref.sync.SyncToAsync object at 0xffff7a109190>"}, "name": "__call__"}, {"filename": "/usr/local/lib/python3.11/site-packages/asgiref/current_thread_executor.py", "line": "", "lineno": 40, "locals": {"__traceback_hide__": "True", "self": "None"}, "name": "run"}, {"filename": "/usr/local/lib/python3.11/site-packages/asgiref/sync.py", "line": "", "lineno": 538, "locals": {"__traceback_hide__": "True", "args": "'(functools.partial(<function OutpostViewSet at 0xffff7c56a480>, <ASGIRequest: GE'+35", "current_thread": "<Thread(ThreadPoolExecutor-81_0, started 281472182972832)>", "exc_info": "(None, None, None)", "func": "<built-in method run of _contextvars.Context object at 0xffff7a0bdb40>", "kwargs": "{}", "loop": "<uvloop.Loop running=True closed=False debug=False>", "parent_set": "False", "self": "<asgiref.sync.SyncToAsync object at 0xffff7a109190>", "source_task": "None"}, "name": "thread_handler"}, {"filename": "/usr/local/lib/python3.11/site-packages/django/views/decorators/csrf.py", "line": "", "lineno": 56, "locals": {"args": "(<ASGIRequest: GET '/api/v3/outposts/instances/'>,)", "kwargs": "{}", "view_func": "<function OutpostViewSet at 0xffff7c56a3e0>"}, "name": "wrapper_view"}, {"filename": "/usr/local/lib/python3.11/site-packages/rest_framework/viewsets.py", "line": "", "lineno": 125, "locals": {"action": "list", "actions": "{'get': 'list', 'post': 'create', 'head': 'list'}", "args": "()", "cls": "<class 'authentik.outposts.api.outposts.OutpostViewSet'>", "handler": "'<bound method ListModelMixin.list of <authentik.outposts.api.outposts.OutpostVie'+31", "initkwargs": "{'suffix': 'List', 'basename': 'outpost', 'detail': False}", "kwargs": "{}", "method": "head", "request": "<ASGIRequest: GET '/api/v3/outposts/instances/'>", "self": "<authentik.outposts.api.outposts.OutpostViewSet object at 0xffff7ba7a210>"}, "name": "view"}, {"filename": "/usr/local/lib/python3.11/site-packages/rest_framework/views.py", "line": "", "lineno": 509, "locals": {"args": "()", "handler": "'<bound method ListModelMixin.list of <authentik.outposts.api.outposts.OutpostVie'+31", "kwargs": "{}", "request": "<rest_framework.request.Request: GET '/api/v3/outposts/instances/'>", "self": "<authentik.outposts.api.outposts.OutpostViewSet object at 0xffff7ba7a210>"}, "name": "dispatch"}, {"filename": "/usr/local/lib/python3.11/site-packages/rest_framework/views.py", "line": "", "lineno": 469, "locals": {"context": "\"{'view': <authentik.outposts.api.outposts.OutpostViewSet object at 0xffff7ba7a21\"+109", "exc": "\"OperationalError('consuming input failed: unable to execute Describe\\\\nDETAIL:  u\"+173", "exception_handler": "<function exception_handler at 0xffff7fad0d60>", "response": "None", "self": "<authentik.outposts.api.outposts.OutpostViewSet object at 0xffff7ba7a210>"}, "name": "handle_exception"}, {"filename": "/usr/local/lib/python3.11/site-packages/rest_framework/views.py", "line": "", "lineno": 480, "locals": {"exc": "\"OperationalError('consuming input failed: unable to execute Describe\\\\nDETAIL:  u\"+173", "self": "<authentik.outposts.api.outposts.OutpostViewSet object at 0xffff7ba7a210>"}, "name": "raise_uncaught_exception"}, {"filename": "/usr/local/lib/python3.11/site-packages/rest_framework/views.py", "line": "", "lineno": 506, "locals": {"args": "()", "handler": "'<bound method ListModelMixin.list of <authentik.outposts.api.outposts.OutpostVie'+31", "kwargs": "{}", "request": "<rest_framework.request.Request: GET '/api/v3/outposts/instances/'>", "self": "<authentik.outposts.api.outposts.OutpostViewSet object at 0xffff7ba7a210>"}, "name": "dispatch"}, {"filename": "/usr/local/lib/python3.11/site-packages/rest_framework/mixins.py", "line": "", "lineno": 38, "locals": {"args": "()", "kwargs": "{}", "request": "<rest_framework.request.Request: GET '/api/v3/outposts/instances/'>", "self": "<authentik.outposts.api.outposts.OutpostViewSet object at 0xffff7ba7a210>"}, "name": "list"}, {"filename": "/usr/local/lib/python3.11/site-packages/rest_framework/generics.py", "line": "", "lineno": 150, "locals": {"backend": "<class 'rest_framework_guardian.filters.ObjectPermissionsFilter'>", "queryset": "<QuerySet [<Outpost: Outpost authentik Embedded Outpost>]>", "self": "<authentik.outposts.api.outposts.OutpostViewSet object at 0xffff7ba7a210>"}, "name": "filter_queryset"}, {"filename": "/usr/local/lib/python3.11/site-packages/rest_framework_guardian/filters.py", "line": "", "lineno": 28, "locals": {"get_objects_for_user": "<function get_objects_for_user at 0xffff85101120>", "permission": "authentik_outposts.view_outpost", "queryset": "<QuerySet [<Outpost: Outpost authentik Embedded Outpost>]>", "request": "<rest_framework.request.Request: GET '/api/v3/outposts/instances/'>", "self": "'<rest_framework_guardian.filters.ObjectPermissionsFilter object at 0xffff7a07d89'+2", "user": "<User: ak-outpost-08b31b1cfde94e0d8fe543da72c71af3>", "view": "<authentik.outposts.api.outposts.OutpostViewSet object at 0xffff7ba7a210>"}, "name": "filter_queryset"}, {"filename": "/usr/local/lib/python3.11/site-packages/guardian/shortcuts.py", "line": "", "lineno": 542, "locals": {"accept_global_perms": "False", "any_perm": "False", "app_label": "authentik_outposts", "codename": "view_outpost", "codenames": "{'view_outpost'}", "ctype": "<ContentType: authentik_outposts | outpost>", "klass": "<QuerySet [<Outpost: Outpost authentik Embedded Outpost>]>", "new_app_label": "authentik_outposts", "new_ctype": "<ContentType: authentik_outposts | outpost>", "perm": "authentik_outposts.view_outpost", "perms": "['authentik_outposts.view_outpost']", "queryset": "<QuerySet [<Outpost: Outpost authentik Embedded Outpost>]>", "use_groups": "True", "user": "<User: ak-outpost-08b31b1cfde94e0d8fe543da72c71af3>", "with_superuser": "True"}, "name": "get_objects_for_user"}, {"filename": "/usr/local/lib/python3.11/site-packages/django/utils/functional.py", "line": "", "lineno": 57, "locals": {"cls": "<class 'authentik.core.models.User'>", "instance": "<User: ak-outpost-08b31b1cfde94e0d8fe543da72c71af3>", "self": "<django.utils.functional.cached_property object at 0xffff84b12150>"}, "name": "__get__"}, {"filename": "/authentik/core/models.py", "line": "", "lineno": 211, "locals": {"self": "<User: ak-outpost-08b31b1cfde94e0d8fe543da72c71af3>"}, "name": "is_superuser"}, {"filename": "/authentik/core/models.py", "line": "", "lineno": 163, "locals": {"self": "<User: ak-outpost-08b31b1cfde94e0d8fe543da72c71af3>"}, "name": "all_groups"}, {"filename": "/authentik/core/models.py", "line": "", "lineno": 163, "locals": {".0": "<generator object QuerySet._iterator at 0xffff7bb268a0>"}, "name": "<genexpr>"}, {"filename": "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", "line": "", "lineno": 516, "locals": {"chunk_size": "None", "iterable": "<django.db.models.query.FlatValuesListIterable object at 0xffff7bb0f510>", "self": "<QuerySet []>", "use_chunked_fetch": "True"}, "name": "_iterator"}, {"filename": "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", "line": "", "lineno": 285, "locals": {"compiler": "\"<SQLCompiler model=Group connection=<DatabaseWrapper vendor='postgresql' alias='\"+26", "queryset": "<QuerySet []>", "self": "<django.db.models.query.FlatValuesListIterable object at 0xffff7bb0f510>"}, "name": "__iter__"}, {"filename": "/usr/local/lib/python3.11/site-packages/django/db/models/sql/compiler.py", "line": "", "lineno": 1513, "locals": {"chunk_size": "2000", "chunked_fetch": "True", "results": "None", "self": "\"<SQLCompiler model=Group connection=<DatabaseWrapper vendor='postgresql' alias='\"+26", "tuple_expected": "False"}, "name": "results_iter"}, {"filename": "/usr/local/lib/python3.11/site-packages/django/db/models/sql/compiler.py", "line": "", "lineno": 1562, "locals": {"chunk_size": "2000", "chunked_fetch": "True", "cursor": "<django.db.backends.utils.CursorWrapper object at 0xffff78716ad0>", "params": "(2,)", "result_type": "multi", "self": "\"<SQLCompiler model=Group connection=<DatabaseWrapper vendor='postgresql' alias='\"+26", "sql": "'SELECT \"authentik_core_group\".\"group_uuid\" FROM \"authentik_core_group\" INNER JOI'+172"}, "name": "execute_sql"}, {"filename": "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", "line": "", "lineno": 67, "locals": {"params": "(2,)", "self": "<django.db.backends.utils.CursorWrapper object at 0xffff78716ad0>", "sql": "'SELECT \"authentik_core_group\".\"group_uuid\" FROM \"authentik_core_group\" INNER JOI'+172"}, "name": "execute"}, {"filename": "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", "line": "", "lineno": 80, "locals": {"context": "\"{'connection': <DatabaseWrapper vendor='postgresql' alias='default'>, 'cursor': \"+66", "executor": "'<bound method CursorWrapper._execute of <django.db.backends.utils.CursorWrapper '+26", "many": "False", "params": "(2,)", "self": "<django.db.backends.utils.CursorWrapper object at 0xffff78716ad0>", "sql": "'SELECT \"authentik_core_group\".\"group_uuid\" FROM \"authentik_core_group\" INNER JOI'+172"}, "name": "_execute_with_wrappers"}, {"filename": "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", "line": "", "lineno": 84, "locals": {"ignored_wrapper_args": "\"(False, {'connection': <DatabaseWrapper vendor='postgresql' alias='default'>, 'c\"+75", "params": "(2,)", "self": "<django.db.backends.utils.CursorWrapper object at 0xffff78716ad0>", "sql": "'SELECT \"authentik_core_group\".\"group_uuid\" FROM \"authentik_core_group\" INNER JOI'+172"}, "name": "_execute"}, {"filename": "/usr/local/lib/python3.11/site-packages/django/db/utils.py", "line": "", "lineno": 91, "locals": {"db_exc_type": "<class 'psycopg.OperationalError'>", "dj_exc_type": "<class 'django.db.utils.OperationalError'>", "dj_exc_value": "\"OperationalError('consuming input failed: unable to execute Describe\\\\nDETAIL:  u\"+173", "exc_type": "<class 'psycopg.OperationalError'>", "exc_value": "\"OperationalError('consuming input failed: unable to execute Describe\\\\nDETAIL:  u\"+173", "self": "<django.db.utils.DatabaseErrorWrapper object at 0xffff7a07ffd0>", "traceback": "<traceback object at 0xffff7a0624c0>"}, "name": "__exit__"}, {"filename": "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", "line": "", "lineno": 89, "locals": {"ignored_wrapper_args": "\"(False, {'connection': <DatabaseWrapper vendor='postgresql' alias='default'>, 'c\"+75", "params": "(2,)", "self": "<django.db.backends.utils.CursorWrapper object at 0xffff78716ad0>", "sql": "'SELECT \"authentik_core_group\".\"group_uuid\" FROM \"authentik_core_group\" INNER JOI'+172"}, "name": "_execute"}, {"filename": "/usr/local/lib/python3.11/site-packages/psycopg/server_cursor.py", "line": "", "lineno": 294, "locals": {"binary": "None", "kwargs": "{}", "params": "(2,)", "query": "'SELECT \"authentik_core_group\".\"group_uuid\" FROM \"authentik_core_group\" INNER JOI'+172", "self": "\"<psycopg.ServerCursor '_django_curs_281472182972832_sync_1' [closed] [BAD] at 0x\"+13"}, "name": "execute"}], "is_cause": false, "syntax_error": null}, {"exc_type": "OperationalError", "exc_value": "consuming input failed: unable to execute Describe\nDETAIL:  unable to get the bind message\nserver closed the connection unexpectedly\n\tThis probably means the server terminated abnormally\n\tbefore or while processing the request.", "frames": [{"filename": "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", "line": "", "lineno": 89, "locals": {"ignored_wrapper_args": "\"(False, {'connection': <DatabaseWrapper vendor='postgresql' alias='default'>, 'c\"+75", "params": "(2,)", "self": "<django.db.backends.utils.CursorWrapper object at 0xffff78716ad0>", "sql": "'SELECT \"authentik_core_group\".\"group_uuid\" FROM \"authentik_core_group\" INNER JOI'+172"}, "name": "_execute"}, {"filename": "/usr/local/lib/python3.11/site-packages/psycopg/server_cursor.py", "line": "", "lineno": 294, "locals": {"binary": "None", "kwargs": "{}", "params": "(2,)", "query": "'SELECT \"authentik_core_group\".\"group_uuid\" FROM \"authentik_core_group\" INNER JOI'+172", "self": "\"<psycopg.ServerCursor '_django_curs_281472182972832_sync_1' [closed] [BAD] at 0x\"+13"}, "name": "execute"}], "is_cause": true, "syntax_error": null}], "level": "error", "logger": "django.request", "timestamp": 1694440699.7994626}
{"auth_via": "secret_key", "event": "/api/v3/outposts/instances/", "host": "localhost:8000", "level": "info", "logger": "authentik.asgi", "method": "GET", "pid": 67, "remote": "127.0.0.1", "request_id": "c66af8b20f5f42809d875aef13e0cd24", "runtime": 1002, "scheme": "http", "status": 500, "timestamp": "2023-09-11T13:58:20.193035", "user": "ak-outpost-08b31b1cfde94e0d8fe543da72c71af3", "user_agent": "goauthentik.io/outpost/2023.8.2"}
{"error":"500 Internal Server Error","event":"Failed to fetch outpost configuration, retrying in 3 seconds","level":"error","logger":"authentik.outpost.ak-api-controller","timestamp":"2023-09-11T13:58:20Z"}

Version and Deployment (please complete the following information):

Additional context

Minimal tested docker-compose.yml

version: "3.4"

services:
  redis:
    image: docker.io/library/redis:alpine
    command: --save 60 1 --loglevel warning
    restart: unless-stopped
    healthcheck:
      test: ["CMD-SHELL", "redis-cli ping | grep PONG"]
      start_period: 20s
      interval: 30s
      retries: 5
      timeout: 3s
    volumes:
      - redis:/data
  server:
    image: ${AUTHENTIK_IMAGE:-ghcr.io/goauthentik/server}:${AUTHENTIK_TAG:-2023.8.2}
    restart: unless-stopped
    command: server
    environment:
      AUTHENTIK_REDIS__HOST: redis
      AUTHENTIK_POSTGRESQL__USER: ${PG_USER:-authentik}
      AUTHENTIK_POSTGRESQL__NAME: ${PG_DB:-authentik}
      AUTHENTIK_POSTGRESQL__PASSWORD: ${PG_PASS}
    volumes:
      - ./media:/media
      - ./custom-templates:/templates
    env_file:
      - .env
    ports:
      - "${COMPOSE_PORT_HTTP:-9000}:9000"
      - "${COMPOSE_PORT_HTTPS:-9443}:9443"
    depends_on:
      - redis
  worker:
    image: ${AUTHENTIK_IMAGE:-ghcr.io/goauthentik/server}:${AUTHENTIK_TAG:-2023.8.2}
    restart: unless-stopped
    command: worker
    environment:
      AUTHENTIK_REDIS__HOST: redis
      AUTHENTIK_POSTGRESQL__USER: ${PG_USER:-authentik}
      AUTHENTIK_POSTGRESQL__NAME: ${PG_DB:-authentik}
      AUTHENTIK_POSTGRESQL__PASSWORD: ${PG_PASS}
    # `user: root` and the docker socket volume are optional.
    # See more for the docker socket integration here:
    # https://goauthentik.io/docs/outposts/integrations/docker
    # Removing `user: root` also prevents the worker from fixing the permissions
    # on the mounted folders, so when removing this make sure the folders have the correct UID/GID
    # (1000:1000 by default)
    user: root
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./media:/media
      - ./certs:/certs
      - ./custom-templates:/templates
    env_file:
      - .env
    depends_on:
      - redis

volumes:
  redis:
    driver: local

.env

PG_PASS=mypass
AUTHENTIK_SECRET_KEY=mysecret
AUTHENTIK_POSTGRESQL__HOST=postgres.ip
AUTHENTIK_POSTGRESQL__PORT=postgres.port
PG_USER=postgres.user
PG_PASS=postgres.password
boesr commented 1 year ago

Can be closed. Issue is probably due to the use of a pgpool instance. Using AUTHENTIK_POSTGRESQL__USE_PGBOUNCER=true fixes it.

This was not necessary before.