RAPI Client Errors

115 views
Skip to first unread message

Russell

unread,
Jun 14, 2010, 5:57:23 PM6/14/10
to gan...@googlegroups.com
I'm trying to use the provided RAPI client, but keep getting a certain error.

If I do (with actual hostnames):


It works fine

But if I execute this:

import client

if __name__ == '__main__':
    rapi = client.GanetiRapiClient('ganeti.example.com')
    print rapi.GetInfo()

I get this:

/home/russell_h/ganetiweb/ganeti/rapi/client.py:239: DeprecationWarning: FakeSocket is deprecated, and won't be in 3.x.  Use the result of ssl.wrap_socket() directly instead.
  self.sock = httplib.FakeSocket(sock, ssl)
Traceback (most recent call last):
  File "test.py", line 5, in <module>
    print rapi.GetInfo()
  File "/home/russell_h/ganetiweb/ganeti/rapi/client.py", line 490, in GetInfo
    None, None)
  File "/home/russell_h/ganetiweb/ganeti/rapi/client.py", line 418, in _SendRequest
    resp = self._http.open(req)
  File "/usr/lib/python2.6/urllib2.py", line 389, in open
    response = self._open(req, data)
  File "/usr/lib/python2.6/urllib2.py", line 407, in _open
    '_open', req)
  File "/usr/lib/python2.6/urllib2.py", line 367, in _call_chain
    result = func(*args)
  File "/home/russell_h/ganetiweb/ganeti/rapi/client.py", line 272, in https_open
    return self.do_open(self._CreateHttpsConnection, req)
  File "/usr/lib/python2.6/urllib2.py", line 1119, in do_open
    r = h.getresponse()
  File "/usr/lib/python2.6/httplib.py", line 972, in getresponse
    method=self._method)
  File "/usr/lib/python2.6/httplib.py", line 330, in __init__
    self.fp = sock.makefile('rb', 0)
NotImplementedError: Cannot make file object of SSL.Connection

Has anyone else gotten this, or have any idea what this is about?

Thanks,
-Russell

Michael Hanselmann

unread,
Jun 15, 2010, 5:17:37 AM6/15/10
to gan...@googlegroups.com
Hi Russell

Am 14. Juni 2010 22:57 schrieb Russell <russell...@gmail.com>:
> […]


>   File "/usr/lib/python2.6/httplib.py", line 330, in __init__
>     self.fp = sock.makefile('rb', 0)
> NotImplementedError: Cannot make file object of SSL.Connection
> Has anyone else gotten this, or have any idea what this is about?

It's due to something that changed between Python 2.5 and 2.6. I'll
have a look into it. Expect a patch.

Michael

Michael Hanselmann

unread,
Jun 17, 2010, 10:52:31 AM6/17/10
to gan...@googlegroups.com
Hi

This has been fixed in commit beba56ae8.

http://git.ganeti.org/?p=ganeti.git;a=commit;h=beba56ae8

Michael

Russell

unread,
Jun 18, 2010, 2:08:52 PM6/18/10
to gan...@googlegroups.com
Michael,

Thanks!

I'm hitting another (unrelated) issue now, that I'm having a little trouble tracking down. Testing against 6 clusters (I think they're all on 2.1.2.1, and I'm running the latest RAPI client), every call I've tried has worked, except one call against one cluster. When I try "client.GetInstances(bulk=True)" against the largest of the clusters (63 instances - the others have less than 10 off the top of my head) it gives the following error:

Traceback (most recent call last):
  File "do.py", line 4, in <module>
    print len(client.GetInstances(bulk=True))
  File "/home/russell_h/ganetiweb/ganeti/rapi/client.py", line 586, in GetInstances
    query, None)
  File "/home/russell_h/ganetiweb/ganeti/rapi/client.py", line 454, in _SendRequest
    raise CertificateError("SSL issue: %s (%r)" % (err, err))
rapi.client.CertificateError: SSL issue: (9, 'Bad file descriptor') (SysCallError(9, 'Bad file descriptor'))

I'm not doing anything with SSL on my end, the entire test client is:

from rapi.client import GanetiRapiClient

client = GanetiRapiClient('ganeti.example.com')
print client.GetInstances(bulk=True)

If I try it without "bulk=True" it works fine. My only guess is that this has something to do with the size of the return, but I can't find any other calls with a large enough return value to trigger the issue (we keep the job queue tidy, and the largest cluster has only 4 nodes). Does that seem plausible? I can do the same RAPI call with httplib2 without issue.

Let me know if I can do anything to help track this down.

Thanks,
-Russell

Michael Hanselmann

unread,
Jun 18, 2010, 2:48:07 PM6/18/10
to gan...@googlegroups.com
Hi Russell

Am 18. Juni 2010 19:08 schrieb Russell <russell...@gmail.com>:
>     raise CertificateError("SSL issue: %s (%r)" % (err, err))
> rapi.client.CertificateError: SSL issue: (9, 'Bad file descriptor')
> (SysCallError(9, 'Bad file descriptor'))

I can reproduce this error (better backtrace below) and strongly
suspect this being related to the issues described in the commit
message of my fix. I'm working on improving OpenSSL integration, which
we'll also be able to use in the RAPI client, but I can't give any ETA
right now. You can use httplib2 as a work-around and decode the
results using simplejson, though you should make sure to enable
certificate verification (only available in Python 2.6 and above).


File "…", line 451, in _SendRequest
encoded_response_content = resp.read()
File "…/python2.6/socket.py", line 329, in read
data = self._sock.recv(rbufsize)
File "…/python2.6/httplib.py", line 538, in read
s = self.fp.read(amt)
File "…/python2.6/socket.py", line 353, in read
data = self._sock.recv(left)
OpenSSL.SSL.SysCallError: (9, 'Bad file descriptor')

Michael

Russell

unread,
Jun 18, 2010, 2:57:52 PM6/18/10
to gan...@googlegroups.com
Michael,

Great, I'm glad thats not just me. I have a working solution with httplib2 already (although I don't currently do any certificate verification - should probably enable that), so don't hurry on my account. I just wanted to give the RAPI client a shot, no sense in duplicating all of that code, etc.

Anyway, thanks for checking that for me!

-Russell

Michael Hanselmann

unread,
Jul 1, 2010, 8:45:11 AM7/1/10
to gan...@googlegroups.com
Hello

Am 18. Juni 2010 20:48 schrieb Michael Hanselmann <han...@google.com>:
> Am 18. Juni 2010 19:08 schrieb Russell <russell...@gmail.com>:
>>     raise CertificateError("SSL issue: %s (%r)" % (err, err))
>> rapi.client.CertificateError: SSL issue: (9, 'Bad file descriptor')
>> (SysCallError(9, 'Bad file descriptor'))
>
> I can reproduce this error (better backtrace below) and strongly
> suspect this being related to the issues described in the commit
> message of my fix. I'm working on improving OpenSSL integration, which
> we'll also be able to use in the RAPI client, but I can't give any ETA
> right now.

Ganeti 2.2 will have a RAPI client built on top of PycURL (commit
2a7c3583d5). It'll be distributed as part of Ganeti 2.2.0~beta1 and
add a new dependency, python-pycurl.

Michael

Reply all
Reply to author
Forward
0 new messages