Dockered celery does not send mail #87

Closed
opened 2022-01-27 15:28:31 +01:00 by mpeltriaux · 2 comments
Owner

Problem

The dockered celery worker of konova fails on staging with the following error:

[2022-01-27 15:24:53,038: ERROR/ForkPoolWorker-1] Task konova.tasks.celery_send_mail_shared_data_unrecorded[91f7ecab-dbe7-417e-aeb6-c915b0c8fb7f] raised unexpected: TypeError('getaddrinfo() argument 1 must be string or None')
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/celery/app/trace.py", line 451, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/celery/app/trace.py", line 734, in __protected_call__
    return self.run(*args, **kwargs)
  File "/konova/konova/tasks.py", line 46, in celery_send_mail_shared_data_unrecorded
    user.send_mail_shared_data_unrecorded(obj_identifier)
  File "/konova/user/models/user.py", line 78, in send_mail_shared_data_unrecorded
    mailer.send_mail_shared_data_unrecorded(obj_identifier, self)
  File "/konova/konova/utils/mailer.py", line 137, in send_mail_shared_data_unrecorded
    msg
  File "/konova/konova/utils/mailer.py", line 49, in send
    auth_password=self.auth_password
  File "/usr/local/lib/python3.7/site-packages/django/core/mail/__init__.py", line 61, in send_mail
    return mail.send()
  File "/usr/local/lib/python3.7/site-packages/django/core/mail/message.py", line 284, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "/usr/local/lib/python3.7/site-packages/django/core/mail/backends/smtp.py", line 102, in send_messages
    new_conn_created = self.open()
  File "/usr/local/lib/python3.7/site-packages/django/core/mail/backends/smtp.py", line 62, in open
    self.connection = self.connection_class(self.host, self.port, **connection_params)
  File "/usr/local/lib/python3.7/smtplib.py", line 251, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/local/lib/python3.7/smtplib.py", line 336, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "/usr/local/lib/python3.7/smtplib.py", line 307, in _get_socket
    self.source_address)
  File "/usr/local/lib/python3.7/socket.py", line 707, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/usr/local/lib/python3.7/socket.py", line 752, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
TypeError: getaddrinfo() argument 1 must be string or None

Fix

Since mails are send properly, having celery run on a non-dockered dev machine, we need to look for the reasons it fails in a dockered environment.

# Problem The dockered celery worker of konova fails on staging with the following error: ```python [2022-01-27 15:24:53,038: ERROR/ForkPoolWorker-1] Task konova.tasks.celery_send_mail_shared_data_unrecorded[91f7ecab-dbe7-417e-aeb6-c915b0c8fb7f] raised unexpected: TypeError('getaddrinfo() argument 1 must be string or None') Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/celery/app/trace.py", line 451, in trace_task R = retval = fun(*args, **kwargs) File "/usr/local/lib/python3.7/site-packages/celery/app/trace.py", line 734, in __protected_call__ return self.run(*args, **kwargs) File "/konova/konova/tasks.py", line 46, in celery_send_mail_shared_data_unrecorded user.send_mail_shared_data_unrecorded(obj_identifier) File "/konova/user/models/user.py", line 78, in send_mail_shared_data_unrecorded mailer.send_mail_shared_data_unrecorded(obj_identifier, self) File "/konova/konova/utils/mailer.py", line 137, in send_mail_shared_data_unrecorded msg File "/konova/konova/utils/mailer.py", line 49, in send auth_password=self.auth_password File "/usr/local/lib/python3.7/site-packages/django/core/mail/__init__.py", line 61, in send_mail return mail.send() File "/usr/local/lib/python3.7/site-packages/django/core/mail/message.py", line 284, in send return self.get_connection(fail_silently).send_messages([self]) File "/usr/local/lib/python3.7/site-packages/django/core/mail/backends/smtp.py", line 102, in send_messages new_conn_created = self.open() File "/usr/local/lib/python3.7/site-packages/django/core/mail/backends/smtp.py", line 62, in open self.connection = self.connection_class(self.host, self.port, **connection_params) File "/usr/local/lib/python3.7/smtplib.py", line 251, in __init__ (code, msg) = self.connect(host, port) File "/usr/local/lib/python3.7/smtplib.py", line 336, in connect self.sock = self._get_socket(host, port, self.timeout) File "/usr/local/lib/python3.7/smtplib.py", line 307, in _get_socket self.source_address) File "/usr/local/lib/python3.7/socket.py", line 707, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): File "/usr/local/lib/python3.7/socket.py", line 752, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): TypeError: getaddrinfo() argument 1 must be string or None ``` # Fix Since mails are send properly, having celery run on a non-dockered dev machine, we need to look for the reasons it fails in a dockered environment.
mpeltriaux added the
bug
label 2022-01-27 15:28:31 +01:00
mpeltriaux self-assigned this 2022-01-27 15:28:31 +01:00
Author
Owner

It does not seem to be a celery specific issue. The same happens if the foreground konova process shall sent an email. Something seems to be odd on the docker configuration for konova, since arnova is working fine and sending mails without problems.

It does not seem to be a celery specific issue. The same happens if the foreground konova process shall sent an email. Something seems to be odd on the docker configuration for konova, since arnova is working fine and sending mails without problems.
mpeltriaux referenced this issue from a commit 2022-01-28 17:01:49 +01:00
Author
Owner

Inspired by this post I took a look on the django_settings.py file on the docker branch.

Indeed, somehow trailing comma got in there.

Fix has been merged and published on the staging in this commit

Inspired by [this post](https://stackoverflow.com/questions/42872923/flask-mail-typeerror-getaddrinfo-argument-1-must-be-string-or-none) I took a look on the `django_settings.py` file on the docker branch. Indeed, somehow trailing comma got in there. Fix has been merged and published on the staging in [this commit](https://git.naturschutz.rlp.de/SGD-Nord/konova/commit/9c9c9b7717932c336c56e3960de7910c1784c5c2)
btuelek referenced this issue from a commit 2024-12-05 13:18:36 +01:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: IT-Naturschutz/konova#87
No description provided.