Bug 1488729 - Failed to create affinity group via REST API
Summary: Failed to create affinity group via REST API
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: ovirt-engine
Classification: oVirt
Component: RestAPI
Version: 4.2.0
Hardware: x86_64
OS: Linux
unspecified
high
Target Milestone: ovirt-4.2.0
: ---
Assignee: Juan Hernández
QA Contact: Petr Matyáš
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-09-06 06:40 UTC by Artyom
Modified: 2017-12-20 10:45 UTC (History)
3 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2017-12-20 10:45:19 UTC
oVirt Team: SLA
Embargoed:
rule-engine: ovirt-4.2+
rule-engine: blocker+


Attachments (Terms of Use)
server log (1.72 MB, text/plain)
2017-09-06 06:40 UTC, Artyom
no flags Details


Links
System ID Private Priority Status Summary Last Updated
oVirt gerrit 81489 0 master POST Don't require deprecated affinity group attributes 2017-09-06 07:54:16 UTC
oVirt gerrit 81501 0 model_4.1 POST Don't require deprecated affinity group attributes 2017-09-06 09:00:59 UTC
oVirt gerrit 81507 0 master POST restapi: Update to model 4.2.17 2017-09-06 10:03:39 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 Artyom 2017-09-06 06:40:37 UTC
Created attachment 1322497 [details]
server log

Description of problem:
Failed to create affinity host to VM group

Version-Release number of selected component (if applicable):
ovirt-engine-4.2.0-0.0.master.20170904111624.git842d79b.el7.centos.noarch

How reproducible:
Always

Steps to Reproduce:
1. Try to create host to VM affinity group via REST API
<affinity_group>
    <name>affinity_enforcement_01</name>
    <hosts_rule>
        <enforcing>true</enforcing>
        <positive>true</positive>
    </hosts_rule>
    <vms_rule>
        <enabled>false</enabled>
    </vms_rule>
    <hosts>
        <host id="091db1f9-7c7a-408d-9abe-3f549b4da5b9"/>
    </hosts>
    <vms>
        <vm id="06fefa09-a213-410c-ae12-149b0de90f42"/>
    </vms>
</affinity_group>
2.
3.

Actual results:
Internal Server Error
2017-09-06 09:35:21,835+03 ERROR [io.undertow.request] (default task-36) UT005023: Exception handling request to /ovirt-engine/api/v4/clusters/753d7ede-61f6-4fc3-9d8d-263d01374745/affinitygroups: java.lang.RuntimeException: org.jboss.resteasy.spi.UnhandledException: org.ovirt.api.metamodel.server.ValidationException: Parameter 'group.enforcing' is mandatory but was not provided.
        at io.undertow.servlet.spec.RequestDispatcherImpl.forwardImpl(RequestDispatcherImpl.java:245) [undertow-servlet-1.4.18.Final.jar:1.4.18.Final]
        at io.undertow.servlet.spec.RequestDispatcherImpl.forwardImplSetup(RequestDispatcherImpl.java:147) [undertow-servlet-1.4.18.Final.jar:1.4.18.Final]
        at io.undertow.servlet.spec.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:111) [undertow-servlet-1.4.18.Final.jar:1.4.18.Final]
        at org.ovirt.engine.api.restapi.invocation.VersionFilter.doFilter(VersionFilter.java:180) [restapi-jaxrs.jar:]
        at org.ovirt.engine.api.restapi.invocation.VersionFilter.doFilter(VersionFilter.java:98) [restapi-jaxrs.jar:]
        at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) [undertow-servlet-1.4.18.Final.jar:1.4.18.Final]

Expected results:
Affinity group creation succeeds

Additional info:
Via UI all works fine

Comment 1 Juan Hernández 2017-09-06 07:58:19 UTC
The reason for this is that the 'enforcing' and 'positive' attributes where deprecated in version 4.1 of the engine, but we didn't update the specification of the API correctly, so they are still marked as mandatory. In addition now the API server is more strict, and enforces the restrictions declared in the specification of the API, so it rejects the request.

This will need to be fixed in the specification of the API, with the suggested patch, then the engine will need to be updated to use the fixed version of the specification.

Comment 2 Red Hat Bugzilla Rules Engine 2017-09-06 07:59:03 UTC
This bug report has Keywords: Regression or TestBlocker.
Since no regressions or test blockers are allowed between releases, it is also being identified as a blocker for this release. Please resolve ASAP.

Comment 3 Petr Matyáš 2017-09-12 11:42:58 UTC
[root@pm-rh40 ~]# curl -v -u "admin@internal:$pass" -H "Content-type: application/xml" --insecure -X POST https://$engine/ovirt-engine/api/clusters/$cluster_id/affinitygroups -d "<affinity_group><name>affinity_enforcement_01</name><hosts_rule><enforcing>true</enforcing><positive>true</positive></hosts_rule><vms_rule><enabled>false</enabled></vms_rule><hosts><host id="7c14d704-66b0-462b-8e6d-5619736e6ce6"/></hosts><vms><vm id="54fff86b-f4b2-4a6d-acf9-70d7f17977f0"/></vms></affinity_group>"

^ this results in 400 Request syntactically incorrect and in engine log is:
Message: Open quote is expected for attribute "id" associated with an  element type  "host".
Although I can clearly see that id attribute has all the necessary quotes

Comment 5 Petr Matyáš 2017-09-12 12:34:26 UTC
Sorry, I forgot to mention I'm using ovirt-engine-4.2.0-0.0.master.20170911195522.git5ddba50.el7.centos.noarch

Comment 6 Juan Hernández 2017-09-12 12:39:54 UTC
In order to send that request using curl and the command line you need to use shell quoting carefully. Currently you are putting all the XML document between double quotes, and then there are double quotes inside the XML document itself. Try to use single quotes for the XML document:

  -d '<affinity_group>...</affinity_group>'

Or else use the back slash to escape the double quotes inside the XML document:

  -d "<affinity_group>...id=\"..."

Comment 7 Petr Matyáš 2017-09-12 13:29:00 UTC
You are right, my quotes were wrong, this request works correctly.

Comment 8 Sandro Bonazzola 2017-12-20 10:45:19 UTC
This bugzilla is included in oVirt 4.2.0 release, published on Dec 20th 2017.

Since the problem described in this bug report should be
resolved in oVirt 4.2.0 release, published on Dec 20th 2017, it has been closed with a resolution of CURRENT RELEASE.

If the solution does not work for you, please open a new bug report.


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