nix-community / authentik-nix

Nix flake with package, NixOS module and basic VM test for authentik. Trying to provide an alternative deployment mode to the officially supported docker-compose approach. Not affiliated with or officially supported by the authentik project [maintainer=@willibutz]
MIT License
82 stars 18 forks source link

Errors wihle sending Emails, `FileNotFoundError` #6

Closed shokinn closed 10 months ago

shokinn commented 11 months ago

Hi, while sending emails I'll get those FileNotFoundError exception for web/dist:

Dec 10 19:34:56 shel1sso00 server[575814]: {"auth_via": "unauthenticated", "event": "/api/v3/flows/executor/s1q-recovery/?query=next%3D%252F", "host": "sso.example.tld", "level": "info", "logger": "authentik.asgi", "method": "GET", "pid": 575814, "remote": "aaa.xxx.yyy.zzz", "request_id": "0a9fdf11508f4ccfa9d5c0774ec64c>
Dec 10 19:34:56 shel1sso00 server[227267]: {"event":"/static/dist/flow/EmailStage-9Jhcx8Qm.js","host":"sso.example.tld","level":"info","logger":"authentik.router","method":"GET","remote":"aaa.xxx.yyy.zzz","runtime":"0.652","scheme":"https","size":9254,"status":200,"timestamp":"2023-12-10T19:34:56Z","user_agent":"Mozilla>
Dec 10 19:34:57 shel1sso00 celery[579432]: {"event": "Task published", "level": "info", "logger": "authentik.root.celery", "pid": 579432, "task_id": "4c7403008a7544bbb8f7f9125bf23586", "task_name": "authentik.stages.email.tasks.send_mail", "timestamp": "2023-12-10T19:34:57.776696"}
Dec 10 19:34:57 shel1sso00 celery[579432]: {"event": "Task finished", "level": "info", "logger": "authentik.root.celery", "pid": 579432, "state": "RETRY", "task_id": "4c7403008a7544bbb8f7f9125bf23586", "task_name": "send_mail", "timestamp": "2023-12-10T19:34:57.784838"}
Dec 10 19:34:58 shel1sso00 celery[579503]: {"event": "Task started", "level": "info", "logger": "authentik.root.celery", "pid": 579503, "task_id": "4c740300-8a75-44bb-b8f7-f9125bf23586", "task_name": "send_mail", "timestamp": "2023-12-10T19:34:58.202565"}
Dec 10 19:34:58 shel1sso00 celery[579503]: {"event": "Task published", "level": "info", "logger": "authentik.root.celery", "pid": 579503, "task_id": "4c7403008a7544bbb8f7f9125bf23586", "task_name": "authentik.stages.email.tasks.send_mail", "timestamp": "2023-12-10T19:34:58.692401"}
Dec 10 19:34:58 shel1sso00 celery[579503]: {"event": "Task finished", "level": "info", "logger": "authentik.root.celery", "pid": 579503, "state": "RETRY", "task_id": "4c7403008a7544bbb8f7f9125bf23586", "task_name": "send_mail", "timestamp": "2023-12-10T19:34:58.698943"}
Dec 10 19:35:00 shel1sso00 celery[579506]: {"event": "Task started", "level": "info", "logger": "authentik.root.celery", "pid": 579506, "task_id": "4c740300-8a75-44bb-b8f7-f9125bf23586", "task_name": "send_mail", "timestamp": "2023-12-10T19:35:00.684791"}
Dec 10 19:35:01 shel1sso00 celery[579506]: {"event": "Task published", "level": "info", "logger": "authentik.root.celery", "pid": 579506, "task_id": "4c7403008a7544bbb8f7f9125bf23586", "task_name": "authentik.stages.email.tasks.send_mail", "timestamp": "2023-12-10T19:35:01.177277"}
Dec 10 19:35:01 shel1sso00 celery[579504]: {"event": "Task started", "level": "info", "logger": "authentik.root.celery", "pid": 579504, "task_id": "4c740300-8a75-44bb-b8f7-f9125bf23586", "task_name": "send_mail", "timestamp": "2023-12-10T19:35:01.180210"}
Dec 10 19:35:01 shel1sso00 celery[579506]: {"event": "Task finished", "level": "info", "logger": "authentik.root.celery", "pid": 579506, "state": "RETRY", "task_id": "4c7403008a7544bbb8f7f9125bf23586", "task_name": "send_mail", "timestamp": "2023-12-10T19:35:01.185922"}
Dec 10 19:35:01 shel1sso00 celery[579504]: {"action": "system_task_exception", "client_ip": null, "context": {"message": "Task send_mail encountered an error: Traceback (most recent call last):\n  File \"/nix/store/nidrq7x9vg876i87fid81kacikwcbjli-python3-3.11.5-env/lib/python3.11/site-packages/celery/app/trace.py>
Dec 10 19:35:01 shel1sso00 celery[579504]: {"event": "Task published", "level": "info", "logger": "authentik.root.celery", "pid": 579504, "task_id": "a708bf93b21542a5850895b031c4227a", "task_name": "authentik.events.tasks.event_notification_handler", "timestamp": "2023-12-10T19:35:01.652668"}
Dec 10 19:35:01 shel1sso00 celery[579504]: {"event": "Task failure", "exc": "FileNotFoundError(2, 'No such file or directory')", "level": "warning", "logger": "authentik.root.celery", "pid": 579504, "task_id": "task-4c7403008a7544bbb8f7f9125bf23586", "timestamp": "2023-12-10T19:35:01.653102"}
Dec 10 19:35:01 shel1sso00 celery[579504]: {"event": "Task authentik.stages.email.tasks.send_mail[4c740300-8a75-44bb-b8f7-f9125bf23586] raised unexpected: FileNotFoundError(2, 'No such file or directory')", "exception": [{"exc_type": "FileNotFoundError", "exc_value": "[Errno 2] No such file or directory: 'web/dist>

Best Philip

xanderio commented 11 months ago

This is do to the worker having it's working directory set to %t/authentik aka. /run/authentik where the staticWorkdirDeps aren't link into.

I was able to fix it with this small addition.

    systemd.services.authentik-worker.preStart = ''
      ln -svf ${config.services.authentik.authentikComponents.staticWorkdirDeps}/* /run/authentik/
    '';
shokinn commented 10 months ago

fixed. Thanks!