Bug 1448511 - event.id type is inconsistent
Summary: event.id type is inconsistent
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: ovirt-engine
Classification: oVirt
Component: RestAPI
Version: ---
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ovirt-4.1.3
: 4.1.3.3
Assignee: Juan Hernández
QA Contact: Radim Hrazdil
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-05-05 15:44 UTC by Fabrice Bacchella
Modified: 2017-09-27 13:21 UTC (History)
6 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2017-07-06 13:25:15 UTC
oVirt Team: Infra
Embargoed:
rule-engine: ovirt-4.1+
lsvaty: testing_ack+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
oVirt gerrit 76802 0 master MERGED Introduce Event.index 2017-05-28 18:04:01 UTC
oVirt gerrit 77457 0 model_4.1 MERGED Introduce Event.index 2017-05-28 18:06:34 UTC
oVirt gerrit 77592 0 master MERGED restapi: Update to model 4.2.12 2017-06-01 07:24:35 UTC
oVirt gerrit 77594 0 ovirt-engine-4.1 MERGED restapi: Update to model 4.1.37 2017-06-01 08:29:23 UTC
oVirt gerrit 79475 0 sdk_4.1 MERGED Update to model 4.1.37 and metamodel 1.1.14 2017-07-17 11:56:26 UTC
oVirt gerrit 82162 0 master MERGED Update to model 4.2.19 2017-09-25 11:42:23 UTC
oVirt gerrit 82184 0 master MERGED Update to model 4.2.19 2017-09-25 13:45:09 UTC
oVirt gerrit 82303 0 master MERGED Update to model 4.2.19 2017-09-27 13:28:50 UTC

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.


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