Bug 1853924
Summary: | Fails to import template as OVA from the given configuration if the VM is not removed | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | [oVirt] ovirt-engine | Reporter: | Polina <pagranat> | ||||||
Component: | BLL.Virt | Assignee: | Shmuel Melamud <smelamud> | ||||||
Status: | CLOSED CURRENTRELEASE | QA Contact: | Polina <pagranat> | ||||||
Severity: | medium | Docs Contact: | |||||||
Priority: | unspecified | ||||||||
Version: | 4.4.1 | CC: | ahadas, bugs, dfodor, emarcus, michal.skrivanek, mzamazal, smelamud | ||||||
Target Milestone: | ovirt-4.5.2 | Keywords: | ZStream | ||||||
Target Release: | 4.5.2 | Flags: | sbonazzo:
ovirt-4.5+
|
||||||
Hardware: | x86_64 | ||||||||
OS: | Linux | ||||||||
Whiteboard: | |||||||||
Fixed In Version: | ovirt-engine-4.5.2 | Doc Type: | Bug Fix | ||||||
Doc Text: |
Previously, when attempting to add a disk using ovirt-engine SDK script when the disk already exists, the operation fails, and an exception is thrown.
With this release, the Add Disk Functionality checks for duplicate disks, and fails gracefully with a readable error message when the disk to be inserted already exists.
|
Story Points: | --- | ||||||
Clone Of: | Environment: | ||||||||
Last Closed: | 2022-08-30 08:47:42 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: | |||||||||
Bug Depends On: | 1848586 | ||||||||
Bug Blocks: | |||||||||
Attachments: |
|
relevant for 4.3 and 4.4 As per our discussions concerning BZ 1848586, we are reusing the disk identifiers from the ovf file to insert the disks which means we are not supporting this feature where the disks with the same identifiers already exist. Unless we want to support cloning for this request we may consider closing this issue. Well, we should avoid the exception. We need to return a proper validation error in this case. still happens in ovirt-engine-4.4.7.4-0.9.el8ev.noarch Although one validation is fixed already in this bug (disks existing), the problem here is that we import a VM as a template. The imported template uses the same ID as the VM, which cause the vm_static key violation. The validation we use is: VmTemplate duplicateTemplate = vmTemplateDao.get(getParameters().getVmTemplate().getId()); // check that the template does not exists in the target domain if (duplicateTemplate != null) { return failValidation(EngineMessage.VMT_CANNOT_IMPORT_TEMPLATE_EXISTS, String.format("$TemplateName %1$s", duplicateTemplate.getName())); } It won't find a thing, since the source is a VM. But if we will search the ID in vmStaticDao for example, we will see it's already there. We should validate it as well. Since both templates and vms can be found in vm_static, it should be enough to check for duplicate in this table. Liran posted https://gerrit.ovirt.org/115362 but it seems like we'd need another part to solve this bz so moving back to ASSIGNED Created attachment 1898029 [details]
Modified upload_ova_as_template.py script
1. When a template is imported from an OVA, all disks should be uploaded at the beginning and IDs of the disks should be referenced in the OVF.
2. Import with preloaded disks uses the template ID from the OVF, so a new template ID should be generated.
After these two modifications (see the script attached), the import finishes successfully. No changes in the Engine required.
Polina, Arik, do you consider such behaviour of REST API as correct? (In reply to Shmuel Melamud from comment #9) > Polina, Arik, do you consider such behaviour of REST API as correct? yes, for the import-as-clone flow for ordinary import flow, we need to keep the id since there might be VMs that are imported later on which are based on that template (In reply to Arik from comment #10) > (In reply to Shmuel Melamud from comment #9) > > Polina, Arik, do you consider such behaviour of REST API as correct? > > yes, for the import-as-clone flow > for ordinary import flow, we need to keep the id since there might be VMs > that are imported later on which are based on that template agree :) If so, I consider this bz as solved. (In reply to Shmuel Melamud from comment #12) > If so, I consider this bz as solved. Shmuel, which patch addresses the last part of comment 5? (In reply to Arik from comment #13) > Shmuel, which patch addresses the last part of comment 5? You mean checking the existence of the same ID so the command will fail in validation instead of DB error? You're right, let me fix that. The last patch has been merged and it looks like everything is resolved now, so moving to MODIFIED. verified on ovirt-engine-4.5.2-0.3.el8ev.noarch by running automation test rhevmtests.compute.virt.external_providers.ova.test_ova_sanity.TestUploadOVAasTemplate (commenting out the VM removing part assert helper.remove_vm_sampler(self.vm_name), f"Failed to remove VM {self.vm_name} before uploading") This bugzilla is included in oVirt 4.5.2 release, published on August 10th 2022. Since the problem described in this bug report should be resolved in oVirt 4.5.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. |
Created attachment 1699950 [details] engine log and upload_ova_as_template.py script Description of problem:Operation Failed: [Internal Engine Error] when trying to import template as OVA with script Version-Release number of selected component (if applicable): ovirt-engine-4.4.1.2-0.10.el8ev.noarch How reproducible:always Steps to Reproduce: 1. Create a VM 2. Export VM as OVA 3. Don't remove the VM and try to import as OVA using the attached script, like python3 upload_ova_as_template.py pa6.ova golden_env_mixed_1 nfs_0 Actual results: 2020-07-05 19:14:22,965+03 INFO [org.ovirt.engine.core.utils.transaction.TransactionSupport] (default task-15) [4e9ef671-17ab-439b-9c3b-2a6acd0514b5] transaction rolled back 2020-07-05 19:14:22,966+03 ERROR [org.ovirt.engine.core.bll.exportimport.ImportVmTemplateFromConfigurationCommand] (default task-15) [4e9ef671-17ab-439b-9c3b-2a6acd0514b5] Command 'org.ovirt.engine.core.bll.exportimport.ImportVmTemplateFromConfigurationCommand' failed: CallableStatementCallback; SQL [{call insertvmtemplate(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)}ERROR: duplicate key value violates unique constraint "pk_vm_static" ... 2020-07-05 19:14:22,971+03 ERROR [org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector] (default task-15) [4e9ef671-17ab-439b-9c3b-2a6acd0514b5] EVENT_ID: TEMPLATE_IMPORT_FROM_CONFIGURATION_FAILED(181), Failed to import Template pa5 from the given configuration. 2020-07-05 19:14:22,976+03 ERROR [org.ovirt.engine.api.restapi.resource.AbstractBackendResource] (default task-15) [] Operation Failed: [Internal Engine Error] Expected results: Additional info: