Bug 2224663

Summary: The VM clone cannot be used as a source for other clonings
Product: Container Native Virtualization (CNV) Reporter: Denys Shchedrivyi <dshchedr>
Component: VirtualizationAssignee: sgott
Status: NEW --- QA Contact: Kedar Bidarkar <kbidarka>
Severity: high Docs Contact:
Priority: high    
Version: 4.14.0   
Target Milestone: ---   
Target Release: 4.15.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: 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 Denys Shchedrivyi 2023-07-21 21:19:13 UTC
Description of problem:
 
 VM Cloning stuck in RestoreInProgress phase when using recently created VM clone as the source:

> $ oc get vmclone
> NAME               PHASE               SOURCEVIRTUALMACHINE   TARGETVIRTUALMACHINE
> testclone          Succeeded           vm-fedora              vm-fedora-clone
> testclone-cloned   RestoreInProgress   vm-fedora-clone        vm-fedora-clone2


 There is an error in vmrestore events:
> $  oc describe vmrestore
> .
> Events:
>   Type     Reason                      Age                 From                Message
>  Warning  VirtualMachineRestoreError  49s                 restore-controller  VirtualMachineRestore encountered error Operation cannot be fulfilled on virtualmachines.kubevirt.io "vm-fedora-clone2": the object has been modified; please apply your changes to the latest version and try again
>  Warning  VirtualMachineRestoreError  45s (x24 over 51s)  restore-controller  VirtualMachineRestore encountered error error patching VM vm-fedora-clone2: failed to apply patch for VM [
> {"op": "replace", "path": "/spec/template/spec/domain/devices/interfaces/0/macAddress", "value": ""},
> {"op": "replace", "path": "/spec/template/spec/domain/firmware/serial", "value": "new-serial-new"},
> {"op": "remove", "path": "/metadata/annotations/kubevirt.io~1latest-observed-api-version"},
> {"op": "remove", "path": "/metadata/annotations/kubevirt.io~1storage-observed-api-version"},
> {"op": "remove", "path": "/metadata/annotations/restore.kubevirt.io~1lastRestoreUID"},
> {"op": "replace", "path": "/spec/template/spec/domain/firmware/uuid", "value": ""}
> ]: error in remove for path: '/metadata/annotations/kubevirt.io~1latest-observed-api-version': Unable to remove nonexistent key: kubevirt.io/latest-observed-api-version: missing value




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


How reproducible:


Steps to Reproduce:
1. create VM
2. Clone VM
3. Clone again using the VM clone as a source

Actual results:
 VM cloning failed

Expected results:
 VM successfully cloned

Additional info:

Comment 1 Denys Shchedrivyi 2023-07-21 22:15:12 UTC
Wanted to add - see this issue only when used `annotationFilters` field in the VirtualMachineClone, e.g.:

apiVersion: clone.kubevirt.io/v1alpha1
kind: VirtualMachineClone
metadata:
  name: testclone-cloned
spec:
  source:
    apiGroup: kubevirt.io
    kind: VirtualMachine
    name: vm-fedora-clone
  target:
    apiGroup: kubevirt.io
    kind: VirtualMachine
    name: vm-fedora-clone2
  annotationFilters:
    - "somekey/*"



 Without `annotationFilters` VM succesfully cloned.