← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1388351] [NEW] NoVNC does not work under python 2.7.4

 

Public bug reported:

noVNCproxy will not be functional if  python version lower than 2.7.4.
It will raise exception as below:

parse = urlparse.urlparse(self.path)	
if parse.scheme not in ('http', 'https'):	
	# From a bug in urlparse in Python < 2.7.4 we cannot support 
	# special schemes (cf: http://bugs.python.org/issue9374) 
	if sys.version_info < (2, 7, 4):	
		raise exception.NovaException(
			_("We do not support scheme '%s' under Python < 2.7.4, ")

This statement check is Incorrect. Not only because parse.schema will
always be '', but also this is not relevant to any python versions.

The reason is that 
1) When user trigger webbrower novnc url such as
http://192.168.1.105:6080/vnc_auto.html?token=2d58d946-1469-48c5-9082-44ac6e1a59e5
basic python TCP modules will parse the request information in BaseHTTPServer.py. for the HTTP command, URI, and the request version. 

2)  Since the request is to get the vnc_auto.html.  the vnc module will
sent out the html to browser.

3) With the vnc_auto html page rendering, on page load method, it will make a new request to /websockify.
            path = WebUtil.getQueryVar('path', 'websockify');
           .....
            rfb.connect(host, port, password, path);

4) The /websokify request(with token in the cookie) will flow to
websokify framework which following to
NovaProxyRequestHandler(websockify request handler) to make token
validations(rpc sent to nova consoleauth). The token is

5) After token validation passed, NovaProxyRequestHandler will proxy to
compute Host, vnc port(5900)

So by that means, the self.path in NovaProxyRequestHandlerBase.new_websocket_client will always being '/websockify'. 
It will never return scheme if using urlparse.parse('/websockify') and not relevant to any python versions. 

