Mailman: don't report useless exceptions in Django via email
This commit is contained in:
parent
39166fbfee
commit
b64d7567f6
3 changed files with 42 additions and 3 deletions
17
roles/mailman/files/django_fedora.py
Normal file
17
roles/mailman/files/django_fedora.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
from django.core.exceptions import DisallowedHost
|
||||
from django.http import UnreadablePostError
|
||||
from pylibmc import Error as MemcachedError
|
||||
|
||||
EXCLUDED = (
|
||||
DisallowedHost,
|
||||
UnreadablePostError,
|
||||
MemcachedError,
|
||||
)
|
||||
|
||||
def exclude_useless_errors(record):
|
||||
if record.exc_info:
|
||||
exc_type, exc_value = record.exc_info[:2]
|
||||
for excluded_class in EXCLUDED:
|
||||
if isinstance(exc_value, EXCLUDED):
|
||||
return False
|
||||
return True
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#
|
||||
# SELinux
|
||||
# TODO: switch to the sefcontext module when we update Ansible to 2.2+
|
||||
#
|
||||
- name: install semanage
|
||||
yum: pkg=policycoreutils-python state=present
|
||||
|
@ -266,6 +267,16 @@
|
|||
- config
|
||||
- mailman
|
||||
|
||||
- name: install the django_fedora module
|
||||
copy: src=django_fedora.py
|
||||
dest="{{ mailman_webui_confdir }}/django_fedora.py"
|
||||
owner=root group=root mode=0644
|
||||
tags:
|
||||
- config
|
||||
- mailman
|
||||
notify:
|
||||
- reload apache
|
||||
|
||||
- name: install the hyperkitty urls file
|
||||
copy: src=urls.py
|
||||
dest="{{ mailman_webui_confdir }}/urls.py"
|
||||
|
|
|
@ -6,6 +6,8 @@ Django settings for HyperKitty + Postorius
|
|||
import os
|
||||
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
import django_fedora
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = '{{ mailman_hyperkitty_cookie_key }}'
|
||||
|
||||
|
@ -29,7 +31,7 @@ ALLOWED_HOSTS = [
|
|||
".fedoraproject.org",
|
||||
"localhost", # Archiving API from Mailman
|
||||
"127.0.0.1", # HAProxy ping
|
||||
"mailman01", # Varnish ping on STG
|
||||
"{{ ansible_hostname }}", # Varnish ping
|
||||
]
|
||||
|
||||
# Mailman API credentials
|
||||
|
@ -322,12 +324,16 @@ LOGGING = {
|
|||
'filters': {
|
||||
'require_debug_false': {
|
||||
'()': 'django.utils.log.RequireDebugFalse'
|
||||
},
|
||||
'exclude_useless_errors': {
|
||||
'()': 'django.utils.log.CallbackFilter',
|
||||
'callback': django_fedora.exclude_useless_errors,
|
||||
}
|
||||
},
|
||||
'handlers': {
|
||||
'mail_admins': {
|
||||
'level': 'ERROR',
|
||||
'filters': ['require_debug_false'],
|
||||
'filters': ['require_debug_false', 'exclude_useless_errors'],
|
||||
'class': 'django.utils.log.AdminEmailHandler'
|
||||
},
|
||||
'file':{
|
||||
|
@ -340,7 +346,12 @@ LOGGING = {
|
|||
},
|
||||
'loggers': {
|
||||
'django.request': {
|
||||
'handlers': ['mail_admins', 'file'],
|
||||
'handlers': [
|
||||
'file',
|
||||
{% if env == 'prod' %}
|
||||
'mail_admins',
|
||||
{% endif %}
|
||||
],
|
||||
'level': 'DEBUG',
|
||||
'propagate': True,
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue