Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1439970

Summary: [v4 API] Specifying name and vm.disk_attachments returns error 500
Product: Red Hat Enterprise Virtualization Manager Reporter: Germano Veit Michel <gveitmic>
Component: ovirt-engineAssignee: Tomas Jelinek <tjelinek>
Status: CLOSED ERRATA QA Contact: Israel Pinto <ipinto>
Severity: low Docs Contact:
Priority: medium    
Version: 4.0.7CC: apinnick, gveitmic, juan.hernandez, lsurette, michal.skrivanek, mmartinv, mwest, rbalakri, Rhev-m-bugs, srevivo, ykaul
Target Milestone: ovirt-4.2.0   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Previously, when creating a template from a virtual machine with the REST API, if the disk attachments were customized, the virtual machine could not be referenced by its name. In the current release, it is possible to create a template from a virtual machine referenced by its name and to customize the disk attachments in the same request.
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-05-15 17:41:54 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Virt RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Germano Veit Michel 2017-04-07 00:38:33 UTC
Description of problem:

While creating a template using the API, according to [1] and [2], I have to specify the VM element using it's NAME or it's ID. And it works fine.

However, if in the same template create request, I customize the VM disk_attachment, ID works but NAME returns error 500.

[1] https://github.com/oVirt/ovirt-engine-api-model/blob/master/src/main/java/services/TemplatesService.java#L44

[2] https://gerrit.ovirt.org/75272 (see BZ#1425295)

Examples: 

A: No disk customization, VM by name: OK
========================================
<template>
  <name>lala_template_070420171032</name>
  <vm>
    <name>test</name>
  </vm>
</template>
upload completely sent off
HTTP/1.1 202 Accepted

B: Disk customization, VM by id: OK
===================================
<template>
  <name>lala_template_070420171020</name>
  <vm id="064dec9d-733d-46a8-91f8-78e85c6b150e">
    <disk_attachments>
      <disk_attachment>
        <disk id="901ce7f1-e5c0-4b16-8d0d-ff976bdcb94b">
          <format>cow</format>
          <sparse>true</sparse>
        </disk>
      </disk_attachment>
    </disk_attachments>
  </vm>
</template>
upload completely sent off
HTTP/1.1 202 Accepted

C: Disk customization, VM by name: ERROR
========================================
<template>
  <name>lala_template_070420171031</name>
  <vm>
    <name>test</name>
    <disk_attachments>
      <disk_attachment>
        <disk id="901ce7f1-e5c0-4b16-8d0d-ff976bdcb94b">
          <format>cow</format>
          <sparse>true</sparse>
        </disk>
      </disk_attachment>
    </disk_attachments>
  </vm>
</template>
upload completely sent off
HTTP/1.1 500 Internal Server Error

I also get this on engine.log, spamming all the logs since the first call is made. Engine goes into a error logging frenzy, repeating it all the time. Tons of these non-stop:

2017-04-07 10:33:23,454 ERROR [org.ovirt.engine.api.restapi.util.LinkHelper] (default task-13) [] Can't find relative path for class "org.ovirt.engine.api.resource.TemplateDisksResource", will return null
2017-04-07 10:33:23,501 ERROR [org.ovirt.engine.api.restapi.util.LinkHelper] (default task-10) [] Can't find relative path for class "org.ovirt.engine.api.resource.TemplateDisksResource", will return null
2017-04-07 10:33:23,501 ERROR [org.ovirt.engine.api.restapi.util.LinkHelper] (default task-10) [] Can't find relative path for class "org.ovirt.engine.api.resource.TemplateDisksResource", will return null
2017-04-07 10:33:23,513 ERROR [org.ovirt.engine.api.restapi.util.LinkHelper] (default task-25) [] Can't find relative path for class "org.ovirt.engine.api.resource.TemplateDisksResource", will return null
2017-04-07 10:33:23,513 ERROR [org.ovirt.engine.api.restapi.util.LinkHelper] (default task-25) [] Can't find relative path for class "org.ovirt.engine.api.resource.TemplateDisksResource", will return null
2017-04-07 10:33:23,514 ERROR [org.ovirt.engine.api.restapi.util.LinkHelper] (default task-25) [] Can't find relative path for class "org.ovirt.engine.api.resource.TemplateDisksResource", will return null
2017-04-07 10:33:23,514 ERROR [org.ovirt.engine.api.restapi.util.LinkHelper] (default task-25) [] Can't find relative path for class "org.ovirt.engine.api.resource.TemplateDisksResource", will return null
2017-04-07 10:33:23,520 ERROR [org.ovirt.engine.api.restapi.util.LinkHelper] (default task-9) [] Can't find relative path for class "org.ovirt.engine.api.resource.TemplateDisksResource", will return null
2017-04-07 10:33:23,520 ERROR [org.ovirt.engine.api.restapi.util.LinkHelper] (default task-9) [] Can't find relative path for class "org.ovirt.engine.api.resource.TemplateDisksResource", will return null

