Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IP address error when used with Eventlet gunicorn worker class #59

Open
modbender opened this issue Feb 11, 2020 · 0 comments
Open

IP address error when used with Eventlet gunicorn worker class #59

modbender opened this issue Feb 11, 2020 · 0 comments

Comments

@modbender
Copy link

Recently switched from gevent to eventlet due to some worker timeouts in gunicorn and django-ip restrict app stopped working. On urls where iprestrict is used, I get the following traceback:

 Traceback (most recent call last):
Feb 11 20:27:45 project gunicorn[21670]:   File "/home/siteuser/project/renv/lib/python3.6/site-packages/django/core/validators.py", line 254, in validate_ipv4_address
Feb 11 20:27:45 project gunicorn[21670]:     ipaddress.IPv4Address(value)
Feb 11 20:27:45 project gunicorn[21670]:   File "/usr/lib/python3.6/ipaddress.py", line 1284, in __init__
Feb 11 20:27:45 project gunicorn[21670]:     self._ip = self._ip_int_from_string(addr_str)
Feb 11 20:27:45 project gunicorn[21670]:   File "/usr/lib/python3.6/ipaddress.py", line 1114, in _ip_int_from_string
Feb 11 20:27:45 project gunicorn[21670]:     raise AddressValueError('Address cannot be empty')
Feb 11 20:27:45 project gunicorn[21670]: ipaddress.AddressValueError: Address cannot be empty
Feb 11 20:27:45 project gunicorn[21670]: During handling of the above exception, another exception occurred:
Feb 11 20:27:45 project gunicorn[21670]: Traceback (most recent call last):
Feb 11 20:27:45 project gunicorn[21670]:   File "/home/siteuser/project/renv/lib/python3.6/site-packages/django/core/validators.py", line 266, in validate_ipv46_address
Feb 11 20:27:45 project gunicorn[21670]:     validate_ipv4_address(value)
Feb 11 20:27:45 project gunicorn[21670]:   File "/home/siteuser/project/renv/lib/python3.6/site-packages/django/core/validators.py", line 256, in validate_ipv4_address
Feb 11 20:27:45 project gunicorn[21670]:     raise ValidationError(_('Enter a valid IPv4 address.'), code='invalid')
Feb 11 20:27:45 project gunicorn[21670]: django.core.exceptions.ValidationError: ['Enter a valid IPv4 address.']
Feb 11 20:27:45 project gunicorn[21670]: During handling of the above exception, another exception occurred:
Feb 11 20:27:45 project gunicorn[21670]: Traceback (most recent call last):
Feb 11 20:27:45 project gunicorn[21670]:   File "/home/siteuser/project/renv/lib/python3.6/site-packages/django/core/validators.py", line 269, in validate_ipv46_address
Feb 11 20:27:45 project gunicorn[21670]:     validate_ipv6_address(value)
Feb 11 20:27:45 project gunicorn[21670]:   File "/home/siteuser/project/renv/lib/python3.6/site-packages/django/core/validators.py", line 261, in validate_ipv6_address
Feb 11 20:27:45 project gunicorn[21670]:     raise ValidationError(_('Enter a valid IPv6 address.'), code='invalid')
Feb 11 20:27:45 project gunicorn[21670]: django.core.exceptions.ValidationError: ['Enter a valid IPv6 address.']
Feb 11 20:27:45 project gunicorn[21670]: During handling of the above exception, another exception occurred:
Feb 11 20:27:45 project gunicorn[21670]: Traceback (most recent call last):
Feb 11 20:27:45 project gunicorn[21670]:   File "/home/siteuser/project/renv/lib/python3.6/site-packages/django/contrib/gis/geoip2/base.py", line 158, in _check_query
Feb 11 20:27:45 project gunicorn[21670]:     validate_ipv46_address(query)
Feb 11 20:27:45 project gunicorn[21670]:   File "/home/siteuser/project/renv/lib/python3.6/site-packages/django/core/validators.py", line 271, in validate_ipv46_address
Feb 11 20:27:45 project gunicorn[21670]:     raise ValidationError(_('Enter a valid IPv4 or IPv6 address.'), code='invalid')
Feb 11 20:27:45 project gunicorn[21670]: django.core.exceptions.ValidationError: ['Enter a valid IPv4 or IPv6 address.']
Feb 11 20:27:45 project gunicorn[21670]: During handling of the above exception, another exception occurred:
Feb 11 20:27:45 project gunicorn[21670]: Traceback (most recent call last):
Feb 11 20:27:45 project gunicorn[21670]:   File "/home/siteuser/project/renv/lib/python3.6/site-packages/eventlet/support/greendns.py", line 425, in resolve
Feb 11 20:27:45 project gunicorn[21670]:     use_network=use_network)
Feb 11 20:27:45 project gunicorn[21670]:   File "/home/siteuser/project/renv/lib/python3.6/site-packages/eventlet/support/greendns.py", line 380, in query
Feb 11 20:27:45 project gunicorn[21670]:     return end()
Feb 11 20:27:45 project gunicorn[21670]:   File "/home/siteuser/project/renv/lib/python3.6/site-packages/eventlet/support/greendns.py", line 359, in end
Feb 11 20:27:45 project gunicorn[21670]:     raise result[1]
Feb 11 20:27:45 project gunicorn[21670]:   File "/home/siteuser/project/renv/lib/python3.6/site-packages/eventlet/support/greendns.py", line 340, in step
Feb 11 20:27:45 project gunicorn[21670]:     a = fun(*args, **kwargs)
Feb 11 20:27:45 project gunicorn[21670]:   File "/home/siteuser/project/renv/lib/python3.6/site-packages/dns/resolver.py", line 898, in query
Feb 11 20:27:45 project gunicorn[21670]:     raise NoNameservers(request=request, errors=errors)
Feb 11 20:27:45 project gunicorn[21670]: dns.resolver.NoNameservers: All nameservers failed to answer the query server. IN A: Server 127.0.0.53 UDP port 53 answered SERVFAIL
Feb 11 20:27:45 project gunicorn[21670]: dns.resolver.NoNameservers: All nameservers failed to answer the query server. IN A: Server 127.0.0.53 UDP port 53 answered SERVFAIL
Feb 11 20:27:45 project gunicorn[21670]: During handling of the above exception, another exception occurred:
Feb 11 20:27:45 project gunicorn[21670]: Traceback (most recent call last):
Feb 11 20:27:45 project gunicorn[21670]:   File "/home/siteuser/project/renv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
Feb 11 20:27:45 project gunicorn[21670]:     response = get_response(request)
Feb 11 20:27:45 project gunicorn[21670]:   File "/home/siteuser/project/renv/lib/python3.6/site-packages/django/utils/deprecation.py", line 93, in __call__
Feb 11 20:27:45 project gunicorn[21670]:     response = self.process_request(request)
Feb 11 20:27:45 project gunicorn[21670]:   File "/home/siteuser/project/accounts/middleware.py", line 45, in process_request
Feb 11 20:27:45 project gunicorn[21670]:     if self.restrictor.is_restricted(url, client_ip):
Feb 11 20:27:45 project gunicorn[21670]:   File "/home/siteuser/project/renv/lib/python3.6/site-packages/iprestrict/restrictor.py", line 16, in is_restricted
Feb 11 20:27:45 project gunicorn[21670]:     if rule.matches_url(url) and rule.matches_ip(ip):
Feb 11 20:27:45 project gunicorn[21670]:   File "/home/siteuser/project/renv/lib/python3.6/site-packages/iprestrict/models.py", line 229, in matches_ip
Feb 11 20:27:45 project gunicorn[21670]:     match = typed_ip_group(self.ip_group).matches(ip)
Feb 11 20:27:45 project gunicorn[21670]:   File "/home/siteuser/project/renv/lib/python3.6/site-packages/iprestrict/models.py", line 124, in matches
Feb 11 20:27:45 project gunicorn[21670]:     country_code = geoip.country_code(ip) or NO_COUNTRY
Feb 11 20:27:45 project gunicorn[21670]:   File "/home/siteuser/project/renv/lib/python3.6/site-packages/iprestrict/geoip.py", line 47, in country_code
Feb 11 20:27:45 project gunicorn[21670]:     return self._geoip.country_code(ip)
Feb 11 20:27:45 project gunicorn[21670]:   File "/home/siteuser/project/renv/lib/python3.6/site-packages/django/contrib/gis/geoip2/base.py", line 175, in country_code
Feb 11 20:27:45 project gunicorn[21670]:     enc_query = self._check_query(query, city_or_country=True)
Feb 11 20:27:45 project gunicorn[21670]:   File "/home/siteuser/project/renv/lib/python3.6/site-packages/django/contrib/gis/geoip2/base.py", line 160, in _check_query
Feb 11 20:27:45 project gunicorn[21670]:     query = socket.gethostbyname(query)
Feb 11 20:27:45 project gunicorn[21670]:   File "/home/siteuser/project/renv/lib/python3.6/site-packages/eventlet/support/greendns.py", line 550, in gethostbyname
Feb 11 20:27:45 project gunicorn[21670]:     rrset = resolve(hostname)
Feb 11 20:27:45 project gunicorn[21670]:   File "/home/siteuser/project/renv/lib/python3.6/site-packages/eventlet/support/greendns.py", line 434, in resolve
Feb 11 20:27:45 project gunicorn[21670]:     raise EAI_NODATA_ERROR
Feb 11 20:27:45 project gunicorn[21670]: socket.gaierror: [Errno -2] Name or service not known
Feb 11 20:27:45 project gunicorn[21670]: During handling of the above exception, another exception occurred:
Feb 11 20:27:45 project gunicorn[21670]: Traceback (most recent call last):
Feb 11 20:27:45 project gunicorn[21670]:   File "/home/siteuser/project/renv/lib/python3.6/site-packages/raven/utils/serializer/manager.py", line 76, in transform
Feb 11 20:27:45 project gunicorn[21670]:     return repr(value)
Feb 11 20:27:45 project gunicorn[21670]:   File "/usr/lib/python3.6/ipaddress.py", line 583, in __repr__
Feb 11 20:27:45 project gunicorn[21670]:     return '%s(%r)' % (self.__class__.__name__, str(self))
Feb 11 20:27:45 project gunicorn[21670]:   File "/usr/lib/python3.6/ipaddress.py", line 586, in __str__
Feb 11 20:27:45 project gunicorn[21670]:     return str(self._string_from_ip_int(self._ip))
Feb 11 20:27:45 project gunicorn[21670]: AttributeError: _ip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant