kimchi-project / kimchi

An HTML5 management interface for KVM guests
https://github.com/kimchi-project/kimchi/releases/latest
Other
3.09k stars 365 forks source link

Bug: TypeError: get() got an unexpected keyword argument 'token' #1165

Closed time-river closed 6 years ago

time-river commented 7 years ago

When I use View Console through VNC method, the page popd can't display, error:

[17/Aug/2017:15:59:20] HTTP 
Request Headers:
  COOKIE: username=novell; user_role=admin; lastPage="/#plugins/kimchi/tabs/guests"; wok=7285e0983aacd285c2c97caedabe3960b7d8f03d; token=dGVzdC0z
  ORIGIN: https://147.2.207.237:8001
  Remote-Addr: 127.0.0.1
  X-REAL-IP: 147.2.212.73
  SEC-WEBSOCKET-EXTENSIONS: permessage-deflate; client_max_window_bits
  USER-AGENT: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36
  CONNECTION: close
  PRAGMA: no-cache
  DNT: 1
  HOST: 147.2.207.237
  CACHE-CONTROL: no-cache
  SEC-WEBSOCKET-VERSION: 13
  SEC-WEBSOCKET-PROTOCOL: binary
  ACCEPT-LANGUAGE: zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4,zh-TW;q=0.2
  SEC-WEBSOCKET-KEY: SAsYqMwYRqaM8FxsPGk1mQ==
  X-FORWARDED-FOR: 147.2.212.73
  ACCEPT-ENCODING: gzip, deflate, br
INFO:cherrypy.error.140432735853520:[17/Aug/2017:15:59:20] HTTP 
Request Headers:
  COOKIE: username=novell; user_role=admin; lastPage="/#plugins/kimchi/tabs/guests"; wok=7285e0983aacd285c2c97caedabe3960b7d8f03d; token=dGVzdC0z
  ORIGIN: https://147.2.207.237:8001
  Remote-Addr: 127.0.0.1
  X-REAL-IP: 147.2.212.73
  SEC-WEBSOCKET-EXTENSIONS: permessage-deflate; client_max_window_bits
  USER-AGENT: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36
  CONNECTION: close
  PRAGMA: no-cache
  DNT: 1
  HOST: 147.2.207.237
  CACHE-CONTROL: no-cache
  SEC-WEBSOCKET-VERSION: 13
  SEC-WEBSOCKET-PROTOCOL: binary
  ACCEPT-LANGUAGE: zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4,zh-TW;q=0.2
  SEC-WEBSOCKET-KEY: SAsYqMwYRqaM8FxsPGk1mQ==
  X-FORWARDED-FOR: 147.2.212.73
  ACCEPT-ENCODING: gzip, deflate, br
[17/Aug/2017:15:59:20] HTTP 
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/CherryPy-11.0.1.dev70+g1b979c3e-py2.7.egg/cherrypy/_cprequest.py", line 670, in respond
    response.body = self.handler()
  File "/usr/lib/python2.7/site-packages/CherryPy-11.0.1.dev70+g1b979c3e-py2.7.egg/cherrypy/lib/encoding.py", line 221, in __call__
    self.body = self.oldhandler(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/CherryPy-11.0.1.dev70+g1b979c3e-py2.7.egg/cherrypy/_cpdispatch.py", line 60, in __call__
    return self.callable(*self.args, **self.kwargs)
  File "/usr/lib/python2.7/site-packages/wok/control/base.py", line 219, in index
    'PUT': self.update}[method](*args, **kargs)
TypeError: get() got an unexpected keyword argument 'token'

I debug it, add those print code:

# /usr/lib/python2.7/site-packages/wok/control/base.py
    @cherrypy.expose
    def index(self, *args, **kargs):
        # status must be always set in order to request be logged.
        # use 500 as fallback for "exception not handled" cases.
        details = None
        status = 500

        method = validate_method(('GET', 'DELETE', 'PUT'), self.admin_methods)

        try:
            self.lookup()
            if not self.is_authorized():
                raise UnauthorizedError('WOKAPI0009E')

+            print('method: ', method)
+            print('args: ', args)
+            print('kargs: ', kargs)
+            print("test: ", selt)

            result = {'GET': self.get,
                      'DELETE': self.delete,
                      'PUT': self.update}[method](*args, **kargs)

            status = cherrypy.response.status

Output:

('method: ', 'GET')
('args: ', ())
('kargs: ', {'token': u'dGVzdC0z'})
('test: ', <wok.root.WokRoot object at 0x7fb90b55d690>)