Right after issuing the API call I already have 500 of those. See:
# grep "Can't find relative path for class \"org.ovirt.engine.api.resource.TemplateDisksResource\"" /var/log/ovirt-engine/engine.log | wc -l
504

Version-Release number of selected component (if applicable):
rhevm-4.0.7.4-0.1.el7ev.noarch

How reproducible:
100%

Comment 1 Germano Veit Michel 2017-04-07 00:53:38 UTC
Looks like it can't follow the vm link if it's by name?

  <vm id="064dec9d-733d-46a8-91f8-78e85c6b150e">
    <disk_attachments>

VS:

  <vm>
    <name>test</name>
    <disk_attachments>

Comment 2 Juan Hernández 2017-04-07 07:20:53 UTC
I am taking this to investigate it. May need to move to a different team later.

Comment 3 Juan Hernández 2017-04-07 13:20:47 UTC
I believe that the proposed patch fixes the issue:

  restapi: Fix adding customized template with VM name
  https://gerrit.ovirt.org/75336

Michal, I'd appreciate if your team can take it from here, and target/backport as required.

Comment 4 Juan Hernández 2017-04-07 13:24:23 UTC
Germano, the proposed patch fixes the main issue. But I wasn't able to reproduce those log messages that you mention. They are really warnings, not errors, but anyhow they shouldn't flood the log. I'd appreciate if you can re-test, once the main error is fixed, and report back if you see that log flooding.

Comment 6 Germano Veit Michel 2017-04-10 00:49:01 UTC
(In reply to Juan Hernández from comment #4)
> Germano, the proposed patch fixes the main issue. But I wasn't able to
> reproduce those log messages that you mention. They are really warnings, not
> errors, but anyhow they shouldn't flood the log. I'd appreciate if you can
> re-test, once the main error is fixed, and report back if you see that log
> flooding.

Hi Juan and Michal,

Thanks. Can we get it on the 4.1 branch? If so I can test it straightforward.

FYI, there is no customer hitting this at the moment and it's really easy to workaround (use ID), so not sure about real the need for a zstream.

Comment 7 rhev-integ 2017-11-02 13:39:32 UTC
INFO: Bug status wasn't changed from MODIFIED to ON_QA due to the following reason:

[No relevant external trackers attached]

For more info please contact: rhv-devops

Comment 9 Israel Pinto 2017-11-20 09:15:45 UTC
Verify with:
Software version:4.2.0-0.0.master.20171114111003.git7aa1b91.el7.centos

Steps:
Create template with VM name and custom disk id:
<template>
  <name>template_BZ</name>
  <vm>
    <name>golden_env_mixed_virtio_5</name>
    <disk_attachments>
      <disk_attachment>
        <disk id="b45d0d47-4234-4db9-80e0-769dae8cfb34">
          <format>cow</format>
          <sparse>true</sparse>
        </disk>
      </disk_attachment>
    </disk_attachments>
  </vm>
</template>

Template created

Comment 12 errata-xmlrpc 2018-05-15 17:41:54 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

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

https://access.redhat.com/errata/RHEA-2018:1488

Comment 13 Franta Kust 2019-05-16 13:06:17 UTC
BZ<2>Jira Resync