-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
recursive_folder_or_rp_moid_search awaits objects_moid to be in order (but it isn't necessarily) #500
Comments
Could this maybe already have been fixed by #445 ? Edit: Just copy-pasting the code from the PR does not seem to work. It runs into an ansible_collections.cloud.common.plugins.module_utils.turbo.exceptions.EmbeddedModuleUnexpectedFailure |
Maybe this is also the same as #324 |
hi @dbk-rabel im having some trouble reproducing the issue. Im also experiencing the EmbeddedModuleUnexpectedFailure when I try to use these lookups. Could you provide the version of the collection your using, the version of ansible packages (ansible and/or ansible-core), and your vcenter version? Also maybe a playbook to reproduce the issue? I dont see any reason the playbook in 445 wouldnt work for you but other playbooks would, so thats interesting. If you have any insight into why that might be happening that would also be helpful |
Hello @mikemorency . We are using vmware.vmware_rest 3.0.1, ansible-core 2.15.11 Here is an example playbook, but of course you would need to create the folders in vcenter first: ---
- name: Test
hosts: localhost
gather_facts: false
connection: local
vars:
directories:
- folder/subfolder1
- folder/subfolder2
tasks:
- name: Test
ansible.builtin.debug:
msg: "{{ item }} has MOID {{ lookup('vmware.vmware_rest.folder_moid', '/ my_datacenter/' + item, **connection_args) }}"
loop: "{{ directories }}" As I said: It works if and only if the API returns the moids of the folders in the correct order. This is not guaranteed. We did not find out when or why it does so, but since it fails especially with newer folders, it might have something todo with the date when the folders where created. |
Hi @dbk-rabel , thank you for your patience. I just wanted to let you know that I have a PR with a fix for the lookup plugins. It would be great if you could test it before we release in a few weeks, just to be extra sure your issue is solved. To install my branch:
Please note the modules on my branch are from release 4.0.0 and are based on vSphere 8. The lookup plugins should work on either 7 or 8 |
Hi @mikemorency .
|
Thanks for testing! Can you confirm the version of Python your using on the Ansible control node?
|
I tried to use Python3.9 in my virtualenv, but somehow I seem to keep failing:
I tried to add Yours |
@mikemorency Since you already closed this, I guess you were able to test that it fixes this issue? |
The PR I had opened was merged, and some automation closed the issue. Ive re-opened it. Thats weird, but Im able to see the same results as you (python interpreter not taking effect). Let me see if I can find out why |
OK I think I understand the issue. The So you would need to activate your virtual env before running the playbook, or install Heres a playbook showing the difference:
For reference: |
Ok. I kinda understand the issue. I installed aiohttp using the system python and then it worked. And yes, it does seem to fix the issue! :-) At least for my testcase: Cannot find folder moid with upstream version. Can find folder moid with your fix. Thanks a lot! |
Excellent! The fix will be included in the next minor version release for version 4 and 3 of this collection. It should be available around September 19th. Im going to close the issue, but feel free to open a new one in the future or let me know if you think it should be re-opened. |
Hi.
We stumbled across this, because sometimes folder lookups worked fine and sometimes they didn't.
While troubleshooting we noticed that
recursive_folder_or_rp_moid_search
awaitsobjects_moid
(which it gets from the API) to be in order of the path.If they're not, https://github.com/ansible-collections/vmware.vmware_rest/blob/main/plugins/plugin_utils/lookup.py#L472 will never match.
But the API does not always send them in order.
We have a lookup that looks like this:
lookup('vmware.vmware_rest.folder_moid', '/my_datacenter/my_topfolder/my_subfolder', **connection_args)
In
get_all_objects_path_moid
there is an API call to a ressource like this:https:///api/vcenter/folder?datacenters=my_datacenter_moid&names=my_subfolder&names=my_topfolder
And it receives this from the API:
[{'folder': 'my_subfolder_moid', 'name': 'my_subfolder', 'type': 'VIRTUAL_MACHINE'}, {'folder': 'my_topfolder_moid', 'name': 'my_top_folder', 'type': 'VIRTUAL_MACHINE'}]
This only happens for folders that we've created in the last days. Not sure if this is the reason, why the API behaves like that.
But since the API is not consistent with the ordering, I think we can say that
recursive_folder_or_rp_moid_search
is broken right now.Yours
David
The text was updated successfully, but these errors were encountered: