Skip to content

postgresql: Cast sorted_old_postgres_pods as list#1791

Merged
rooftopcellist merged 1 commit intoansible:develfrom
dsavineau:reverse_filter_to_list
Mar 27, 2024
Merged

postgresql: Cast sorted_old_postgres_pods as list#1791
rooftopcellist merged 1 commit intoansible:develfrom
dsavineau:reverse_filter_to_list

Conversation

@dsavineau
Copy link
Copy Markdown
Contributor

SUMMARY

With ansible 2.9.27 (operator-sdk v1.27.0) then the reverse filter returns an iterator so we need to cast it to list. The behavior doesn't exist when using a more recent operator-sdk version like v1.34.0 (ansible-core 2.15.8) but using the list filter on that version works too (even if not needed)

ISSUE TYPE
  • Bug, Docs Fix or other nominal change
ADDITIONAL INFORMATION
TASK [Set info for previous postgres pod] **************************************
task path: /opt/ansible/roles/installer/tasks/database_configuration.yml:130
ok: [localhost] => {"ansible_facts": {"sorted_old_postgres_pods": "<list_reverseiterator object at 0x7f512f251fd0>"}, "changed": false}

TASK [Set info for previous postgres pod] **************************************
task path: /opt/ansible/roles/installer/tasks/database_configuration.yml:138
ok: [localhost] => {"ansible_facts": {"old_postgres_pod": "<"}, "changed": false}

(...)

TASK [postgres : Get old PostgreSQL version] ***********************************
task path: /opt/ansible/roles/installer/tasks/database_configuration.yml:159
fatal: [localhost]: FAILED! => {
    "msg": "The task includes an option with an undefined variable. The error was: 'ansible.utils.unsafe_proxy.AnsibleUnsafeText object' has no attribute 'metadata'\n\nThe error appears to be in '/opt/ansible/roles/installer/tasks/database_configuration.yml': line 159, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n    - name: Get old PostgreSQL version\n      ^ here\n"

With ansible 2.9.27 (operator-sdk v1.27.0) then the reverse filter
returns an iterator so we need to cast it to list.
The behavior doesn't exist when using a more recent operator-sdk
version like v1.34.0 (ansible-core 2.15.8) but using the list
filter on that version works too (even if not needed)

"sorted_old_postgres_pods": "<list_reverseiterator object at 0x7f539eaa5610>"

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
@dsavineau dsavineau force-pushed the reverse_filter_to_list branch from c23cde7 to 66f23d3 Compare March 26, 2024 13:22
@rooftopcellist rooftopcellist merged commit 80a9e8c into ansible:devel Mar 27, 2024
@rooftopcellist
Copy link
Copy Markdown
Member

Thanks for adding the backwards compatibility. We will likely need to be backwards compatible with the earlier ansible-operator-sdk image for the next 6-12 months.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants