Open lynchmaniac opened 2 years ago
Extra info : I am trying to create an additional disk on my virtual machine. The code below runs often and works fine. My disks are correctly added. However, sometimes I have an error that occurs randomly. If I run the command again, it works without changing anything in the hypervisor code or settings
ovirt.ovirt.ovirt_disk
I retry this code several times and finally have an "'NoneType' object has no attribute 'status'" error.
- name: ({{ machine.name }}) create extra disk
ovirt_disk:
auth:
username: "{{ ovirt_username }}"
password: "{{ ovirt_password }}"
hostname: "{{ ovirt_hostname }}"
url: https://{{ ovirt_hostname }}/ovirt-engine/api
token: "{{ ansible_facts['ovirt_auth'].token }}"
insecure: yes
scsi_passthrough: filtered
vm_name: "{{ machine.name }}"
name: "{{ machine.name | upper ~ disk_suffixes[template_info.ovirt_templates[0].disk_attachments | length + index] }}"
size: "{{ disk.size }}"
format: raw
interface: virtio
storage_domain: "{{ disk.storage }}"
description: "{{ disk.comment | default('') }}"
state: "{{ machine.state | default('present') }}"
poll_interval: 60
timeout: 300
loop: "{{ profile.disks | default([]) + machine.disks | default([]) }}"
loop_control:
loop_var: disk
index_var: index
when: bool_add_disks and bool_all
TASK [test : (machine1) create extra disk] ***
changed: [localhost] => (item={'size': '20GiB', 'comment': 'lorem_ipsum', 'storage': 'domain_1'})
the stacktrace
TASK [rhev_infra_node : (XMOECONTVPIKW1) Création des disques supplémentaires] ***
task path: /builds/ansible/playbooks/roles/rhev_infra_node/tasks/create-vm.yml:305
redirecting (type: modules) ansible.builtin.ovirt_disk to ovirt.ovirt.ovirt_disk
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c 'echo ~root && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir "` echo /root/.ansible/tmp/ansible-tmp-1662050436.4582345-480-224325627885602 `" && echo ansible-tmp-1662050436.4582345-480-224325627885602="` echo /root/.ansible/tmp/ansible-tmp-1662050436.4582345-480-224325627885602 `" ) && sleep 0'
redirecting (type: modules) ansible.builtin.ovirt_disk to ovirt.ovirt.ovirt_disk
Using module file /root/.ansible/collections/ansible_collections/ovirt/ovirt/plugins/modules/ovirt_disk.py
<localhost> PUT /root/.ansible/tmp/ansible-local-148a6_1ly3d/tmpgq5czux6 TO /root/.ansible/tmp/ansible-tmp-1662050436.4582345-480-224325627885602/AnsiballZ_ovirt_disk.py
<localhost> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1662050436.4582345-480-224325627885602/ /root/.ansible/tmp/ansible-tmp-1662050436.4582345-480-224325627885602/AnsiballZ_ovirt_disk.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3 /root/.ansible/tmp/ansible-tmp-1662050436.4582345-480-224325627885602/AnsiballZ_ovirt_disk.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1662050436.4582345-480-224325627885602/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ovirt_disk_payload_4ibfftmu/ansible_ovirt_disk_payload.zip/ansible_collections/ovirt/ovirt/plugins/modules/ovirt_disk.py", line 881, in main
File "/tmp/ansible_ovirt_disk_payload_4ibfftmu/ansible_ovirt_disk_payload.zip/ansible_collections/ovirt/ovirt/plugins/module_utils/ovirt.py", line 691, in create
wait(
File "/tmp/ansible_ovirt_disk_payload_4ibfftmu/ansible_ovirt_disk_payload.zip/ansible_collections/ovirt/ovirt/plugins/module_utils/ovirt.py", line 386, in wait
elif fail_condition(entity):
File "/tmp/ansible_ovirt_disk_payload_4ibfftmu/ansible_ovirt_disk_payload.zip/ansible_collections/ovirt/ovirt/plugins/modules/ovirt_disk.py", line 885, in <lambda>
AttributeError: 'NoneType' object has no attribute 'status'
plugins/modules/ovirt_disk.py
The error is in theses lines
ret = disks_module.create(
entity=disk if not force_create else None,
result_state=otypes.DiskStatus.OK if lun is None else None,
search_params=searchable_attributes(module),
fail_condition=lambda d: d.status == otypes.DiskStatus.ILLEGAL if lun is None else False,
force_create=force_create,
_wait=True if module.params['upload_image_path'] else module.params['wait'],
)
So it's to be the same kind of error but in another place in the code. The object representing the virtual machine or the disk is sometimes null and therefore cannot have a status. Tell me if you need more information.
SUMMARY
Hi, the use case is when I try to start my new VM. The code below runs often and works fine. The VM start correctly. However, sometimes I have an error that occurs randomly. If I run the command again, it works without changing anything in the hypervisor code or settings
COMPONENT NAME
ovirt.ovirt.ovirt_vm
STEPS TO REPRODUCE
I retry this code several times and finally have an "'NoneType' object has no attribute 'status'" error.
EXPECTED RESULTS
ACTUAL RESULTS
the stacktrace in short version
The error is in theses lines
So sometimes the vm variable is not filled in correctly. Do you have any idea why this use case may occur randomly ? Could this be due to hypervisor slowness?