-
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
folder_moid_lookup not working consistently #324
Comments
While the workaround is working, I noticed that other lookups have the same issue.. |
Thank you @robbevl for the bug report. What version of vSphere do you use? |
I've tried to reproduce the problem with the following tasks: - name: Create the Applications folder
community.vmware.vcenter_folder:
datacenter_name: my_dc
folder_name: Applications
folder_type: vm
state: present
- name: Create the MYAPP folder
community.vmware.vcenter_folder:
datacenter_name: my_dc
folder_name: MYAPP
folder_type: vm
parent_folder: Applications
state: present
- include_tasks: create_delete.yaml
with_sequence: start=0 end=400 stride=1 and this is the - name: Create the PRD folder
community.vmware.vcenter_folder:
datacenter_name: my_dc
folder_name: PRD
folder_type: vm
parent_folder: Applications/MYAPP
state: present
- vcenter_folder_info:
register: a
- debug: var=a
- set_fact:
level1: "{{ lookup('vmware.vmware_rest.folder_moid', '/my_dc/vm/Applications') }}"
level2: "{{ lookup('vmware.vmware_rest.folder_moid', '/my_dc/vm/Applications/MYAPP') }}"
level3: "{{ lookup('vmware.vmware_rest.folder_moid', '/my_dc/vm/Applications/MYAPP/PRD') }}"
- debug:
msg: "level1 {{ level1 }}, level2 {{ level2 }}, level3: {{ level3 }}"
- assert:
that:
- "level1 != ''"
- "level2 != ''"
- "level3 != ''"
- name: Delete the PRD folder
community.vmware.vcenter_folder:
datacenter_name: my_dc
folder_name: PRD
folder_type: vm
parent_folder: Applications/MYAPP
state: absen This is not enough to reproduce the problem here (vSphere 7.0.3). Can you try on your side to confirm this is enough to trigger the error. |
Hi, thanks for taking the time to look into this! I adapted the tasks slightly (needed to provide custom vcenter_hostname and user, also provided our actual dc name), but it did fail on the first iteration:
Here's the literal playbook I used (minus vsphere login info). test_moid.yml:
test_create_delete.yml:
Only actual difference I can see with what you did is the dc name (not sure it is relevant). |
SUMMARY This change rewrites the lookup plugin logic to use a top down approach to finding objects. The plugins will now step through an objects path and try to lookup each intermediate object until it gets to the final object. The old method has a few issues: The existing plugins use an incorrect search method which yield inconsistent results (as described in #500) They also cannot find resources with the same name, even if the paths given are unique. For example, if /datacenter/vms/my-folder and /datacenter/hosts/my-folder both exist, you can never find either one Items with the same name will cause conflicts, even if those items have slightly different paths. For example: /datacenter/vms/foo and /datacenter/hosts/foo existing at the same time makes it difficult to search for either folder Fixes: #500 #445 #324 ISSUE TYPE Bugfix Pull Request COMPONENT NAME all lookup plugins ADDITIONAL INFORMATION The original top down approach is described in #445. I tried to get that version working but ran into a few issues. Reviewed-by: Danielle Barda Reviewed-by: Ondra Machacek <machacek.ondra@gmail.com> Reviewed-by: mikemorency
This issue should be resolved in the next release. Please see #500 for more details |
…d folder_moid We are hitting the following bug: ansible-collections/vmware.vmware_rest#324 This is a workaround till new version of the vmware.vmware_rest will be released
…d folder_moid (#8551) * [ocp4_workload_virt_roadshow_vmware] Using vcenter_folder_info instead folder_moid We are hitting the following bug: ansible-collections/vmware.vmware_rest#324 This is a workaround till new version of the vmware.vmware_rest will be released * Update vcenter_setup_create_folder_and_vms.yml * Update vcenter_setup_create_folder_and_vms.yml
Sometimes, a folder 4 levels deep is not found, the lookup then returns an empty string.
Our folderstructure looks like this:
/DC/Applications/MYAPP/PRD
/DC/Applications/MYAPP is found, and MOID returned.
/DC/Applications/MYAPP/PRD is not found
If I create /DC/Applications/MYAPP/PROD it is found.
If that folder is then renamed to /DC/Applications/MYAPP/PRD the plug can't find it any more.
I'm not sure what the issue is:
It looks totally random, but it's always four levels deep, and once it decides it can't find a name it will never find that name, not even if you delete and recreate the folder, or if you rename a folder that can be found.
Note that vmware.vmware_rest.vcenter_folder_info can find those problematic folders.
If someone can help me pinpoint this I'm all ears.
I'll use a workaround like this for now:
"{{ my_folder.value[0].folder }}"
gives me then the same value as I expected from
"{{ lookup('vmware.vmware_rest.folder_moid', deploy_folder) }}"
The text was updated successfully, but these errors were encountered: