Add explicit list filter after rejectattr#1845
Merged
rooftopcellist merged 1 commit intoansible:develfrom Apr 30, 2024
Merged
Conversation
With ansible 2.9.27 (operator-sdk v1.27.0) then the rejectattr filter returns a generator 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) "<generator object select_or_reject at 0x7fbbf0443728>" This is a similar issue as 80a9e8c. TASK [Get the new resource pod information after updating resource.] ******************************** FAILED! => {"msg": "The conditional check '_new_pod['resources'] | rejectattr('metadata.deletionTimestamp', 'defined') | length' failed. The error was: Unexpected templating type error occurred on ({% if _new_pod['resources'] | rejectattr('metadata.deletionTimestamp', 'defined') | length %} True {% else %} False {% endif %}): object of type 'generator' has no len() This also removes the unneeded quotes on the when conditions. Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
rcarrillocruz
approved these changes
Apr 29, 2024
rooftopcellist
approved these changes
Apr 30, 2024
larsux
pushed a commit
to plusserver/awx-operator
that referenced
this pull request
Apr 30, 2024
With ansible 2.9.27 (operator-sdk v1.27.0) then the rejectattr filter returns a generator 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) "<generator object select_or_reject at 0x7fbbf0443728>" This is a similar issue as 80a9e8c. TASK [Get the new resource pod information after updating resource.] ******************************** FAILED! => {"msg": "The conditional check '_new_pod['resources'] | rejectattr('metadata.deletionTimestamp', 'defined') | length' failed. The error was: Unexpected templating type error occurred on ({% if _new_pod['resources'] | rejectattr('metadata.deletionTimestamp', 'defined') | length %} True {% else %} False {% endif %}): object of type 'generator' has no len() This also removes the unneeded quotes on the when conditions. Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SUMMARY
With ansible 2.9.27 (operator-sdk v1.27.0) then the rejectattr filter returns a generator 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
ADDITIONAL INFORMATION
"<generator object select_or_reject at 0x7fbbf0443728>"This is a similar issue as 80a9e8c.
This also removes the unneeded quotes on the when conditions.