-
Notifications
You must be signed in to change notification settings - Fork 327
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
Mac OSX resolver domains do not resolve when monkey_patch applied #383
Comments
|
$ python -c 'import eventlet ; print(eventlet.__version__)'
0.20.1 |
It's because patched version of I'm still studying how it works in OSX and will implement this. |
Sure thing! Thanks for getting back so fast. For anyone in the future that stumbles across this and needs a refresher on how /etc/resolver works, here's an example. /etc/resolver/tech:
This tells us that for every *.tech domain requested, it should use the nameserver located at 127.0.0.1 to do the resolution. |
Linking similar issue in Go, just for fun: golang/go#12524 |
Sorry for negation in name, perfectionists want EVENTLET_GREEN_DNS=no but I figured it's lesser evil than reviving same behavior under different name. This works around #383 at the cost of resolving blocking other greenthreads.
Okay, this is probably your best option for today
Run python with A better solution is yet to come, I'm tired. |
Thanks for the hard work. Interestingly enough, this solved it for my example, but not for our actual production issue. I'm having a difficult time recreating this configuration for a test case. I know our Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/arbiter.py", line 495, in spawn_worker
worker.init_process()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/workers/geventlet.py", line 48, in init_process
super(EventletWorker, self).init_process()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/workers/base.py", line 106, in init_process
self.wsgi = self.app.wsgi()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/app/base.py", line 114, in wsgi
self.callable = self.load()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 62, in load
return self.load_wsgiapp()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 49, in load_wsgiapp
return util.import_app(self.app_uri)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/util.py", line 365, in import_app
app = eval(obj, mod.__dict__)
File "<string>", line 1, in <module>
File "/Users/User.Name/Development/webd.py", line 49, in create_app
app.db = database.db_from_config('my-database')
File "/Users/User.Name/Development/tools/db/database.py", line 41, in db_from_config
return db_from_connection(config.db_uri, config.db_name)
File "/Users/User.Name/Development/tools/db/database.py", line 32, in db_from_connection
con = MongoClient(host=uri, tz_aware=True)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mongokit/connection.py", line 107, in __init__
PymongoConnection.__init__(self, *args, **kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymongo/mongo_client.py", line 426, in __init__
raise ConnectionFailure(str(e))
ConnectionFailure: [Errno 8] No address found |
You have OSX in production? |
"No address found" looks like a valid error to me. Do you think the address was resolvable at the time? Could you inject the following code into import eventlet
import socket
so = eventlet.patcher.original('socket')
assert eventlet.patcher.is_monkey_patched('socket')
from eventlet.support import greendns
assert socket.gethostbyname is greendns.gethostbyname
db_host = config.db_uri[7:28] # fix indexes to point to hostname
print('% host__ %%%%%%%%%%%%', db_host)
print('% system %%%%%%%%%%%%', so.gethostbyname(db_host))
print('% green_ %%%%%%%%%%%%', socket.gethostbyname(db_host)) |
Sorry, production was not the right word, development is the environment that our Mac's are in :) As for the "No address found" message, I'm positive that the address was resolvable (testing with our old versions and with gevent works as expected). I injected the code above, and the findings are very interesting indeed. ('% host__ %%%%%%%%%%%%', 'my.special.hostname.com')
('% system %%%%%%%%%%%%', '192.168.10.1') # fake IP here
2017-02-02 09:18:39 [3801] [ERROR] Exception in worker process:
Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/arbiter.py", line 495, in spawn_worker
worker.init_process()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/workers/geventlet.py", line 48, in init_process
super(EventletWorker, self).init_process()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/workers/base.py", line 106, in init_process
self.wsgi = self.app.wsgi()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/app/base.py", line 114, in wsgi
self.callable = self.load()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 62, in load
return self.load_wsgiapp()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 49, in load_wsgiapp
return util.import_app(self.app_uri)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/util.py", line 365, in import_app
app = eval(obj, mod.__dict__)
File "<string>", line 1, in <module>
File "/Users/Adam.Brown/Development/webd.py", line 60, in create_app
print('% green_ %%%%%%%%%%%%', socket.gethostbyname(db_host))
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/eventlet/support/greendns.py", line 518, in gethostbyname
rrset = resolve(hostname)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/eventlet/support/greendns.py", line 405, in resolve
raise EAI_NODATA_ERROR
gaierror: [Errno 7] No address associated with hostname |
I forgot to ask you to print |
And this |
Very interesting, but I tried the above patch again this morning (the only thing I thought I changed was adding a print for the environment variable), but the assertion did indeed fail this morning as you said it should, and the patch seems to have worked. |
Yup, computers are precise only in theory. Real solution is coming some time later. |
Sorry for negation in name, perfectionists want EVENTLET_GREEN_DNS=no but I figured it's lesser evil than reviving same behavior under different name. This works around #383 at the cost of resolving blocking other greenthreads.
Versions Effected
Scenario
I am using a private DNS server to resolve database hostnames in our production environment. When I use
eventlet.monkey_patch()
, these hostnames no longer resolve.To set this up for replication, I installed a local DNS server to resolve the hostname
somewherespecial.tech
to127.0.0.1
. The specific commands I ran are listed below:Example
The following code shows the change in resolution that monkey_patching causes.
I'm more than willing to provide any other info that might be useful.
The text was updated successfully, but these errors were encountered: