Skip to content
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

[Bug] filtering on name results in error in module ntnx_images_info #388

Closed
jhowe-uw opened this issue Aug 19, 2023 · 3 comments · Fixed by #392
Closed

[Bug] filtering on name results in error in module ntnx_images_info #388

jhowe-uw opened this issue Aug 19, 2023 · 3 comments · Fixed by #392
Assignees
Labels
1.9.3_triage Bug fixes & Improvements bug Something isn't working

Comments

@jhowe-uw
Copy link

Describe the bug

Following the examples provided for ntnx_images_info, I encounter runtime issues when applying a filter to the images_info query

We use cloud-init isos to customize the VM on deploys

We have a playbook that leaves ${hostname}-cloud-init isos on VM deploy failure.

It appears we can upload multiple instances of the same ISO with the same name. This causes issues on new VM deploys using nutanix.ncp.ntnx_vms ( 500 Internal Server Error )

To address this issue, I am attempting to sanity check for existing cloud-init isos and make a list to purge if duplicates are found.

To Reproduce
Steps to reproduce the behavior:

Create 12 images named "some-host-cloud-init.iso" using the same ISO file.

Relevant vars

  module_defaults:
    group/nutanix.ncp.ntnx:
      nutanix_username: '{{ vault_nutanix_svc_account }}'
      nutanix_password: '{{ vault_nutanix_svc_password }}'
      validate_certs:   false

Playbook

- name: Create VM If It Does Not Exist
  when: does_nutanix_vm_exist.response.metadata.total_matches == 0
  block:
    - name: Sanity Check for Existing Cloud Init ISOs
      delegate_to:  localhost
      register:     existing_cloud_init_isos
      nutanix.ncp.ntnx_images_info:
        nutanix_host:   '{{ nutanix_hostname }}'
        filter:
          - name:       '{{ inventory_hostname_short }}-cloud-init.iso'
        length:         -1
        offset:         0
        sort_order:     'ASCENDING'
        sort_attribute: 'name'

Stack trace

TASK [Sanity Check for Existing Cloud Init ISOs] *********************************************************
Friday 18 August 2023  18:41:53 -0700 (0:00:01.208)       0:00:02.107 ********* 
Friday 18 August 2023  18:41:53 -0700 (0:00:01.208)       0:00:02.106 ********* 
fatal: [${FQDN} -> localhost]: FAILED! => {"changed": false, "msg": "argument 'filter' is of type <class 'list'> and we were unable to convert to dict: <class 'list'> cannot be converted to a dict"}

Expected behavior

Filtering on '{{ inventory_hostname_short }}-cloud-init.iso' should result in a json list containing the 12 instances of this file that I can parse to gather a list of UUIDs to queue for deletion.

Additional context

I tested using a known single instance of an image name and got the same error ( 'CENTOS_78' )

Please let me know if you need additional information.

Thanks

@jhowe-uw jhowe-uw added the bug Something isn't working label Aug 19, 2023
@Gevorg-Khachatryan-97
Copy link
Collaborator

Dear @jhowe-uw,
Unfortunately, there is a typo in the example, and as you can see, the error message says that the filter must be a dictionary.
So it should look like this.

      nutanix.ncp.ntnx_images_info:
        nutanix_host:   '{{ nutanix_hostname }}'
        filter:
          name:       '{{ inventory_hostname_short }}-cloud-init.iso'

@jhowe-uw
Copy link
Author

@Gevorg-Khachatryan-97

I tested with the new syntax and it works for me.

Thanks!

@bhati-pradeep bhati-pradeep linked a pull request Oct 30, 2023 that will close this issue
@bhati-pradeep bhati-pradeep added the 1.9.3_triage Bug fixes & Improvements label Aug 5, 2024
@george-ghawali
Copy link
Collaborator

The issue has been fixed in PR #392, and everything is working as expected now. Closing the issue.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.9.3_triage Bug fixes & Improvements bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants