kubevirt / kubevirt-ansible

Set of Ansible roles & playbooks for KubeVirt deployment
Apache License 2.0
91 stars 72 forks source link

Failed to import VM from URL #312

Closed qwang1 closed 6 years ago

qwang1 commented 6 years ago

Hi there,

I failed to use import-vm-apb to import a vm or template via URL. I used this as disk image: http://download.eng.bos.redhat.com/brewroot/packages/rhel-guest-image/7.6/70/images/rhel-guest-image-7.6-70.x86_64.qcow2 . Anything I did wrong? Besides, I'd like to know why the command "oc logs" shows it sticks when "Get content metadata", but run ansible-playbook in the sandbox shows it sticks when "Change project". Thanks.

Version: openshift v3.10.8 kubevirt v0.7.0-alpha.5 asb 1.2.17

[root@cnv-executor-qwang0702-master1 ~]# oc get all -n dh-import-vm-apb-prov-t8vtt
NAME                                           READY     STATUS    RESTARTS   AGE
pod/apb-45c07bf1-c8bf-49df-84ed-d1f7f579ec4a   1/1       Running   0          41s

[root@cnv-executor-qwang0702-master1 ~]# oc logs pod/apb-45c07bf1-c8bf-49df-84ed-d1f7f579ec4a -n dh-import-vm-apb-prov-t8vtt
 [WARNING]: provided hosts list is empty, only localhost is available. Note
that the implicit localhost does not match 'all'
 [WARNING]: Found variable using reserved name: action

PLAY [Playbook to import the virtual machine disk] *****************************

TASK [ansible.kubernetes-modules : Install latest openshift client] ************
skipping: [localhost]

TASK [ansibleplaybookbundle.asb-modules : debug] *******************************
skipping: [localhost]

TASK [import-from-url : include] ***********************************************
included: /opt/ansible/roles/import-from-url/tasks/provision.yml for localhost

TASK [import-from-url : Change project to qwang-import-vm-7] *******************
changed: [localhost]

TASK [import-from-url : Target is VM?] *****************************************
skipping: [localhost]

TASK [import-from-url : Target is Template?] ***********************************
ok: [localhost]

TASK [import-from-url : Login As Super User] ***********************************
changed: [localhost]

TASK [import-from-url : Check for existing PVC] ********************************
changed: [localhost]

TASK [import-from-url : Get content metadata] **********************************

[root@cnv-executor-qwang0702-master1 ~]# oc project dh-import-vm-apb-prov-t8vtt
Now using project "dh-import-vm-apb-prov-t8vtt" on server "https://cnv-executor-qwang0702-master1:8443".