With removing the check and exception(revert commit
https://review.openstack.org/#/c/125398/), the vnc function will be
function well.


Following is the right flow: 
192.168.1.104 - - [01/Nov/2014 14:31:27] # requestline in BaseHTTPServer py2.7.6: GET /vnc_auto.html?token=2d58d946-1469-48c5-9082-44ac6e1a59e5 HTTP/1.1
192.168.1.104 - - [01/Nov/2014 14:31:27] # self.path is /vnc_auto.html?token=2d58d946-1469-48c5-9082-44ac6e1a59e5
192.168.1.104 - - [01/Nov/2014 14:31:27] # self.request_version HTTP/1.1
192.168.1.104 - - [01/Nov/2014 14:31:27] "GET /vnc_auto.html?token=2d58d946-1469-48c5-9082-44ac6e1a59e5 HTTP/1.1" 200 -
2014-11-01 14:31:28.231 DEBUG nova.console.websocketproxy [-] 192.168.1.104: new handler Process from (pid=15763) vmsg /usr/local/lib/python2.7/dist-packages/websockify/websocket.py:824
192.168.1.104 - - [01/Nov/2014 14:31:28] # requestline in py2.7.6: GET /websockify HTTP/1.1
192.168.1.104 - - [01/Nov/2014 14:31:28] # self.path is /websockify
192.168.1.104 - - [01/Nov/2014 14:31:28] # self.request_version HTTP/1.1
192.168.1.104 - - [01/Nov/2014 14:31:28] "GET /websockify HTTP/1.1" 101 -
192.168.1.104 - - [01/Nov/2014 14:31:28] 192.168.1.104: Plain non-SSL (ws://) WebSocket connection
192.168.1.104 - - [01/Nov/2014 14:31:28] 192.168.1.104: Version hybi-13, base64: 'False'
192.168.1.104 - - [01/Nov/2014 14:31:28] 192.168.1.104: Path: '/websockify'
2014-11-01 14:31:28.270 INFO nova.console.websocketproxy [-] self.path in new_websocket_client in python276is  /websockify
2014-11-01 14:31:28.271 INFO nova.console.websocketproxy [-] parse.scheme in pythone276 is
2014-11-01 14:31:28.272 INFO nova.console.websocketproxy [-] parse.query in new_websocket_client
2014-11-01 14:31:28.272 INFO nova.console.websocketproxy [-] token after urlparse.parse_qs:
2014-11-01 14:31:28.273 INFO nova.console.websocketproxy [-] self.headers is Host: 192.168.1.105:6080
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en,zh-cn;q=0.8,zh-tw;q=0.5,en-us;q=0.3
Accept-Encoding: gzip, deflate
Sec-WebSocket-Version: 13
Origin: http://192.168.1.105:6080
Sec-WebSocket-Protocol: binary, base64
Sec-WebSocket-Key: FxJXwRLEslPNU+nmcwIVzw==
Cookie: token=2d58d946-1469-48c5-9082-44ac6e1a59e5
Connection: keep-alive, Upgrade
Pragma: no-cache
Cache-Control: no-cache
Upgrade: websocket

2014-11-01 14:31:28.282 INFO oslo.messaging._drivers.impl_rabbit [req-1404bf1a-b530-4708-be0c-007bafcbf998 None None] Connecting to AMQP server on 127.0.0.1:5672
2014-11-01 14:31:28.300 INFO oslo.messaging._drivers.impl_rabbit [req-1404bf1a-b530-4708-be0c-007bafcbf998 None None] Connected to AMQP server on 127.0.0.1:5672
2014-11-01 14:31:28.305 INFO oslo.messaging._drivers.impl_rabbit [req-1404bf1a-b530-4708-be0c-007bafcbf998 None None] Connecting to AMQP server on 127.0.0.1:5672
2014-11-01 14:31:28.312 INFO oslo.messaging._drivers.impl_rabbit [req-1404bf1a-b530-4708-be0c-007bafcbf998 None None] Connected to AMQP server on 127.0.0.1:5672
2014-11-01 14:31:28.405 INFO nova.console.websocketproxy [req-1404bf1a-b530-4708-be0c-007bafcbf998 None None]   8: connect info: {u'instance_uuid': u'77c1709d-e051-4954-bd6e-1f444f31084e', u'internal_access_path': None, u'last_activity_at': 1414823475.800361, u'console_type': u'novnc', u'host': u'127.0.0.1', u'token': u'2d58d946-1469-48c5-9082-44ac6e1a59e5', u'port': u'5900'}
2014-11-01 14:31:28.406 INFO nova.console.websocketproxy [req-1404bf1a-b530-4708-be0c-007bafcbf998 None None]   8: connecting to: 127.0.0.1:5900

** Affects: nova
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1388351

Title:
  NoVNC does not work under python 2.7.4

Status in OpenStack Compute (Nova):
  New

Bug description:
  noVNCproxy will not be functional if  python version lower than 2.7.4.
  It will raise exception as below:

  parse = urlparse.urlparse(self.path)	
  if parse.scheme not in ('http', 'https'):	
  	# From a bug in urlparse in Python < 2.7.4 we cannot support 
  	# special schemes (cf: http://bugs.python.org/issue9374) 
  	if sys.version_info < (2, 7, 4):	
  		raise exception.NovaException(
  			_("We do not support scheme '%s' under Python < 2.7.4, ")

  This statement check is Incorrect. Not only because parse.schema will
  always be '', but also this is not relevant to any python versions.

  The reason is that 
  1) When user trigger webbrower novnc url such as
  http://192.168.1.105:6080/vnc_auto.html?token=2d58d946-1469-48c5-9082-44ac6e1a59e5
  basic python TCP modules will parse the request information in BaseHTTPServer.py. for the HTTP command, URI, and the request version. 

  2)  Since the request is to get the vnc_auto.html.  the vnc module
  will sent out the html to browser.

  3) With the vnc_auto html page rendering, on page load method, it will make a new request to /websockify.
              path = WebUtil.getQueryVar('path', 'websockify');
             .....
              rfb.connect(host, port, password, path);

  4) The /websokify request(with token in the cookie) will flow to
  websokify framework which following to
  NovaProxyRequestHandler(websockify request handler) to make token
  validations(rpc sent to nova consoleauth). The token is

  5) After token validation passed, NovaProxyRequestHandler will proxy
  to compute Host, vnc port(5900)

  So by that means, the self.path in NovaProxyRequestHandlerBase.new_websocket_client will always being '/websockify'. 
  It will never return scheme if using urlparse.parse('/websockify') and not relevant to any python versions. 

  With removing the check and exception(revert commit
  https://review.openstack.org/#/c/125398/), the vnc function will be
  function well.


  Following is the right flow: 
  192.168.1.104 - - [01/Nov/2014 14:31:27] # requestline in BaseHTTPServer py2.7.6: GET /vnc_auto.html?token=2d58d946-1469-48c5-9082-44ac6e1a59e5 HTTP/1.1
  192.168.1.104 - - [01/Nov/2014 14:31:27] # self.path is /vnc_auto.html?token=2d58d946-1469-48c5-9082-44ac6e1a59e5
  192.168.1.104 - - [01/Nov/2014 14:31:27] # self.request_version HTTP/1.1
  192.168.1.104 - - [01/Nov/2014 14:31:27] "GET /vnc_auto.html?token=2d58d946-1469-48c5-9082-44ac6e1a59e5 HTTP/1.1" 200 -
  2014-11-01 14:31:28.231 DEBUG nova.console.websocketproxy [-] 192.168.1.104: new handler Process from (pid=15763) vmsg /usr/local/lib/python2.7/dist-packages/websockify/websocket.py:824
  192.168.1.104 - - [01/Nov/2014 14:31:28] # requestline in py2.7.6: GET /websockify HTTP/1.1
  192.168.1.104 - - [01/Nov/2014 14:31:28] # self.path is /websockify
  192.168.1.104 - - [01/Nov/2014 14:31:28] # self.request_version HTTP/1.1
  192.168.1.104 - - [01/Nov/2014 14:31:28] "GET /websockify HTTP/1.1" 101 -
  192.168.1.104 - - [01/Nov/2014 14:31:28] 192.168.1.104: Plain non-SSL (ws://) WebSocket connection
  192.168.1.104 - - [01/Nov/2014 14:31:28] 192.168.1.104: Version hybi-13, base64: 'False'
  192.168.1.104 - - [01/Nov/2014 14:31:28] 192.168.1.104: Path: '/websockify'
  2014-11-01 14:31:28.270 INFO nova.console.websocketproxy [-] self.path in new_websocket_client in python276is  /websockify
  2014-11-01 14:31:28.271 INFO nova.console.websocketproxy [-] parse.scheme in pythone276 is
  2014-11-01 14:31:28.272 INFO nova.console.websocketproxy [-] parse.query in new_websocket_client
  2014-11-01 14:31:28.272 INFO nova.console.websocketproxy [-] token after urlparse.parse_qs:
  2014-11-01 14:31:28.273 INFO nova.console.websocketproxy [-] self.headers is Host: 192.168.1.105:6080
  User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0
  Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  Accept-Language: en,zh-cn;q=0.8,zh-tw;q=0.5,en-us;q=0.3
  Accept-Encoding: gzip, deflate
  Sec-WebSocket-Version: 13
  Origin: http://192.168.1.105:6080
  Sec-WebSocket-Protocol: binary, base64
  Sec-WebSocket-Key: FxJXwRLEslPNU+nmcwIVzw==
  Cookie: token=2d58d946-1469-48c5-9082-44ac6e1a59e5
  Connection: keep-alive, Upgrade
  Pragma: no-cache
  Cache-Control: no-cache
  Upgrade: websocket

  2014-11-01 14:31:28.282 INFO oslo.messaging._drivers.impl_rabbit [req-1404bf1a-b530-4708-be0c-007bafcbf998 None None] Connecting to AMQP server on 127.0.0.1:5672
  2014-11-01 14:31:28.300 INFO oslo.messaging._drivers.impl_rabbit [req-1404bf1a-b530-4708-be0c-007bafcbf998 None None] Connected to AMQP server on 127.0.0.1:5672
  2014-11-01 14:31:28.305 INFO oslo.messaging._drivers.impl_rabbit [req-1404bf1a-b530-4708-be0c-007bafcbf998 None None] Connecting to AMQP server on 127.0.0.1:5672
  2014-11-01 14:31:28.312 INFO oslo.messaging._drivers.impl_rabbit [req-1404bf1a-b530-4708-be0c-007bafcbf998 None None] Connected to AMQP server on 127.0.0.1:5672
  2014-11-01 14:31:28.405 INFO nova.console.websocketproxy [req-1404bf1a-b530-4708-be0c-007bafcbf998 None None]   8: connect info: {u'instance_uuid': u'77c1709d-e051-4954-bd6e-1f444f31084e', u'internal_access_path': None, u'last_activity_at': 1414823475.800361, u'console_type': u'novnc', u'host': u'127.0.0.1', u'token': u'2d58d946-1469-48c5-9082-44ac6e1a59e5', u'port': u'5900'}
  2014-11-01 14:31:28.406 INFO nova.console.websocketproxy [req-1404bf1a-b530-4708-be0c-007bafcbf998 None None]   8: connecting to: 127.0.0.1:5900

To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1388351/+subscriptions


Follow ups

References