The quota_notify.py has fatal error when executed by the system, when executed manually it works.

It seems it’s unable to get the REDISPASS from the OS environment.

Log:

dovecot-mailcow-1 | Feb 10 11:03:30 f988b5f2c60c dovecot: imap-login: Disconnected: Aborted login by logging out (no auth attempts in 0 secs): user=<>, rip=172.22.1.12, lip=172.22.1.250, TLS, TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
dovecot-mailcow-1 | Feb 10 11:03:31 f988b5f2c60c dovecot: quota-warning: Error: Traceback (most recent call last):
dovecot-mailcow-1 | Feb 10 11:03:31 f988b5f2c60c dovecot: quota-warning: Error: File “/usr/local/bin/quota_notify.py”, line 26, in <module>
dovecot-mailcow-1 | Feb 10 11:03:31 f988b5f2c60c dovecot: quota-warning: Error: r = redis.StrictRedis(host=‘redis’, decode_responses=True, port=6379, db=0, password=os.environ[‘REDISPASS’])
dovecot-mailcow-1 | Feb 10 11:03:31 f988b5f2c60c dovecot: quota-warning: Error: ~~~~~^^^^^^^^^^^^^
dovecot-mailcow-1 | Feb 10 11:03:31 f988b5f2c60c dovecot: quota-warning: Error: File “<frozen os>”, line 714, in getitem
dovecot-mailcow-1 | Feb 10 11:03:31 f988b5f2c60c dovecot: quota-warning: Error: KeyError: ‘REDISPASS’
dovecot-mailcow-1 | Feb 10 11:03:31 f988b5f2c60c dovecot: quota-warning: Error:
dovecot-mailcow-1 | Feb 10 11:03:31 f988b5f2c60c dovecot: quota-warning: Error: During handling of the above exception, another exception occurred:
dovecot-mailcow-1 | Feb 10 11:03:31 f988b5f2c60c dovecot: quota-warning: Error:
dovecot-mailcow-1 | Feb 10 11:03:31 f988b5f2c60c dovecot: quota-warning: Error: Traceback (most recent call last):
dovecot-mailcow-1 | Feb 10 11:03:31 f988b5f2c60c dovecot: quota-warning: Error: File “/usr/local/bin/quota_notify.py”, line 29, in <module>
dovecot-mailcow-1 | Feb 10 11:03:31 f988b5f2c60c dovecot: quota-warning: Error: print(‘%s - trying again…’ % (ex))
dovecot-mailcow-1 | Feb 10 11:03:31 f988b5f2c60c dovecot: quota-warning: Error: BrokenPipeError: [Errno 32] Broken pipe
dovecot-mailcow-1 | Feb 10 11:03:31 f988b5f2c60c dovecot: quota-warning: Fatal: master: service(quota-warning): child 237297 returned error 1
dovecot-mailcow-1 | Feb 10 11:03:32 f988b5f2c60c dovecot: imap-login: Login: user=example@example.com, method=PLAIN, rip=172.22.1.248, lip=172.22.1.250, mpid=239076

Steps:

  1. Create a test mailbox with 10 MB quota
  2. Sent mail with 8 MB so quota notification is triggered, wait for 1-2 minutes after email is received
  3. See quota_notify.py fatal error in docker logs (docker compose logs -f dovecot-mailcow | grep quota)

For manual execution connect to dovecot-mailcow and execute it manually.

  1. docker compose exec -it dovecot-mailcow /bin/bash
  2. /usr/local/bin/quota_notify.py 90 testmail@example.com

In the dovecot container:
printenv returns the REDISPASS
Pythons version is 3.12.8

Can someone reproduce this?

Thanks

  • DocFraggle

    • Community Hero
    Moolevel 282
  • Edited

Yes, I can reproduce this…

dovecot-mailcow-1  | Feb 10 14:04:04 11832a3e7c78 dovecot: quota-warning: Error: Traceback (most recent call last):
dovecot-mailcow-1  | Feb 10 14:04:04 11832a3e7c78 dovecot: quota-warning: Error:   File "/usr/local/bin/quota_notify.py", line 26, in <module>
dovecot-mailcow-1  | Feb 10 14:04:04 11832a3e7c78 dovecot: quota-warning: Error:     r = redis.StrictRedis(host='redis', decode_responses=True, port=6379, db=0, password=os.environ['REDISPASS'])
dovecot-mailcow-1  | Feb 10 14:04:04 11832a3e7c78 dovecot: quota-warning: Error:                                                                                          ~~~~~~~~~~^^^^^^^^^^^^^
dovecot-mailcow-1  | Feb 10 14:04:04 11832a3e7c78 dovecot: quota-warning: Error:   File "<frozen os>", line 714, in __getitem__
dovecot-mailcow-1  | Feb 10 14:04:04 11832a3e7c78 dovecot: quota-warning: Error: KeyError: 'REDISPASS'
dovecot-mailcow-1  | Feb 10 14:04:04 11832a3e7c78 dovecot: quota-warning: Error: 
dovecot-mailcow-1  | Feb 10 14:04:04 11832a3e7c78 dovecot: quota-warning: Error: During handling of the above exception, another exception occurred:
dovecot-mailcow-1  | Feb 10 14:04:04 11832a3e7c78 dovecot: quota-warning: Error: 
dovecot-mailcow-1  | Feb 10 14:04:04 11832a3e7c78 dovecot: quota-warning: Error: Traceback (most recent call last):
dovecot-mailcow-1  | Feb 10 14:04:04 11832a3e7c78 dovecot: quota-warning: Error:   File "/usr/local/bin/quota_notify.py", line 29, in <module>
dovecot-mailcow-1  | Feb 10 14:04:04 11832a3e7c78 dovecot: quota-warning: Error:     print('%s - trying again...'  % (ex))
dovecot-mailcow-1  | Feb 10 14:04:04 11832a3e7c78 dovecot: quota-warning: Error: BrokenPipeError: [Errno 32] Broken pipe
dovecot-mailcow-1  | Feb 10 14:04:04 11832a3e7c78 dovecot: quota-warning: Fatal: master: service(quota-warning): child 510952 returned error 1

@FreddleSpl0it looks like your commit introduced the REDISPASS variable?

mailcow/mailcow-dockerized89fb132

Have something to say?

Join the community by quickly registering to participate in this discussion. We'd like to see you joining our great moo-community!

  • DocFraggle

    • Community Hero
    Moolevel 282

Dug around a little bit, if I run the script manually from within the dovecot container it works:

docker compose exec dovecot-mailcow /bin/sh -c "python3 /usr/local/bin/quota_notify.py 80 test@domain.tld"

But in fact it’s dovecot which is running the script, and I guess dovecot isn’t aware of the REDISPASS environment variable

@FreddleSpl0it

  • FreddleSpl0it

    • Forum Staff
    • mailcow team
    Moolevel 2
  • Edited

Probably because dovecot does not run the quota_notify script as root. I think the environment variable REDISPASS is only available for the root user

i think the best solution is to generate a config json, so the script can load it.

  • DocFraggle

    • Community Hero
    Moolevel 282

Also for the quarantine_notify.py I guess

mhm quarantine_notify.py is executed by ofelia as vmail user. The vmail user has REDISPASS in environment. But dovecot should also run the quota_notify.py script as vmail

No one is typing