-
Notifications
You must be signed in to change notification settings - Fork 347
Description
SUMMARY
ansible modules sporadically fail for:
AttributeError: 'NoneType' object has no attribute 'dasProtected'
The problem happens every few months in our continuous integration builds. We are running tens of builds per day, and each of the builds is executing ansible modules tens/hundreds of times.
Full stack trace:
2023-07-14 21:29:50.714 MSG:
2023-07-14 21:29:50.714
2023-07-14 21:29:50.714 MODULE FAILURE
2023-07-14 21:29:50.714 See stdout/stderr for the exact error
2023-07-14 21:29:50.714
2023-07-14 21:29:50.714
2023-07-14 21:29:50.714 MODULE_STDERR:
2023-07-14 21:29:50.714
2023-07-14 21:29:50.714 Traceback (most recent call last):
2023-07-14 21:29:50.714 File "<stdin>", line 102, in <module>
2023-07-14 21:29:50.714 File "<stdin>", line 94, in _ansiballz_main
2023-07-14 21:29:50.714 File "<stdin>", line 40, in invoke_module
2023-07-14 21:29:50.714 File "/usr/lib64/python2.7/runpy.py", line 176, in run_module
2023-07-14 21:29:50.714 fname, loader, pkg_name)
2023-07-14 21:29:50.714 File "/usr/lib64/python2.7/runpy.py", line 82, in _run_module_code
2023-07-14 21:29:50.714 mod_name, mod_fname, mod_loader, pkg_name)
2023-07-14 21:29:50.714 File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
2023-07-14 21:29:50.714 exec code in run_globals
2023-07-14 21:29:50.714 File "/tmp/ansible_vmware_guest_payload_sGAKeD/ansible_vmware_guest_payload.zip/ansible/modules/cloud/vmware/vmware_guest.py", line 2834, in <module>
2023-07-14 21:29:50.714 File "/tmp/ansible_vmware_guest_payload_sGAKeD/ansible_vmware_guest_payload.zip/ansible/modules/cloud/vmware/vmware_guest.py", line 2776, in main
2023-07-14 21:29:50.714 File "/tmp/ansible_vmware_guest_payload_sGAKeD/ansible_vmware_guest_payload.zip/ansible/module_utils/vmware.py", line 805, in set_vm_power_state
2023-07-14 21:29:50.714 File "/tmp/ansible_vmware_guest_payload_sGAKeD/ansible_vmware_guest_payload.zip/ansible/module_utils/vmware.py", line 324, in gather_vm_facts
2023-07-14 21:29:50.714 AttributeError: 'NoneType' object has no attribute 'dasProtected'
We are still running ansible-2.9.27-1.el7, but the piece of code which causes the problem is still the same:
community.vmware/plugins/module_utils/vmware.py
Lines 485 to 486 in 9f06033
| if vm.summary.runtime.dasVmProtection: | |
| facts['hw_guest_ha_state'] = vm.summary.runtime.dasVmProtection.dasProtected |
those two code lines should never be able to result in this error? The if-statement should skip executing the block, if dasVmProtection=None ... but still, sometimes it gets executed and then it fails.
ISSUE TYPE
- Bug Report
COMPONENT NAME
module_utils/vmware.py
ANSIBLE VERSION
[root@01fb50763f87 /]# ansible --version
ansible 2.9.27
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/root/.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
python version = 2.7.5 (default, Nov 20 2015, 02:00:19) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]
COLLECTION VERSION
N/A
CONFIGURATION
ANSIBLE_PIPELINING(env: ANSIBLE_SSH_PIPELINING) = True
ANSIBLE_SSH_CONTROL_PATH_DIR(env: ANSIBLE_SSH_CONTROL_PATH_DIR) = /tmp
ANY_ERRORS_FATAL(env: ANSIBLE_ANY_ERRORS_FATAL) = True
DEFAULT_STDOUT_CALLBACK(env: ANSIBLE_STDOUT_CALLBACK) = debug
DEFAULT_TIMEOUT(env: ANSIBLE_TIMEOUT) = 180
DEFAULT_TRANSPORT(env: ANSIBLE_TRANSPORT) = paramiko
HOST_KEY_CHECKING(env: ANSIBLE_HOST_KEY_CHECKING) = False
OS / ENVIRONMENT
vCenter 7
python2-pyvmomi-7.0.1-2.el7
STEPS TO REPRODUCE
The problem happens every few months in our continuous integration builds. We are running tens of builds per day, and each of the builds is executing ansible modules tens/hundreds of times. We have no exact steps to reproduce because the problem is sporadic and happens infrequently.
EXPECTED RESULTS
vmware modules should get facts successfully from vmware.py:gather_vm_facts()
ACTUAL RESULTS
vmware.py:gather_vm_facts() sometimes fails for AttributeError: 'NoneType' object has no attribute 'dasProtected', even though looking at the code this should not be even possible.