Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1448511

Summary: event.id type is inconsistent
Product: [oVirt] ovirt-engine Reporter: Fabrice Bacchella <fabrice.bacchella>
Component: RestAPIAssignee: Juan Hernández <juan.hernandez>
Status: CLOSED CURRENTRELEASE QA Contact: Radim Hrazdil <rhrazdil>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: ---CC: bugs, juan.hernandez, lsvaty, mperina, oourfali, stirabos
Target Milestone: ovirt-4.1.3Flags: rule-engine: ovirt-4.1+
lsvaty: testing_ack+
Target Release: 4.1.3.3   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-07-06 13:25:15 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Infra RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Fabrice Bacchella 2017-05-05 15:44:27 UTC
The following code fails:

event_service = connection.system_service().events_service()
last_event = event_service.list(max=1)[0]
print "%s %s" % (last_event.id, type(last_event.id))
new_event = event_service.list(from_=last_event.id)

with:
50792 <type 'str'>
...
TypeError: The 'from_' parameter should be of type 'int', but it is of type 'str'.


Indeed event.id is a string but from expect a number. That's inconsistent. It might be to late to change event.id to a int, and for all other types it's a string, so changing it is probably not possible.

But then from_ should allow string argument.

Comment 1 Ondra Machacek 2017-05-10 10:44:33 UTC
The 'id' is for all the entities a String, where usually it's 'uid'. In case of the event it's integer, so that's why the 'from_' takes integer as parameter. I know it's not nice, but still there is very easy workaround. We can change it in API version 5, due to backward compatibility. Or we can add another similar parameter with different type, but I don't really think we need it. So I would leave this bug for the oVirt 5. Juan what do you think?

Comment 2 Juan Hernández 2017-05-10 12:14:46 UTC
The 'id' of the entity needs to be kept as an string, as it is handled in the same way for all entities, not just for events. And 'from' should be an integer, as there is an implicit concept of total order. What we can do is add a new attribute to the 'Event' type that has the same value but that is declared as integer in the specification of the API. Maybe 'sequence' or 'index':

  <event id="123" href="/ovirt-engine/api/events">
    <index>123</index>
    ...
  </event>

If it is declared as integer in the specification then it will be treated as integer in all the SDKs, so you will be able to do this:

  events_service = connection.system_service().events_service()
  last_event = events_service.list(max=1)[0]
  new_event = events_service.list(from_=last_event.index)

We can add that attribute without breaking backwards compatibility, before version 5 of the API. But we can't retrofit it to older versions of the engine, so if you want to support those older versions you will need to use a workaround anyhow.

Comment 3 Juan Hernández 2017-05-31 13:21:45 UTC
The change in the specification of the API has been merged and released with versions 4.2.12 and 4.1.37. Now the engine itself needs to be modified to handle correctly the new attribute.

Comment 4 Martin Perina 2017-06-14 13:28:12 UTC
Moving back to 4.1.3 as it's part of 4.1.3.2 build

Comment 5 rhev-integ 2017-06-16 16:44:38 UTC
INFO: Bug status wasn't changed from MODIFIED to ON_QA due to the following reason:

[Tag 'ovirt-engine-4.1.3.4' doesn't contain patch 'https://gerrit.ovirt.org/77594']
gitweb: https://gerrit.ovirt.org/gitweb?p=ovirt-engine.git;a=shortlog;h=refs/tags/ovirt-engine-4.1.3.4

For more info please contact: infra

Comment 6 Martin Perina 2017-06-16 16:56:11 UTC
(In reply to rhev-integ from comment #5)
> INFO: Bug status wasn't changed from MODIFIED to ON_QA due to the following
> reason:
> 
> [Tag 'ovirt-engine-4.1.3.4' doesn't contain patch
> 'https://gerrit.ovirt.org/77594']
> gitweb:
> https://gerrit.ovirt.org/gitweb?p=ovirt-engine.git;a=shortlog;h=refs/tags/
> ovirt-engine-4.1.3.4
> 
> For more info please contact: infra

Not true, https://gerrit.ovirt.org/77594 has been merged to ovirt-engine-4.1 on May 31st

Comment 7 Radim Hrazdil 2017-06-20 12:41:18 UTC
Verified that engine api offers <index> tag with the same value as attribute id.