-
Notifications
You must be signed in to change notification settings - Fork 23.8k
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
Add an error message if a pkg cannot be removed, fixes #35672 #40723
Add an error message if a pkg cannot be removed, fixes #35672 #40723
Conversation
# Return a special 'error' field so it's obvious to the user | ||
# why yum failed and which package couldn't be removed. More | ||
# details: https://github.com/ansible/ansible/issues/35672 | ||
res['error'] = "Package '%s' couldn't be removed!" % pkg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it would be better for consistency to append it to res['msg']
rather than creating a new key, since we use msg
for errors in the module?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about it, but in this situation the msg
looks like this:
Skipping the running kernel: kernel-3.10.0-693.21.1.el7.x86_64
Which isn't that obvious tbh and if I appended my message it would be easy to miss it. I would leave msg
to the yum
output.
Also yum
module is all over the place regarding the return keys, it would really be nice if we made it consistent and also add the docs about the return keys. I could probably provide some proposal before any work is done on it if you are interested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have strong feelings about this really but I guess my concern was that with this we could end up with having error messages in both msg
and error
at the same time which seems little confusing to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having said that we could do this (add error
) for now and do cleanup for the whole module (including documenting the return keys) later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it is an error, use fail_json
, otherwise it is a warning, which module.warn()
can take care of
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bcoca I don't understand what you are saying. We are using fail_json
, it's in the next line. This will just make sure all the fields which were set before are also returned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then that should be the msg=
to fail_json, the error
key is not a good choice here, i could see a 'failed_pkgs' = [ list of failed]
as an additional key, but error
seems to be part of a standard that does not exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed with @bcoca here, I would like to see that land in msg
b5b8d22
to
5c80778
Compare
As requested I set the error message to be returned inside the |
@kustodian please rebase and resolve the current conflict, thank you :) |
5c80778
to
02c1994
Compare
@maxamillion done. |
rebuild_merge |
@kustodian thank you! Sorry about the churn on the code. I'd like to continue to do more incremental clean up now that the major refactor is done but hopefully won't be doing anything that big again. Anyways, thank you again! |
SUMMARY
When yum cannot remove a package it fails, but the message why the module failed isn't obvious. This adds an
error
return field which prints exactly which package couldn't be removed.This PR is a fix for #35672.
ISSUE TYPE
COMPONENT NAME
yum
ANSIBLE VERSION