Bug 1444016

Summary: Bad check of return code
Product: [oVirt] ovirt-engine-sdk-python Reporter: Fabrice Bacchella <fabrice.bacchella>
Component: GeneralAssignee: Ondra Machacek <omachace>
Status: CLOSED CURRENTRELEASE QA Contact: Petr Matyáš <pmatyas>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.1.3CC: bugs, juan.hernandez, lsvaty, mperina, stirabos
Target Milestone: ovirt-4.1.3Flags: rule-engine: ovirt-4.1+
lsvaty: testing_ack+
Target Release: 4.1.4   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: python-ovirt-engine-sdk4-4.1.4 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-07-06 14:04:54 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-04-20 12:39:50 UTC
I'm running the python sdk 4.1.3 again a ovirt instance release 4.0.4.4-1.el7.centos.

I tried to run the sample code https://github.com/oVirt/ovirt-engine-sdk/blob/master/sdk/examples/get_display_ticket.py but it fails with the message :

    Entity: line 1: parser error : Extra content at the end of the document
    ^

And looking in the example.log, I got :
DEBUG:root:POST /ovirt-engine/api/vms/61a6de0a-2a21-4e90-bc20-29e3f0cd0ad8/graphicsconsoles/7370696365/ticket HTTP/1.1
....
DEBUG:root:HTTP/1.1 404 Not Found


I think i was hit by https://bugzilla.redhat.com/show_bug.cgi?id=1383342. So the failure is not a problem. But I got a meaningless error message. The code got a 404, so why didn't it say so, and instead throws me a message about something else ?

Comment 1 Juan Hernández 2017-04-20 15:24:01 UTC
The meaningless error message is a side effect of the combination of bug 1383342 and bug 1440292. In that situation the server returns an HTML error message and we don't check the returned content type, hence we try to parse the HTML as XML, and that is the error that generates.

In a normal situation the SDK returns a more reasonable error message, for example, if you do this:

  vm_service = vms_service.vm_service('doesnotexist')
  vm_service.get()

You get this exception:

  Traceback (most recent call last):
    File "...py", line 41, in <module>
      vm_service.get()
    File ".../ovirtsdk4/services.py", line 29565, in get
      self._check_fault(response)
    File ".../ovirtsdk4/service.py", line 98, in _check_fault
      Service._raise_error(response, fault)
    File ".../ovirtsdk4/service.py", line 71, in _raise_error
      raise Error(msg)
  ovirtsdk4.Error: HTTP response code is 404.

Consider closing this as a duplicate of bug 1440292. Note also that the fix for that bug, isn't complete yet, see the details. I am moving it back to ASSIGNED.

Comment 2 Ondra Machacek 2017-04-20 15:46:32 UTC
It's version 4.1.3, so there shouldn't be any content-type checking yet, but the issue is that we miss the checking of response code in action methods. Anyway, I will send a fix for both.

Comment 3 Petr Matyáš 2017-06-02 13:27:17 UTC
Verified on 4.1.3-2