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

Fix missing ansible.builtin FQCNs in hardcoded action names #71824

Merged
merged 22 commits into from
Nov 3, 2020

Conversation

felixfontein
Copy link
Contributor

@felixfontein felixfontein commented Sep 19, 2020

SUMMARY

Fixes #71817, fixes #71818, fixes #72319, and a bunch of related problems. This is important since the docs try to always use the FQCN version of a action/module.

This is not the best way to fix this, since a collection might redirect an action to ansible.builtin.xxx; when invoked that way, the problems still happen. That is probably esoteric enough that it can be ignored (at least for now) :)

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

core

@ansibot ansibot added affects_2.11 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. needs_triage Needs a first human triage before being processed. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. utilities Utilities category labels Sep 19, 2020
@felixfontein
Copy link
Contributor Author

/rebuild_failed

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Sep 19, 2020
@felixfontein
Copy link
Contributor Author

/rebuild_failed

2 similar comments
@felixfontein
Copy link
Contributor Author

/rebuild_failed

@felixfontein
Copy link
Contributor Author

/rebuild_failed

@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Sep 19, 2020
@samdoran samdoran removed the needs_triage Needs a first human triage before being processed. label Sep 22, 2020
@@ -69,7 +69,8 @@ def _play_ds(self, pattern, async_val, poll):
mytask = {'action': {'module': context.CLIARGS['module_name'], 'args': parse_kv(context.CLIARGS['module_args'], check_raw=check_raw)}}

# avoid adding to tasks that don't support it, unless set, then give user an error
if context.CLIARGS['module_name'] not in ('include_role', 'include_tasks') and any(frozenset((async_val, poll))):
include_actions = ('include_role', 'include_tasks', 'ansible.builtin.include_role', 'ansible.builtin.include_tasks')
Copy link
Member

Choose a reason for hiding this comment

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

i would just create a function that appends `ansible.builtin.' prefixed options to provided list

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I already added such a function ;) I'm now using it everywhere. For efficiency, how about converting all the (now) dynamic function calls to new constants in (f.ex.) constants.py?

@SimonHeimberg
Copy link
Contributor

SimonHeimberg commented Sep 30, 2020

Does this also check the following? (#71878)

- ansible.builtin.command:
    cmd: ls

I do not find it, but this does not mean it is not there.

@felixfontein
Copy link
Contributor Author

@SimonHeimberg I just checked, with this PR your example also works (and with devel it does not).

@ansibot ansibot added stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. core_review In order to be merged, this PR must follow the core review workflow. and removed stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. core_review In order to be merged, this PR must follow the core review workflow. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Sep 30, 2020
@@ -59,6 +59,15 @@ def __getitem__(self, y):
return self._value[y]


def _add_builtin_fqcn(names):
Copy link
Member

Choose a reason for hiding this comment

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

function is fine, but this might not be best location, as constants.py has a heavy cost on import for those that already dont use it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I first thought about lib/ansible/utils/collection_loader/init.py, but that comes with its own import tree. How about lib/ansible/utils/fqcn.py (a new file)? Or lib/ansible/utils/helpers.py?

Copy link
Member

Choose a reason for hiding this comment

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

either works for me, you can even cache responses with a module level var

Copy link
Member

@bcoca bcoca left a comment

Choose a reason for hiding this comment

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

a couple of small caveats, otherwise the code looks good.

@felixfontein
Copy link
Contributor Author

@bcoca what about:

For efficiency, how about converting all the (now) dynamic function calls to new constants in (f.ex.) constants.py?

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Oct 2, 2020
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Nov 1, 2020
@felixfontein
Copy link
Contributor Author

@bcoca I did the renaming. I had to adjust the renaming scheme a bit, since I noticed I used the same name twice. I hope the new one is fine as well :)

(The tests that currently fail also fail in other PRs, so they should be unrelated.)

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Nov 1, 2020
@felixfontein
Copy link
Contributor Author

/rebuild_failed

@felixfontein
Copy link
Contributor Author

/rebuild

@felixfontein felixfontein reopened this Nov 2, 2020
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Nov 2, 2020
@bcoca bcoca merged commit da60525 into ansible:devel Nov 3, 2020
@felixfontein felixfontein deleted the fix-missing-fqcns branch November 3, 2020 13:52
@felixfontein
Copy link
Contributor Author

@bcoca thanks a lot for reviewing!

felixfontein added a commit to felixfontein/ansible that referenced this pull request Nov 3, 2020
…71824)

* Make sure hard-coded action names also check for FQCN.
* Use _add_internal_fqcn() to avoid hardcoded lists and typoes.

(cherry picked from commit da60525)
felixfontein added a commit to felixfontein/ansible that referenced this pull request Nov 3, 2020
…71824)

* Make sure hard-coded action names also check for FQCN.
* Use _add_internal_fqcn() to avoid hardcoded lists and typoes.

(cherry picked from commit da60525)
felixfontein added a commit to felixfontein/ansible that referenced this pull request Nov 3, 2020
…71824)

* Make sure hard-coded action names also check for FQCN.
* Use _add_internal_fqcn() to avoid hardcoded lists and typoes.

(cherry picked from commit da60525)
felixfontein added a commit to felixfontein/ansible that referenced this pull request Nov 3, 2020
…71824)

* Make sure hard-coded action names also check for FQCN.
* Use _add_internal_fqcn() to avoid hardcoded lists and typoes.

(cherry picked from commit da60525)

ci_complete
@ansible ansible locked and limited conversation to collaborators Dec 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.11 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. has_issue support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. utilities Utilities category
Projects
None yet
5 participants