Bug 1428863 - Getting ticket for VM that is down fails with NPE
Summary: Getting ticket for VM that is down fails with NPE
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: ovirt-engine
Classification: oVirt
Component: RestAPI
Version: future
Hardware: Unspecified
OS: Unspecified
high
medium
Target Milestone: ovirt-4.1.2
: 4.1.2
Assignee: Martin Betak
QA Contact: Israel Pinto
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-03-03 14:23 UTC by Juan Hernández
Modified: 2017-05-23 08:15 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-05-23 08:15:13 UTC
oVirt Team: Virt
Embargoed:
rule-engine: ovirt-4.1+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
oVirt gerrit 73594 0 master MERGED restapi: Fix NPE when requesting ticket on a down VM 2017-03-10 10:37:33 UTC
oVirt gerrit 73880 0 ovirt-engine-4.1 MERGED restapi: Fix NPE when requesting ticket on a down VM 2017-03-12 08:42:07 UTC

Description Juan Hernández 2017-03-03 14:23:55 UTC
Getting a ticket for a virtual machine that is down fails with the following NPE:

Caused by: java.lang.NullPointerException
        at org.ovirt.engine.api.restapi.resource.BackendGraphicsConsoleHelper.asConsoleId(BackendGraphicsConsoleHelper.java:51) [restapi-jaxrs.jar:]
        at org.ovirt.engine.api.restapi.resource.BackendVmResource.ticket(BackendVmResource.java:486) [restapi-jaxrs.jar:]

To reproduce it send a request like this:

  POST /ovirt-engine/api/vms/{vm:id}/ticket
  <action/>

The actual result is 500 HTTP error code and the above NPE in server.log.

The expected result is either a ticket (which doesn't make sense when the VM is down) or a meaningful error message:

  HTTP/1.1 409 Conflict
  <fault>
    <reason>Operation failed</reason>
    <detail>[Can't get ticket because the virtual machine is down.]</detail>
  </fault>

Comment 1 Israel Pinto 2017-05-03 12:12:32 UTC
Verify with: 

Steps:
1. On VM in down status get ticket:
  POST /ovirt-engine/api/vms/{vm:id}/ticket
  <action/>
2. Check logs

Response:
<fault>
    <detail>[Cannot set Virtual Machine Ticket because the VM is in Down status.]</detail>
    <reason>Operation Failed</reason>
</fault>
Engine log:
2017-05-03 06:34:51,323+03 WARN  [org.ovirt.engine.core.bll.SetVmTicketCommand] (default task-2) [0fc00b5e-26d2-4eb8-84e1-5eaffdd44b37] Validation of action 'SetVmTicket' failed for user admin@internal-authz. Reasons: VAR__ACTION__SET,VAR__TYPE__VM_TICKET,ACTION_TYPE_FAILED_VM_STATUS_ILLEGAL,VAR__VM_STATUS__DOWN
2017-05-03 06:34:51,352+03 ERROR [org.ovirt.engine.api.restapi.resource.AbstractBackendResource] (default task-2) [] Operation Failed: [Cannot set Virtual Machine Ticket because the VM is in Down status.]

No NPE, PASS


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