Bug 1884975

Summary: [v2v][VMware to CNV VM import API] Storage Mapping: Using VMware storage name cause a crash
Product: Container Native Virtualization (CNV) Reporter: Ilanit Stein <istein>
Component: V2VAssignee: Sam Lucidi <slucidi>
Status: CLOSED ERRATA QA Contact: Md Nadeem <mnadeem>
Severity: high Docs Contact:
Priority: high    
Version: 2.5.0CC: cnv-qe-bugs, fdupont, mnadeem, ncredi, slucidi
Target Milestone: ---   
Target Release: 2.5.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: 2020-11-17 13:24:56 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:
Attachments:
Description Flags
vm import resource yaml
none
vm import controller log none

Description Ilanit Stein 2020-10-04 08:50:01 UTC
Description of problem:
VM import from VMware to RHV via api, using "name" for the source storage,
causes a crash:
VM import remain in 5%. VM import resource report validation completed.
VM import controller log report:
"panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1ebe93b]

goroutine 1394 [running]:
k8s.io/apimachinery/pkg/util/runtime.HandleCrash(0x0, 0x0, 0x0)" 

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

Additional info:
Source (VMware) storage name was used due to this doc bug:
Bug 1884970 - [v2v][Doc][VMware to CNV VM import API] Storage Mapping: Source storage name should change to storage id

Additional info - How it was tested:
Secret:
------
cat <<EOF | oc create -f -
---
apiVersion: v1
kind: Secret
metadata:
 name: vmw-secret
type: Opaque
stringData:
 vmware: |-
   # API URL of the vCenter or ESXi host
   apiUrl: "https://<Vcenter IP address>/sdk"
   # Username provided in the format of username@domain.
   username: <username>
   password: <password>
   # The certificate thumbprint of the vCenter or ESXi host, in colon-separated hexidecimal octets.
   thumbprint: 31:14:..
EOF

External mapping
----------------

cat <<EOF | oc create -f -
apiVersion: v2v.kubevirt.io/v1beta1
kind: ResourceMapping
metadata:
 name: example-vmware-resourcemappings
 namespace: default
spec:
  vmware:
    networkMappings:
    - source:
        name: VM Network # map network name to network attachment definition
      target: 
        name: pod
      type: pod
    storageMappings:
    - source:
        name: <VMware datastore name>   <======== Here use a name instead of ID
      target: 
        name: nfs
EOF

VM import create
----------------
cat <<EOF | oc create -f -
apiVersion: v2v.kubevirt.io/v1beta1
kind: VirtualMachineImport
metadata:
  name: vmware-import-1
  namespace: default
spec:
  providerCredentialsSecret:
    name: vmw-secret
    namespace: default # optional, if not specified, use CR's namespace
  resourceMapping:
    name: example-vmware-resourcemappings
    namespace: default
  targetVmName: vmw-import
  startVm: false
  source:
    vmware:
      vm:
        id: 42037aff-4d6f-cf89-7979-e98cbc406c0e
EOF

Comment 1 Ilanit Stein 2020-10-04 08:50:53 UTC
Created attachment 1718741 [details]
vm import resource yaml

Comment 2 Ilanit Stein 2020-10-04 08:51:32 UTC
Created attachment 1718742 [details]
vm import controller log

Comment 3 Sam Lucidi 2020-10-05 20:47:32 UTC
https://github.com/kubevirt/vm-import-operator/pull/410 fixes the doc bug and allows Datastores to be mapped by Name as well.

Comment 4 Md Nadeem 2020-10-23 16:09:14 UTC
verified on CNV version: 2.5.0-234

VM import works with both storage id or storage name

Comment 7 errata-xmlrpc 2020-11-17 13:24:56 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 (OpenShift Virtualization 2.5.0 Images), 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/RHEA-2020:5127