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

start getting modules to use shared import error code #51787

Merged
merged 2 commits into from
Feb 6, 2019

Conversation

jborean93
Copy link
Contributor

SUMMARY

Start to get modules to use the shared missing_required_lib error message. This error message builds a common error message in the case of an error when importing a required module. It includes information such as;

  • The module name
  • The host it is required on
  • An optional reason if the module wishes to add this
  • The Python executable that ran the module
ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

lots

@ansibot ansibot added affects_2.8 This issue/PR affects Ansible v2.8 core_review In order to be merged, this PR must follow the core review workflow. deprecated This issue/PR relates to a deprecated module. feature This issue/PR relates to a feature request. k8s m:xml This issue/PR relates to the xml module. module This issue/PR relates to a module. mongodb MongoDB community needs_triage Needs a first human triage before being processed. postgresql PostgreSQL community rabbitmq RabbitMQ community 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. labels Feb 6, 2019
Copy link
Member

@nitzmahone nitzmahone left a comment

Choose a reason for hiding this comment

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

one minor formatting thing, otherwise LGTM

lib/ansible/module_utils/basic.py Outdated Show resolved Hide resolved
@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label Feb 6, 2019
@ansibot
Copy link
Contributor

ansibot commented Feb 6, 2019

The test ansible-test sanity --test pylint [explain] failed with 1 error:

lib/ansible/modules/database/mongodb/mongodb_user.py:353:29: undefined-variable Undefined variable 'missing_required_lib'

click here for bot help

@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 Feb 6, 2019
@maxamillion
Copy link
Contributor

maxamillion commented Feb 6, 2019

I'm a big fan of this, I like to see more uniformity in this kind of stuff for UX consistency. 👍

Copy link
Contributor

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

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

I've checked the crypto/acme modules, they look fine.

@samdoran samdoran dismissed nitzmahone’s stale review February 6, 2019 17:38

Requested changes were made.

@samdoran samdoran merged commit 0f0d33a into ansible:devel Feb 6, 2019
@drzraf
Copy link
Contributor

drzraf commented Feb 9, 2019

Note sure this is related to this specific modification, but starting to use missing_required_lib :
$ python3 test/sanity/validate-modules/validate-modules -w --format json lib/ansible/modules/<foo>
(eg: with lib/ansible/modules/source_control/gitlab_project.py)

Results:
Exception attempting to import module for argument_spec introspection, 'cannot import name 'missing_required_lib''


Traceback (most recent call last):
  File \"/ansible/test/sanity/validate-modules/module_args.py\", line 84, in get_argument_spec
    mod = imp.load_source('module', filename)
  File \"/usr/lib/python3.6/imp.py\", line 172, in load_source
    module = _load(spec)
  File \"<frozen importlib._bootstrap>\", line 684, in _load
  File \"<frozen importlib._bootstrap>\", line 665, in _load_unlocked
  File \"<frozen importlib._bootstrap_external>\", line 678, in exec_module
  File \"<frozen importlib._bootstrap>\", line 219, in _call_with_frames_removed
  File \"lib/ansible/modules/<foo>\", line 172, in <module>
    from ansible.module_utils.basic import missing_required_lib
ImportError: cannot import name 'missing_required_lib'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File \"test/sanity/validate-modules/validate-modules\", line 1125, in _validate_ansible_module_call
    spec, args, kwargs = get_argument_spec(self.path)
  File \"ansible/test/sanity/validate-modules/module_args.py\", line 90, in get_argument_spec
    reraise(AnsibleModuleImportError, AnsibleModuleImportError('%s' % e), sys.exc_info()[2])
  File \".local/lib/python3.6/site-packages/ansible/module_utils/six/__init__.py\", line 699, in reraise
    raise value.with_traceback(tb)
  File \"ansible/test/sanity/validate-modules/module_args.py\", line 84, in get_argument_spec
    mod = imp.load_source('module', filename)
  File \"/usr/lib/python3.6/imp.py\", line 172, in load_source
    module = _load(spec)
  File \"<frozen importlib._bootstrap>\", line 684, in _load
  File \"<frozen importlib._bootstrap>\", line 665, in _load_unlocked
  File \"<frozen importlib._bootstrap_external>\", line 678, in exec_module
  File \"<frozen importlib._bootstrap>\", line 219, in _call_with_frames_removed
  File \"lib/ansible/modules/<foo>\", line 172, in <module>
    from ansible.module_utils.basic import missing_required_lib
module_args.AnsibleModuleImportError: cannot import name 'missing_required_lib

@jborean93
Copy link
Contributor Author

@drzraf missing_required_lib was only added in the devel branch and has not been included in a stable release just yet. Going by your traceback it seems like it's looking up an Ansible install in a Python's site-packages so not sure if this is based on devel or an older release.

@dagwieers dagwieers added the database Database category label Feb 13, 2019
@ansible ansible locked and limited conversation to collaborators Jul 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.8 This issue/PR affects Ansible v2.8 database Database category deprecated This issue/PR relates to a deprecated module. feature This issue/PR relates to a feature request. k8s m:xml This issue/PR relates to the xml module. module This issue/PR relates to a module. mongodb MongoDB community needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. postgresql PostgreSQL community rabbitmq RabbitMQ community 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants