From 489677319b416351d73044ae1336ff2a2112340e Mon Sep 17 00:00:00 2001 From: Brant Knudson Date: Sun, 19 May 2013 10:03:38 -0500 Subject: Disable eventlet monkey-patching of DNS This change avoids eventlet's monkey-patching of DNS resolution. eventlet's doesn't support IPv6, for example. The way to avoid eventlet's DNS is to set an environment variable. The trick is the environment variable needs to be set before eventlet is imported. A similar change was made in nova, so this is just copying that code and technique to Keystone. This allows re-enabling the IPv6 tests, too. Change-Id: I1e4d4bbfea374d386796d1505a602fd187e75c67 --- keystone/common/wsgi_server.py | 13 +++++++++++++ keystone/test.py | 5 ----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/keystone/common/wsgi_server.py b/keystone/common/wsgi_server.py index f3c22907..d8d2512f 100644 --- a/keystone/common/wsgi_server.py +++ b/keystone/common/wsgi_server.py @@ -23,6 +23,19 @@ import socket import ssl import sys +# NOTE(mikal): All of this is because if dnspython is present in your +# environment then eventlet monkeypatches socket.getaddrinfo() with an +# implementation which doesn't work for IPv6. What we're checking here is +# that the magic environment variable was set when the import happened. +if ('eventlet' in sys.modules and + os.environ.get('EVENTLET_NO_GREENDNS', '').lower() != 'yes'): + raise ImportError('eventlet imported before ' + 'keystone.common.wsgi_server ' + '(EVENTLET_NO_GREENDNS env var set to %s)' + % os.environ.get('EVENTLET_NO_GREENDNS')) + +os.environ['EVENTLET_NO_GREENDNS'] = 'yes' + import eventlet import eventlet.wsgi diff --git a/keystone/test.py b/keystone/test.py index 3cfbd01c..fc5cd1c6 100644 --- a/keystone/test.py +++ b/keystone/test.py @@ -375,11 +375,6 @@ class TestCase(NoModule, unittest.TestCase): @staticmethod def skip_if_no_ipv6(): - - # TODO(blk-u): lp 1176204. At this time, eventlet address resolution - # doesn't support IPv6. Once it does, remove the next line. - raise nose.exc.SkipTest("Eventlet doesn't support IPv6, lp 1176204") - try: s = socket.socket(socket.AF_INET6) except socket.error as e: -- cgit