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

check-missing-ansible.py raises error during packaging when building #1871

Closed
kpinc opened this issue Feb 11, 2022 · 5 comments
Closed

check-missing-ansible.py raises error during packaging when building #1871

kpinc opened this issue Feb 11, 2022 · 5 comments
Assignees
Labels

Comments

@kpinc
Copy link

kpinc commented Feb 11, 2022

Summary

An assertation error is raised by tools/check-missing-ansible.py during the packaging step.
The OS setup is such that ansible, ansible-lint, etc. is not installed in the OS.

Issue Type
  • Bug Report
Ansible and Ansible Lint details

This is against main/HEAD commit 99f88e1.

$ .tox/py39-core/bin/ansible --version
ansible [core 2.12.2]
  config file = None
  configured module search path = ['/home/kop/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/kop/projects/ansible/ansible-lint-head/.tox/py39-core/lib/python3.9/site-packages/ansible
  ansible collection location = /home/kop/.ansible/collections:/usr/share/ansible/collections
  executable location = .tox/py39-core/bin/ansible
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]
  jinja version = 3.0.3
  libyaml = True

ansible-lint --version fails, but running in another venv gets results.
Both output is below:

$ .tox/py39-core/bin/ansible-lint --version
Traceback (most recent call last):
  File "/home/kop/projects/ansible/ansible-lint-head/.tox/py39-core/bin/ansible-lint", line 33, in <module>
    sys.exit(load_entry_point('ansible-lint', 'console_scripts', 'ansible-lint')())
  File "/home/kop/projects/ansible/ansible-lint-head/.tox/py39-core/bin/ansible-lint", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/usr/lib/python3.9/importlib/metadata.py", line 77, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/home/kop/projects/ansible/ansible-lint-head/src/ansiblelint/__main__.py", line 35, in <module>
    from ansiblelint import cli
  File "/home/kop/projects/ansible/ansible-lint-head/src/ansiblelint/cli.py", line 13, in <module>
    from ansiblelint.config import DEFAULT_KINDS
  File "/home/kop/projects/ansible/ansible-lint-head/src/ansiblelint/config.py", line 167, in <module>
    if ansible_collections_path() in os.environ:
  File "/home/kop/projects/ansible/ansible-lint-head/src/ansiblelint/config.py", line 117, in ansible_collections_path
    if ansible_version() >= ansible_version("2.10.0.dev0"):
  File "/home/kop/projects/ansible/ansible-lint-head/src/ansiblelint/config.py", line 146, in ansible_version
    proc = subprocess.run(
  File "/usr/lib/python3.9/subprocess.py", line 505, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.9/subprocess.py", line 1823, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'ansible'

The following venv is identical, but is patched per pull request #1866 to support running ansible-lint without activation of a venv.

$ .tox/py39-core/bin/ansible-lint --version
ansible-lint 5.3.3.dev33 using ansible 2.12.2
  • ansible installation method: pip (via tox created venv)
  • ansible-lint installation method: pip (via tox created package from source in a tox created venv)
OS / ENVIRONMENT

Debian stable (bullseye, 11.2)
Python 3.9.2

Note that none of the OS ansible packages (ansible, ansible-lint, etc) are installed. There is no ansible in the OS.

STEPS TO REPRODUCE
virtualenv -p venv
git clone https://github.com/ansible-community/ansible-lint.git
cd ansible-lint
../venv/bin/tox
Desired Behaviour

Should not raise an error. Possibly, should expect a errno of 2 instead of/in addition to 4.

Actual Behaviour

Produces the following output

packaging run-test: commands[4] | /home/kop/projects/ansible/ansible-lint-head/.tox/packaging/bin/python tools/check-missing-ansible.py
Traceback (most recent call last):
  File "/home/kop/projects/ansible/ansible-lint-head/tools/check-missing-ansible.py", line 15, in <module>
    assert result.returncode == 4, result  # missing ansible
AssertionError: CompletedProcess(args=['ansible-lint', '--version'], returncode=1, stdout='', stderr='Traceback (most recent call last):\n  File "/home/kop/projects/ansible/ansible-lint-head/.tox/packaging/bin/ansible-lint", line 5, in <module>\n    from ansiblelint.__main__ import _run_cli_entrypoint\n  File "/home/kop/projects/ansible/ansible-lint-head/.tox/packaging/lib/python3.9/site-packages/ansiblelint/__main__.py", line 35, in <module>\n    from ansiblelint import cli\n  File "/home/kop/projects/ansible/ansible-lint-head/.tox/packaging/lib/python3.9/site-packages/ansiblelint/cli.py", line 13, in <module>\n    from ansiblelint.config import DEFAULT_KINDS\n  File "/home/kop/projects/ansible/ansible-lint-head/.tox/packaging/lib/python3.9/site-packages/ansiblelint/config.py", line 167, in <module>\n    if ansible_collections_path() in os.environ:\n  File "/home/kop/projects/ansible/ansible-lint-head/.tox/packaging/lib/python3.9/site-packages/ansiblelint/config.py", line 117, in ansible_collections_path\n    if ansible_version() >= ansible_version("2.10.0.dev0"):\n  File "/home/kop/projects/ansible/ansible-lint-head/.tox/packaging/lib/python3.9/site-packages/ansiblelint/config.py", line 146, in ansible_version\n    proc = subprocess.run(\n  File "/usr/lib/python3.9/subprocess.py", line 505, in run\n    with Popen(*popenargs, **kwargs) as process:\n  File "/usr/lib/python3.9/subprocess.py", line 951, in __init__\n    self._execute_child(args, executable, preexec_fn, close_fds,\n  File "/usr/lib/python3.9/subprocess.py", line 1823, in _execute_child\n    raise child_exception_type(errno_num, err_msg, err_filename)\nFileNotFoundError: [Errno 2] No such file or directory: \'ansible\'\n')
@kpinc kpinc added bug new Triage required labels Feb 11, 2022
@ssbarnea ssbarnea removed the new Triage required label Feb 12, 2022
@ssbarnea ssbarnea self-assigned this Feb 12, 2022
@ssbarnea
Copy link
Member

I am considering removing this test completely as as v6 will make ansible-core a direct dependency, avoiding such problems.

@kpinc
Copy link
Author

kpinc commented Feb 12, 2022 via email

@ssbarnea
Copy link
Member

Since yesterday we test exactly that https://github.com/ansible-community/ansible-lint/blob/main/test/test_main.py#L10-L33

Yes, ansible-core installs ~10 scripts. I will keep this bug open until I finish adding ansible-core as dependency as I doubt we would need it after. It was a bit of a hack for me to add the extra command on tox.ini and I think it is no longer needed.

@ssbarnea
Copy link
Member

Please check with master branch as we already removed check-missing-ansible.py

@kpinc
Copy link
Author

kpinc commented Feb 13, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants