On 03/22/2017 01:10 PM, nicolas(a)devels.es wrote:
Hi,
We've recently upgraded from oVirt 4.0.x to 4.1.0 and it seems that the
behavior of a script we wrote in Python-SDK has changed slightly. We
have a script that needs to be executed forever (daemon mode). This
daemon creates an ovirtsdk4.Connection object and uses the same
Connection object all the time.
conn = sdk.Connection(
url=URI,
username=USERNAME,
password=PASSWORD,
ca_file=CAFILE
)
Between iterations we have ~5 minutes delays which we accomplish with a
time.sleep(...) call.
After some of these iterations (5 or 6), when trying to perform an
operation on the Connection object (in this case, listing all SDs):
try:
sys_serv = conn.system_service()
sd_serv = sys_serv.storage_domains_service()
storages = sd_serv.list(search=sd_search_query)
except Error, e:
log('ERR: Error getting storage domains: %s' % (e))
We start getting exceptions (i.e., the sd_serv.list() call throwing an
Error exception) with this message:
ERR: Error getting storage domains: HTTP response code is 401.
I believe this has something to do with the Connection object expiring
(even if it's not idle more than 5 minutes at any time). Is there a way
to "refresh" the Connection object so it doesn't auto-logout (assuming
this is the actual problem)?
As I said, this started happening as of oVirt 4.1.0.
ovirt-engine-sdk-python version is 4.1.1.
Any ideas?
This sound like this bug, opened yesterday:
SSO token used for the API expires when running only queries
https://bugzilla.redhat.com/1434605
But I thought the same happened in 4.0. Can you confirm that you don't
see this problem in 4.0?
Open possible workaround is to force a refresh of the backend session
sending an external event, like in this example:
https://github.com/oVirt/ovirt-engine-sdk/blob/master/sdk/examples/vm_bac...
I also think that we need to modify the SDKs so that they detect expired
SSO tokens and renew them automatically. I will open another bug for that.