Bug 2122990

Summary: VMExport should check APIGroup
Product: Container Native Virtualization (CNV) Reporter: Jenia Peimer <jpeimer>
Component: StorageAssignee: Alexander Wels <awels>
Status: CLOSED ERRATA QA Contact: Jenia Peimer <jpeimer>
Severity: medium Docs Contact:
Priority: medium    
Version: 4.12.0CC: awels, mrashish, yadu
Target Milestone: ---   
Target Release: 4.12.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: CNV v4.12.0-548 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-01-24 13:40: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 Jenia Peimer 2022-08-31 13:42:56 UTC
Description of problem:
To create VMExport object we need to specify the APIGroup of exported object

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

How reproducible:
Always

Steps to Reproduce:
1. Create a VM
2. Create a VMSnapshot
3. Create a VMExport for VMSnapshot without specifying the APIGroup

$ cat vmexport-snapshot.yaml 
apiVersion: export.kubevirt.io/v1alpha1
kind: VirtualMachineExport
metadata:
    name: export-vmsnapshot
spec:
    source:
        kind: VirtualMachineSnapshot
        name: my-vmsnapshot
    tokenSecretRef: virt-export-token

Actual results:
The VMExport was created, but it is not Ready and doesn't show any error

$ oc get virtualmachineexport
NAME                SOURCEKIND               SOURCENAME      PHASE
export-vmsnapshot   VirtualMachineSnapshot   my-vmsnapshot 

Expected results:
VMExport will fail to create saying APIGroup needs to be specified

Comment 1 Jenia Peimer 2022-11-03 12:26:47 UTC
Verified on CNV-v4.12.0-665

Create a VM and VMSnapshot,

Create a token:

$ cat token.yaml 
apiVersion: v1
kind: Secret
metadata:
    name: virt-export-token
data:
    token: bXl0b2tlbg==

$ oc create -f token.yaml 
secret/virt-export-token created


Create VMExport with no API Group:

$ cat export-wrong-api-group.yaml 
apiVersion: export.kubevirt.io/v1alpha1
kind: VirtualMachineExport
metadata:
    name: export-vmsnapshot
spec:
    source:
        kind: VirtualMachineSnapshot
        name: my-vmsnapshot
    tokenSecretRef: virt-export-token

$ oc create -f export-wrong-api-group.yaml 
The request is invalid: spec.source.APIGroup: VMSnapshot API group must be snapshot.kubevirt.io


Create VMExport with the wrong API Group:

$ cat export-wrong-api-group.yaml
apiVersion: export.kubevirt.io/v1alpha1
kind: VirtualMachineExport
metadata:
    name: export-vmsnapshot
spec:
    source:
        apiGroup: "snapshot.kubevirt.io-hohoho"
        kind: VirtualMachineSnapshot
        name: my-vmsnapshot
    tokenSecretRef: virt-export-token

$ oc create -f export-wrong-api-group.yaml 
The request is invalid: spec.source.APIGroup: VMSnapshot API group must be snapshot.kubevirt.io

Comment 5 errata-xmlrpc 2023-01-24 13:40:29 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 (Important: OpenShift Virtualization 4.12.0 Images security 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-2023:0408