Bug 1894824

Summary: [v2v][VM import] Pick the smallest template for the imported VM, and not always Medium
Product: Container Native Virtualization (CNV) Reporter: Ilanit Stein <istein>
Component: V2VAssignee: Sam Lucidi <slucidi>
Status: CLOSED ERRATA QA Contact: Amos Mastbaum <amastbau>
Severity: medium Docs Contact:
Priority: medium    
Version: 2.5.0CC: amastbau, cnv-qe-bugs, fdupont, slucidi, stirabos
Target Milestone: ---   
Target Release: 2.6.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-03-10 11:18:59 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Ilanit Stein 2020-11-05 07:52:22 UTC
Description of problem:
Currently VM import from RHv/VMware using VM import operator are both picking Medium common template for the created VM.
Please change it so that the smallest common template will be picked. 

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

Comment 1 Fabien Dupont 2020-11-05 09:21:18 UTC
The idea is not to pick the smallest common template, but the smallest template for the given OS / Machine type.
The reason is that we always override the CPU and memory of the template, so if the source VM is smaller than the Medium template, it will fail validation, even though a template with less resources exists.

Comment 3 Ilanit Stein 2021-02-02 08:54:41 UTC
@Sam, 

1. For VM import from RHV, it seems medium template is still statically picked.
Is this fix planned to include RHV too, or just VMware?
(For VMware, indeed a SMALL template is picked in case memory is 1G or less, and not MEDIUM template).

2. For both VMware & RHV,
the validation failure on minimum required memory enforced by the template no longer appear,
and VM is imported successfully, and stars OK, regardless to it's memory size being lower than the required memory.
For example, a RHV VM RHEL7.7 with memory 500MB has rhel7-server-medium template picked, that has min 1GB required: 
$ oc get template rhel7-server-medium -n openshift -oyaml
...
vm.kubevirt.io/validations: |
        [
          {
            "name": "minimal-required-memory",
            "path": "jsonpath::.spec.domain.resources.requests.memory",
            "rule": "integer",
            "message": "This VM requires more memory.",
            "min": 1073741824
          }
        ]
...

Is this a regression bug?

Comment 4 Ilanit Stein 2021-02-04 16:41:40 UTC
*** Bug 1922295 has been marked as a duplicate of this bug. ***

Comment 5 Sam Lucidi 2021-02-04 22:24:26 UTC
1. I was under the impression that this fix was only necessary for VMware, so the patch only impacts the VMware provider. I see that the initial comment includes RHV/oVirt, so that's my mistake.

2. VMware has never had a validation on the template's minimum required memory. It's my understanding that the validation was added to the oVirt provider to catch a VM that would be rejected by kubevirt. So yes, it technically appears to be a regression in the oVirt provider that the validation isn't occurring, but if the VM was able to boot successfully then it wasn't rejected by kubevirt. This means that the problem the validation is intended to catch isn't occurring either for some reason. In any case that would be a topic for a new BZ.

Comment 8 errata-xmlrpc 2021-03-10 11:18:59 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 (Moderate: OpenShift Virtualization 2.6.0 security and bug fix update), 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/RHSA-2021:0799