-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
alternatives: Fix bug with priority default #4810
alternatives: Fix bug with priority default #4810
Conversation
If neigther the priority nor the subcommands where specified the module decided to update the priority with the default value anyway. This resulted in bug ansible-collections#4803 and ansible-collections#4804
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.
Thanks! Please add a changelog fragment.
tests/integration/targets/alternatives/tasks/tests_set_priority.yml
Outdated
Show resolved
Hide resolved
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 added a very last nitpick but LGTM.
Co-authored-by: Pilou <[email protected]>
Hmm, when looking at the fix and the issues, I don't think this fixes #4803 or #4804. The problem seems to be that
This gives:
Thus for path, prio, subcmd in alternative_regex.findall(display_output):
self.current_alternatives[path] = dict(
priority=int(prio),
subcommands=[dict(
name=name,
path=spath,
link=subcmd_path_map.get(name)
) for name, spath in subcmd_regex.findall(subcmd) if spath != '(null)']
) produces dictionaries with The output was a bit more interesting on RHEL8.5 we use in CI for
The output on Ubuntu 20.04 and 22.04 is different:
So the problem here isn't the default value for |
Ok, so this does fix a bug, but not the bug reported in the issues. Let's merge this anyway, but we need a fix for these issues as well... |
Backport to stable-5: 💚 backport PR created✅ Backport PR branch: Backported as #4835 🤖 @patchback |
Let's fix the issues in another PR. |
* alternatives: Fix bug with priority default If neigther the priority nor the subcommands where specified the module decided to update the priority with the default value anyway. This resulted in bug #4803 and #4804 * Add changelog fragment. * Distinguish None from 0. * Address review comments. * Update plugins/modules/system/alternatives.py Co-authored-by: Pilou <[email protected]> * Remove unrelated issues from changelog. Co-authored-by: Felix Fontein <[email protected]> Co-authored-by: Pilou <[email protected]> (cherry picked from commit 57e83ac)
If neigther the priority nor the subcommands where specified the module decided to update the priority with the default value anyway.
This resulted in the bug #4803 and #4804 when the subcommands have not been specified.SUMMARY
Do not set the priority if the default value if the priority is not set.
ISSUE TYPE
COMPONENT NAME
alternatives
ADDITIONAL INFORMATION