Compared with the normal output using the print ..., token shouldn't appear in the ('kargs: ', {'token': u'dGVzdC0z'}).

Guess: the wrong URL parsing results in it. the original URL is

https://X.X.X.X:8001/plugins/kimchi/novnc/vnc_auto.html?port=8001&path=/websockify?token=dGVzdC0z&encrypt=1

After modified:

https://147.2.208.237:8001/plugins/kimchi/novnc/vnc_auto.html?port=8001&path=websockify?token=dGVzdC0z&encrypt=1

different: path=/websockify? VS path=websockify

Great. My temporary solution:

--- orig-kimchi-2.5.0/ui/js/src/kimchi.api.js   2017-06-30 21:40:06.000000000 +0800
+++ kimchi-2.5.0/ui/js/src/kimchi.api.js    2017-08-17 14:47:33.878209062 +0800
@@ -348,7 +348,7 @@
             url += server_root;
             url += "/plugins/kimchi/novnc/vnc_auto.html";
             url += "?port=" + proxy_port;
-            url += "&path=" + server_root + "/websockify";
+            url += "&path=" + server_root + "websockify";
             /*
              * From python documentation base64.urlsafe_b64encode(s)
              * substitutes - instead of + and _ instead of / in the

However, path=/websockify? works well in another machine, the same version of wok, kimchi, cherrypy. I don't konw the use of /... Hope you can solve it.

alinefm commented 7 years ago

Hi!

Please, provide as much details as you can to reproduce this issue. What is the host OS? Kimchi, Wok, cherrypy and novnc versions?

time-river commented 7 years ago

work well: host OS: openSUSE Leap_42.1 Kimchi: 2.5.0(the last release) Wok: 2.5.0 (the last release) CherryPy: current master——1b979c3 Novnc: 0.5.1

work bad: host OS: openSUSE Tumbleweed Kimchi: 2.5.0(the last release) Wok: 2.5.0 (the last release) CherryPy: current master——1b979c3 Novnc: 0.6.2

I don't know whether CherryPy or Kimchi results in it. In my memory, openSUSE Leap_42.1 had also worked badly once, but it has worked well now, I don't know why. And I can't reappear its condition.

Yesterday, I debuged it, I found(guess) kargs should be as the parameters related to VNC, but token obviously is not. So, I think there is maybe a question about url parsing.

Could you tell me the use of / in path=/websockify? ? Is there a difference between path=websockify? and path=/websockify??

Woovie commented 7 years ago

I am having the same issue. I installed wok, kimchi, ginger-base, and ginger all via the provided RPMs on the github.io page.

Fedora 26

Name : python-cherrypy Version : 3.5.0 Release : 1.fc22

Name : wok Version : 2.5.0 Release : 0.fc25

Name : kimchi Version : 2.5.0 Release : 0.fc25

Modified /usr/share/wok/plugins/kimchi/ui/js/kimchi.min.js directly using a sed line to remove the forward slash. Now working as intended.

Full error output to the /var/log/wok/wok-error.log file.

File "/usr/lib/python2.7/site-packages/cherrypy/_cprequest.py", line 670, in respond response.body = self.handler() File "/usr/lib/python2.7/site-packages/cherrypy/lib/encoding.py", line 217, in call self.body = self.oldhandler(*args, kwargs) File "/usr/lib/python2.7/site-packages/cherrypy/_cpdispatch.py", line 61, in call return self.callable(*self.args, *self.kwargs) File "/usr/lib/python2.7/site-packages/cherrypy/_cptools.py", line 175, in handle_func handled = self.callable(args, self._merged_args(kwargs)) TypeError: staticfile() got multiple values for keyword argument 'filename'

[22/Aug/2017:00:11:53] HTTP Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/cherrypy/_cprequest.py", line 670, in respond response.body = self.handler() File "/usr/lib/python2.7/site-packages/cherrypy/lib/encoding.py", line 217, in call self.body = self.oldhandler(*args, kwargs) File "/usr/lib/python2.7/site-packages/cherrypy/_cpdispatch.py", line 61, in call return self.callable(*self.args, *self.kwargs) File "/usr/lib/python2.7/site-packages/wok/control/base.py", line 209, in index 'PUT': self.update}[method](args, kargs) TypeError: get() got an unexpected keyword argument 'token'

time-river commented 7 years ago

pull #1172 solve this question. My method is not good