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

Modify scripts/check_galaxy to return more descriptive error message(s) #695

Merged
merged 11 commits into from
Aug 15, 2024

Conversation

brookelew
Copy link
Contributor

@brookelew brookelew commented Jul 24, 2024

Check for both existence of ansible-galaxy and verify ansible-galaxy --version works as expected in execution environment to resolve #694

  • Write tests?

Copy link
Contributor

@Shrews Shrews 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 contributing!

Instead of having a 2-step check here, perhaps we could leave it as a single check (running ansible-galaxy --version, like before) and instead just change the first paragraph of the error message to something more generic, such as "there was an error running the ansible-galaxy command, please use the -vvv option to examine the build output for any errors". Doesn't need to be that exact wording, but you get the idea, hopefully.

Also, yes, we should have a test for this, but your change has exposed a hole in our CI testing. The tests for these scripts live in the pulp-integration test subdirectory, but those tests are no longer run for reasons I won't go into, but I don't see any reason why those particular tests for these scripts can't be moved to our normal integration test subdirectory. I'll work on a fix for that for you so we can get this one moving along.

@brookelew
Copy link
Contributor Author

Thanks! I added some possible causes to the error message, but I'm not sure if that's necessary.

Copy link
Contributor

@Shrews Shrews left a comment

Choose a reason for hiding this comment

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

I like this approach.

Once PR #696 merges, and after you rebase your change to pick it up, your change will break the new test/integration/test_build.py::test_missing_ansible integration test, but that will be easily fixable. And that would be the file where you can create a new integration test for this change using the tests in that PR as a model. You'll need to include an ansible.cfg that will break ansible-galaxy in the manner you expect.

@brookelew
Copy link
Contributor Author

Test is written, sorry for the merge instead of rebase, I didn't realise GitHub would do that automatically

@brookelew brookelew marked this pull request as ready for review July 31, 2024 11:16
@brookelew brookelew requested a review from a team as a code owner July 31, 2024 11:16
Copy link
Contributor

@Shrews Shrews left a comment

Choose a reason for hiding this comment

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

Very nice! Just a few comments inline.

Also, the example ansible.cfg contains way more info than is necessary. Typically in tests, you want the minimum amount of data that would cause the failure you are looking for to eliminate any chances of something else causing an error (either today or further in the future). Let's trim that down to just the essential to cause the failure.


dependencies:
ansible_core:
package_pip: ansible-core==2.15.12
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can just remove the version requirement here.

ansible_core:
package_pip: ansible-core==2.15.12
ansible_runner:
package_pip: ansible-runner==2.3.1
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here... leave off version.

f'--container-runtime={runtime} -v3'
)

assert "ERROR - 'ansible-galaxy' command not functioning as expected" in einfo.value.stdout
Copy link
Contributor

Choose a reason for hiding this comment

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

In addition to this assert, we should add another that checks for the actual error emitted from ansible-galaxy (visible in the output thanks to using -v3) to make sure it is the faulty ansible.cfg causing the error and not something else. In this case, looks like the error string we want begins with:

ERROR: Error reading config file (/etc/ansible/ansible.cfg): Source contains parsing errors:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for getting the exact line I needed!

@Shrews
Copy link
Contributor

Shrews commented Jul 31, 2024

Also, regarding the merge commit, I'm not 100% certain how the GH interface is going to handle that. We'd like to keep our history clean and linear, so if you could eliminate that for me in your PR, it would be much appreciated.

@Shrews
Copy link
Contributor

Shrews commented Jul 31, 2024

Also, regarding the merge commit, I'm not 100% certain how the GH interface is going to handle that. We'd like to keep our history clean and linear, so if you could eliminate that for me in your PR, it would be much appreciated.

Actually, I think you can ignore this request, if you wish. The squash button should eliminate the merge commit for us.

@brookelew brookelew marked this pull request as draft July 31, 2024 16:14
@brookelew
Copy link
Contributor Author

If it's fixed by the squash I don't think I'll touch it, should there be a test for a completely missing ansible-galaxy install or is the incorrect ansible.cfg test fine?

@brookelew brookelew marked this pull request as ready for review July 31, 2024 16:33
@brookelew brookelew marked this pull request as draft August 2, 2024 01:12
@Shrews
Copy link
Contributor

Shrews commented Aug 6, 2024

Hi @brookelew

Not sure if you saw, but your change is not passing our CI tests. You can see more info on the Details like next to each failing test. You have a linting problem, and the error message text you are asserting has changed since you modified the example ansible.cfg, so you'll need to account for that.

@brookelew
Copy link
Contributor Author

Oh no yeah I saw sorry was just a bit busy last week

Copy link

sonarcloud bot commented Aug 7, 2024

@brookelew brookelew marked this pull request as ready for review August 7, 2024 22:05
@brookelew brookelew requested a review from Shrews August 14, 2024 03:36
@Shrews Shrews merged commit 7643d68 into ansible:devel Aug 15, 2024
15 checks passed
@Shrews
Copy link
Contributor

Shrews commented Aug 15, 2024

Thanks for your contribution @brookelew !

@brookelew
Copy link
Contributor Author

Thanks for supervising my first open source contribution @Shrews ! : D

Shrews pushed a commit to Shrews/ansible-builder that referenced this pull request Aug 26, 2024
…s) (ansible#695)

Error message from check_galaxy is updated to be more descriptive in case of ansible.cfg parsing error.

(cherry picked from commit 7643d68)
Shrews pushed a commit that referenced this pull request Aug 26, 2024
…s) (#695)

Error message from check_galaxy is updated to be more descriptive in case of ansible.cfg parsing error.

(cherry picked from commit 7643d68)
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.

Ansible Galaxy check script error message may be somewhat misleading
2 participants