Bug 1540071

Summary: An attempt to get the snapshot creation status with JSON request results in 406 response code from server.
Product: [oVirt] ovirt-engine Reporter: Anton Erdman <tentaclius>
Component: RestAPIAssignee: Ondra Machacek <omachace>
Status: CLOSED CURRENTRELEASE QA Contact: Radim Hrazdil <rhrazdil>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.1.5.2CC: bugs, lsvaty, lveyde, mperina
Target Milestone: ovirt-4.2.2Flags: rule-engine: ovirt-4.2+
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: ovirt-engine-4.2.2 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-03-29 11:10:03 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:

Comment 1 Ondra Machacek 2018-01-30 09:04:29 UTC
Description of problem:
When trying to obtain a VM snapshot creation status via REST API, the server responds with code 406 Not Acceptable.
This only happens when the request contains "Accept: application/json" header. 
If Accept is set to application/xml, the server response is correct, but with XML body.

Version-Release number of selected component (if applicable):
4.1.5.2

How reproducible:
Always.

Steps to Reproduce:
1. Request a snapshot creation with POST request to /ovirt-engine/api/<VM_UID>/snapshots
2. Get the status confirmation link from JSON body of the response.
3. Try to get the status response in JSON using the link, e.g. with curl:
   curl \                                                                                                                                                                                      
      --verbose \                                                                                                                                                                              
      --request GET \                                                                                                                                                                          
      --user "admin@internal:<password>" \                                                                                                                                                       
      --header "Accept: application/json" \                                                                                                                                                    
      https://<engine-hostname>/ovirt-engine/api/vms/d4e6000b-bff6-4af3-b876-5b6d7fd39ed1/snapshots/b917bbff-dcca-4fe3-9866-878972c3da26/creation_status/439ee213-2529-4a0d-aabb-958ed5a27eb5  

Actual results:
* Connected to <hostname> (172.20.7.107) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: ./ca.pem
  CApath: none
* SSL connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
* Server certificate:
*       subject: CN=ovirtengine.iba,O=iba,C=US
*       start date: Sep 07 16:36:28 2017 GMT
*       expire date: Aug 13 16:36:28 2022 GMT
*       common name: ovirtengine.iba
*       issuer: CN=ovirtengine.iba.86763,O=iba,C=US
* Server auth using Basic with user 'admin@internal'
> GET /ovirt-engine/api/vms/d4e6000b-bff6-4af3-b876-5b6d7fd39ed1/snapshots/b917bbff-dcca-4fe3-9866-878972c3da26/creation_status/439ee213-2529-4a0d-aabb-958ed5a27eb5 HTTP/1.1
> Authorization: Basic XXXX
> User-Agent: curl/7.29.0
> Host: ovirtengine.iba
> Accept: application/json
> 
< HTTP/1.1 406 Not Acceptable
< Date: Tue, 30 Jan 2018 08:31:59 GMT
< Server: Apache/2.4.27 (Fedora) OpenSSL/1.0.2k-fips
< Content-Length: 0
< Correlation-Id: 621c61b3-69f8-48ab-9f58-9f66096e2f75
< 
* Connection #0 to host ovirtengine.iba left intact

Expected results:
Correct response, like in case with Accept: application/xml:
< HTTP/1.1 200 OK
< Date: Tue, 30 Jan 2018 08:33:36 GMT
< Server: Apache/2.4.27 (Fedora) OpenSSL/1.0.2k-fips
< Content-Type: application/xml
< Content-Length: 317
< Correlation-Id: 4b73b4a5-76a3-4f22-861e-625135384986
< Vary: Accept-Encoding
< 
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<creation href="/ovirt-engine/api/vms/d4e6000b-bff6-4af3-b876-5b6d7fd39ed1/snapshots/b917bbff-dcca-4fe3-9866-878972c3da26/creation_status/439ee213-2529-4a0d-aabb-958ed5a27eb5" id="439ee213-2529-4a0d-aabb-958ed5a27eb5">
    <status>complete</status>
</creation>
* Connection #0 to host ovirtengine.iba left intact

Additional info:
I didn't find any lines in oVirt logs that could be related to the problem, but can provide them if necessary.

Comment 2 Radim Hrazdil 2018-02-26 13:41:34 UTC
Verified by following the steps in the description, that quering the creation_status in json returns:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<creation href="/ovirt-engine/api/vms/123/snapshots/456/creation_status/789" id="789">
    <status>complete</status>
</creation>

RHV version 4.2.2.

Comment 3 Sandro Bonazzola 2018-03-29 11:10:03 UTC
This bugzilla is included in oVirt 4.2.2 release, published on March 28th 2018.

Since the problem described in this bug report should be
resolved in oVirt 4.2.2 release, it has been closed with a resolution of CURRENT RELEASE.

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