Bug 2248091

Summary: Creating virtual machine may incorrectly use already existing PVC in the namespace
Product: Container Native Virtualization (CNV) Reporter: nijin ashok <nashok>
Component: User ExperienceAssignee: Tal Nisan <tnisan>
Status: CLOSED MIGRATED QA Contact: Guohua Ouyang <gouyang>
Severity: high Docs Contact:
Priority: unspecified    
Version: 4.13.5CC: gouyang
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-11-08 02:27:29 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 nijin ashok 2023-11-06 05:16:00 UTC
Description of problem:

The namespace was already having a PVC named mytestvm:

~~~
# oc get pvc mytestvm
NAME       STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS                           AGE
mytestvm   Bound    pvc-9049ae50-3cfc-4b4a-9504-e65eb5dca2e1   10Gi       RWO            ocs-external-storagecluster-ceph-rbd   13m
~~~

Then created a new VM "mytestvm" from the OpenShift Console (Virtual machines => Create => From template => select a template => Quick create virtual machine). The VM was created with the above PVC:

~~~
oc get pod virt-launcher-mytestvm-slzxl -o json |jq '.spec.volumes[7]'
{
  "name": "rootdisk",
  "persistentVolumeClaim": {
    "claimName": "mytestvm"
  }
}
~~~

By default, the generated PVC name is the same as the VM name. However, there is no validation that the PVC already exists and is being used. 


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

OpenShift Virtualization   4.13.5

How reproducible:

100%

Steps to Reproduce:

1. Create a PVC.
2. Create a VM with the same name as of above PVC.
3. The PVC in [1] was attached to the new VM as rootdisk.

Actual results:

Creating a virtual machine may incorrectly use already existing PVC in the namespace

Expected results:

I think it should generate a new name for the PVC if there is already an existing PVC with the same name.

Additional info: