Fix VNC access, when reverse DNS lookups fail

If DNS is configured on a node in a way, so that reverse DNS look ups
time out, noVNC will fail to connect to an instance with 'Connect
timeout' error.

The reverse DNS look up is done implicitly in BaseHTTPRequestHandler
(part of standard library), when logging a request. It's not
configurable, so the only way to disable it is to override the method
of the base class.

This is only true for the standard http server (used for novncproxy),
as the eventlet implementation (used for xvpvncproxy) seems to use
plain IP addresses without any reverse DNS look ups.

Closes-Bug: #1422315

Change-Id: I8b922de49134eda4d753a8e906b0de55203877d3
This commit is contained in:
Roman Podoliaka 2015-02-16 11:55:07 +02:00
parent 69f4b44691
commit c0f773a616
2 changed files with 23 additions and 0 deletions

View File

@ -35,6 +35,12 @@ LOG = logging.getLogger(__name__)
class NovaProxyRequestHandlerBase(object):
def address_string(self):
# NOTE(rpodolyaka): override the superclass implementation here and
# explicitly disable the reverse DNS lookup, which might fail on some
# deployments due to DNS configuration and break VNC access completely
return str(self.client_address[0])
def new_websocket_client(self):
"""Called after a new WebSocket connection has been established."""
# Reopen the eventlet hub to make sure we don't share an epoll

View File

@ -155,3 +155,20 @@ class NovaProxyRequestHandlerBaseTestCase(test.TestCase):
self.assertRaises(exception.NovaException,
self.wh.new_websocket_client)
@mock.patch('socket.getfqdn')
def test_address_string_doesnt_do_reverse_dns_lookup(self, getfqdn):
request_mock = mock.MagicMock()
request_mock.makefile().readline.side_effect = [
'GET /vnc.html?token=123-456-789 HTTP/1.1\r\n',
''
]
server_mock = mock.MagicMock()
client_address = ('8.8.8.8', 54321)
handler = websocketproxy.NovaProxyRequestHandler(
request_mock, client_address, server_mock)
handler.log_message('log message using client address context info')
self.assertFalse(getfqdn.called) # no reverse dns look up
self.assertEqual(handler.address_string(), '8.8.8.8') # plain address