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

Check the stat dictionary's size, not the variable's size #323

Merged
merged 1 commit into from
Feb 16, 2024

Conversation

wolsen
Copy link
Contributor

@wolsen wolsen commented Feb 16, 2024

The ansible.builtin.stat module returns a dictionary where the key to use is 'stat' in order to get the file stats. Add the missing stat key. Failure to do this causes the task to fail with size not being a key in the dictionary.

ref: https://docs.ansible.com/ansible/latest/collections/ansible/builtin/stat_module.html#ansible-collections-ansible-builtin-stat-module

@@ -23,4 +23,4 @@
TOX_CONSTRAINTS_FILE: "{{ constraints_file.path }}"
# Backward compatibility, to be removed
UPPER_CONSTRAINTS_FILE: "{{ constraints_file.path }}"
when: constraints_stat.size > 0
when: constraints_file is defined and constraints_stat.size > 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above condition looks good but more appropriate can be to use constraints_stat.exists

Copy link
Member

@freyes freyes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for fixing this, I missed that part from the docs.

@@ -23,4 +23,4 @@
TOX_CONSTRAINTS_FILE: "{{ constraints_file.path }}"
# Backward compatibility, to be removed
UPPER_CONSTRAINTS_FILE: "{{ constraints_file.path }}"
when: constraints_stat.size > 0
when: constraints_file is defined and constraints_stat.size > 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be constraints_stat.stat.size, it's still missing the .stat

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just pushed a new revision of the change to address this.

The ansible.builtin.stat module returns a dictionary where the
key to use is 'stat' in order to get the file stats. Add the
missing stat key. Failure to do this causes the task to fail
with size not being a key in the dictionary.

ref: https://docs.ansible.com/ansible/latest/collections/ansible/builtin/stat_module.html#ansible-collections-ansible-builtin-stat-module
Copy link
Contributor

@hemanthnakkina hemanthnakkina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hemanthnakkina hemanthnakkina merged commit 1ff110a into openstack-charmers:master Feb 16, 2024
2 checks passed
@wolsen wolsen deleted the fix-stat branch February 16, 2024 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants