Bug 1116009 - sdk always raises a DisconnectedError trying to instantiate again after a previous failure
Summary: sdk always raises a DisconnectedError trying to instantiate again after a pre...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: oVirt
Classification: Retired
Component: ovirt-engine-sdk
Version: 3.5
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
: 3.5.0
Assignee: Juan Hernández
QA Contact: Petr Beňas
URL:
Whiteboard: infra
: 1113882 (view as bug list)
Depends On:
Blocks: 1073943 1113882
TreeView+ depends on / blocked
 
Reported: 2014-07-03 13:43 UTC by Simone Tiraboschi
Modified: 2016-02-10 19:30 UTC (History)
7 users (show)

Fixed In Version: ovirt-engine-sdk-python-3.5.0.2
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-10-17 12:30:04 UTC
oVirt Team: Infra
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
oVirt gerrit 29684 0 master MERGED codegen: Ignore errors when cleaning old connection Never
oVirt gerrit 29707 0 sdk_3.5 MERGED codegen: Ignore errors when cleaning old connection Never

Description Simone Tiraboschi 2014-07-03 13:43:32 UTC
Description of problem:
in engine-setup, in the all-in-one configuration, I need to setup the engine and only when it 's available I need to add the host itself via the API using the SDK.
To check the engine status I'm looping (till a maximum of retry with a sleep time between each attempt) trying to instantiate the SDK till the engine is ready.

If the system isn't fast enough first attempt goes wrong getting a 503 error (<title>503 Service Unavailable</title> </head><body> <h1>Service Unavailable</h1> <p>The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.</p>)
and than any further attempt fails raising a Disconnected Error.

I suppose that the problem is due to the fact that ovirtsdk/apy.py in the __init__ firstly tries to 
        # Implicitly disconnect and perform cleanup
        # when detected instance of the SDK proxy with
        # ref-count == 0
        if context.manager.has_key(self.__id):
            self.disconnect()
call the disconnect method but the previous attempt never got connected and that the disconnect() always raise a DisconnectedError preventing any further attempt.


Version-Release number of selected component (if applicable):
ovirt-engine-sdk-python.noarch         3.5.0.0-1.20140605.git1267422.fc19

How reproducible:
100%

Steps to Reproduce:
1. try to connect to system that is not fully running
2. wait
3. try again

Actual results:
it raises a DisconnectedError

Expected results:
a working SDK instance

Additional info:

Comment 1 Juan Hernández 2014-07-08 12:43:07 UTC
The change to the code generator that fixes this issue has been merged, now the SDK needs to be regenerated.

Comment 2 Simone Tiraboschi 2014-07-08 14:01:37 UTC
*** Bug 1113882 has been marked as a duplicate of this bug. ***

Comment 3 Petr Beňas 2014-08-07 12:40:56 UTC
I'm still able to reproduce couple of errors between 'temporary unavailable' and working sdk instance, but finally got one. Is it ok for you this way? 


[root@pb-rh35 ~]# cat test.py 
#!/usr/bin/env python

from ovirtsdk.api import API
from ovirtsdk.xml import params
from time import sleep

def loop_connect():
        try:
            api = API (url="TODO",
                       username="admin@internal",
                       password="XXXXX",
                       ca_file="ca.crt")

            print "Connected to %s successfully!" % api.get_product_info().name
            api.disconnect()

        except Exception as ex:
            print "Unexpected error: %s" % ex
            sleep(0.3)
            loop_connect()

loop_connect()
[root@pb-rh35 ~]# service ovirt-engine restart; ./test.py 
Stopping oVirt Engine:                                     [  OK  ]
Starting oVirt Engine:                                     [  OK  ]
Unexpected error: 
status: 503
reason: Service Temporarily Unavailable
detail: 
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>503 Service Temporarily Unavailable</title>
</head><body>
<h1>Service Temporarily Unavailable</h1>
<p>The server is temporarily unable to service your
request due to maintenance downtime or capacity
problems. Please try again later.</p>
<hr>
<address>Apache/2.2.22 (Red Hat Enterprise Web Server) Server at TODO Port 443</address>
</body></html>

<snip> couple of 503s </snip>

Unexpected error: 
status: 503
reason: Service Temporarily Unavailable
detail: 
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>503 Service Temporarily Unavailable</title>
</head><body>
<h1>Service Temporarily Unavailable</h1>
<p>The server is temporarily unable to service your
request due to maintenance downtime or capacity
problems. Please try again later.</p>
<hr>
<address>Apache/2.2.22 (Red Hat Enterprise Web Server) Server at TODO Port 443</address>
</body></html>

Unexpected error: 
status: 404
reason: Not Found
detail: 
Unexpected error: 
status: 404
reason: Not Found
detail: 
Unexpected error: 
status: 404
reason: Not Found
detail: 
Unexpected error: 
status: 404
reason: Not Found
detail: 
Unexpected error: 
status: 500
reason: Internal Server Error
detail: HTTP Status 500
Unexpected error: 
status: 500
reason: Internal Server Error
detail: HTTP Status 500
Unexpected error: 
status: 500
reason: Internal Server Error
detail: HTTP Status 500
Unexpected error: 
status: 401
reason: Unauthorized
detail: HTTP Status 401
Connected to oVirt Engine successfully!

Comment 4 Simone Tiraboschi 2014-08-08 16:58:44 UTC
I think so

Comment 5 Petr Beňas 2014-08-14 11:32:06 UTC
Ok then

Comment 6 Sandro Bonazzola 2014-10-17 12:30:04 UTC
oVirt 3.5 has been released and should include the fix for this issue.


Note You need to log in before you can comment on or make changes to this bug.