[root@cnv-executor-qwang0702-master1 ~]# oc rsh pod/apb-45c07bf1-c8bf-49df-84ed-d1f7f579ec4a
sh-4.2$ ansible-playbook actions/provision.yml -vvvv
ansible-playbook 2.5.5
  config file = /opt/apb/ansible.cfg
  configured module search path = [u'/opt/apb/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 2.7.5 (default, Aug  4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
Using /opt/apb/ansible.cfg as config file
setting up inventory plugins
Set default localhost to localhost
Parsed /opt/apb/hosts inventory source with ini plugin
Loading callback plugin default of type stdout, v2.0 from /usr/lib/python2.7/site-packages/ansible/plugins/callback/default.pyc

PLAYBOOK: provision.yml **********************************************************************************************************************************************************
1 plays in actions/provision.yml
 [WARNING]: Found variable using reserved name: action

PLAY [Playbook to import the virtual machine disk] *******************************************************************************************************************************
META: ran handlers

TASK [ansible.kubernetes-modules : Install latest openshift client] **************************************************************************************************************
task path: /etc/ansible/roles/ansible.kubernetes-modules/tasks/main.yml:4
skipping: [localhost] => {
    "changed": false,
    "skip_reason": "Conditional result was False"
}

TASK [ansibleplaybookbundle.asb-modules : debug] *********************************************************************************************************************************
task path: /etc/ansible/roles/ansibleplaybookbundle.asb-modules/tasks/main.yml:2
ok: [localhost] => {
    "msg": "Ansible Service Broker modules loaded"
}

TASK [import-from-url : include] *************************************************************************************************************************************************
task path: /opt/ansible/roles/import-from-url/tasks/main.yml:2
included: /opt/ansible/roles/import-from-url/tasks/provision.yml for localhost

TASK [import-from-url : Change project to {{ namespace }}] ***********************************************************************************************************************
task path: /opt/ansible/roles/import-from-url/tasks/provision.yml:2
fatal: [localhost]: FAILED! => {
    "msg": "The conditional check '_apb_plan_id == 'url' or _apb_plan_id == 'url-template'' failed. The error was: error while evaluating conditional (_apb_plan_id == 'url' or _apb_plan_id == 'url-template'): '_apb_plan_id' is undefined\n\nThe error appears to have been in '/opt/ansible/roles/import-from-url/tasks/provision.yml': line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n---\n- name: Change project to {{ namespace }}\n  ^ here\nWe could be wrong, but this one looks like it might be an issue with\nmissing quotes.  Always quote template expression brackets when they\nstart a value. For instance:\n\n    with_items:\n      - {{ foo }}\n\nShould be written as:\n\n    with_items:\n      - \"{{ foo }}\"\n"
}

PLAY RECAP ***********************************************************************************************************************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=1
qwang1 commented 6 years ago

Version: kubevirt v0.7.0, cdi-controller:v1.0.0, asb 1.2.17

Downloaded image http://www.tinycorelinux.net/9.x/x86/release/TinyCore-9.0.iso , it worked.

Downloaded image from http://download.eng.bos.redhat.com/brewroot/packages/rhel-guest-image/7.6/70/images/rhel-guest-image-7.6-70.x86_64.qcow2

[root@cnv-executor-qwang-711-master1 ~]# oc project qwang-import-vm-3
Now using project "qwang-import-vm-3" on server "https://cnv-executor-qwang-711-master1:8443".

[root@cnv-executor-qwang-711-master1 ~]# oc get all
NAME                                             READY     STATUS    RESTARTS   AGE
pod/importer-vm-qwang-rhel7-vm-3-disk-01-x7mt7   0/1       Error     0          4m

NAME                                                    TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)   AGE
service/glusterfs-dynamic-vm-qwang-rhel7-vm-3-disk-01   ClusterIP   172.30.244.129   <none>        1/TCP     4m

[root@cnv-executor-qwang-711-master1 ~]# oc logs pod/importer-vm-qwang-rhel7-vm-3-disk-01-x7mt7
I0711 12:47:38.327644       1 importer.go:31] Starting importer
I0711 12:47:38.328505       1 importer.go:36] beginning import from "http://download.eng.bos.redhat.com/brewroot/packages/rhel-guest-image/7.6/70/images/rhel-guest-image-7.6-70.x86_64.qcow2"
W0711 12:47:38.328583       1 dataStream.go:66] IMPORTER_ACCESS_KEY_ID and/or IMPORTER_SECRET_KEY env variables are empty
I0711 12:47:38.423430       1 util.go:49] begin import...
E0711 12:48:45.254591       1 importer.go:39] exit status 1
could not convert qcow2 image to raw
github.com/kubevirt/containerized-data-importer/pkg/image.ConvertQcow2ToRaw
    /go/src/github.com/kubevirt/containerized-data-importer/pkg/image/qemu.go:38
github.com/kubevirt/containerized-data-importer/pkg/importer.copy
    /go/src/github.com/kubevirt/containerized-data-importer/pkg/importer/dataStream.go:303
github.com/kubevirt/containerized-data-importer/pkg/importer.(*dataStream).copy
    /go/src/github.com/kubevirt/containerized-data-importer/pkg/importer/dataStream.go:283
github.com/kubevirt/containerized-data-importer/pkg/importer.CopyImage
    /go/src/github.com/kubevirt/containerized-data-importer/pkg/importer/dataStream.go:172
main.main
    /go/src/github.com/kubevirt/containerized-data-importer/cmd/importer/importer.go:37
runtime.main
    /usr/local/go/src/runtime/proc.go:198
runtime.goexit
    /usr/local/go/src/runtime/asm_amd64.s:2361
unable to copy image

Questions:

  1. Downloading big size of image is supported? AFAIK, 3GB iso images don't work.
  2. Converting qcow2 -> raw is supported?

Thanks.

nellyc commented 6 years ago

I think this issue belongs to the CDI repo. qcow2 to raw is supported, we demonstrated this flow

qwang1 commented 6 years ago

I used a small sized qcow2, it works.