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

race condition when linting multiple roles in a collection, leading to errors #3560

Closed
evgeni opened this issue Jun 14, 2023 · 5 comments · Fixed by #3554 or #3563
Closed

race condition when linting multiple roles in a collection, leading to errors #3560

evgeni opened this issue Jun 14, 2023 · 5 comments · Fixed by #3554 or #3563
Assignees
Labels

Comments

@evgeni
Copy link
Contributor

evgeni commented Jun 14, 2023

Summary

When linting multiple roles inside a collection (using smth like ansible-lint -v roles/*), the installations of the collection will race each other, sometimes leading to the linting error out with [Errno 39] Directory not empty, [Errno 17] File exists, [Errno 2] No such file or directory and similar errors from Python.

I've bisected the issue down to

commit 70d244349192858a5743c9ff413072e7a54d6e34
Author: Sorin Sbarnea <ssbarnea@redhat.com>
Date:   Thu Jun 1 14:17:58 2023 +0100

    Ensure that rules collections use Runtime in offline mode (#3526)

 src/ansiblelint/__main__.py       | 4 +++-
 src/ansiblelint/app.py            | 5 +++--
 src/ansiblelint/rules/__init__.py | 2 +-
 3 files changed, 7 insertions(+), 4 deletions(-)

And yes, running things with --offline works, but I think it also should work online?

6.17.0 is fine, 6.17.1 is not.

Issue Type
  • Bug Report
OS / ENVIRONMENT
% ansible-lint --version
ansible-lint 6.17.2.dev2 using ansible-core:2.14.4 ruamel-yaml:0.17.21 ruamel-yaml-clib:None
You are using a pre-release version of ansible-lint.
  • ansible installation method: Fedora 38 package, but also tried pip
  • ansible-lint installation method: source
STEPS TO REPRODUCE
$ git clone https://github.com/evgeni/evgeni.ansiblelintdebug
$ cd evgeni.ansiblelintdebug
$ ansible-lint -v roles/*

Given it's a race condition, it does not 100% reproduce, but running it multiple times (or increasing the number of roles) helps :)

Desired Behavior

It lints the roles ;-)

Actual Behavior
% ansible-lint -v roles/*
INFO     Identified /tmp/evgeni.ansiblelintdebug as project root due .git directory.
INFO     Set ANSIBLE_LIBRARY=/home/evgeni/.cache/ansible-compat/f633fc/modules:/home/evgeni/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
INFO     Set ANSIBLE_COLLECTIONS_PATH=/home/evgeni/.cache/ansible-compat/f633fc/collections:/home/evgeni/.ansible/collections:/usr/share/ansible/collections
INFO     Set ANSIBLE_ROLES_PATH=/home/evgeni/.cache/ansible-compat/f633fc/roles:roles:/home/evgeni/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles
INFO     Set ANSIBLE_LIBRARY=/home/evgeni/.cache/ansible-compat/f633fc/modules:/home/evgeni/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
INFO     Set ANSIBLE_COLLECTIONS_PATH=/home/evgeni/.cache/ansible-compat/f633fc/collections:/home/evgeni/.ansible/collections:/usr/share/ansible/collections
INFO     Set ANSIBLE_ROLES_PATH=/home/evgeni/.cache/ansible-compat/f633fc/roles:roles:/home/evgeni/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles
INFO     Running from /tmp/evgeni.ansiblelintdebug : ansible-galaxy collection install -vvv --force .
INFO     Set ANSIBLE_LIBRARY=/home/evgeni/.cache/ansible-compat/f633fc/modules:/home/evgeni/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
INFO     Set ANSIBLE_COLLECTIONS_PATH=/home/evgeni/.cache/ansible-compat/f633fc/collections:/home/evgeni/.ansible/collections:/usr/share/ansible/collections
INFO     Set ANSIBLE_ROLES_PATH=/home/evgeni/.cache/ansible-compat/f633fc/roles:roles:/home/evgeni/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles
INFO     Running from /tmp/evgeni.ansiblelintdebug : ansible-galaxy collection install -vvv --force .
INFO     Set ANSIBLE_LIBRARY=/home/evgeni/.cache/ansible-compat/f633fc/modules:/home/evgeni/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
INFO     Set ANSIBLE_COLLECTIONS_PATH=/home/evgeni/.cache/ansible-compat/f633fc/collections:/home/evgeni/.ansible/collections:/usr/share/ansible/collections
INFO     Set ANSIBLE_ROLES_PATH=/home/evgeni/.cache/ansible-compat/f633fc/roles:roles:/home/evgeni/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles
INFO     Running from /tmp/evgeni.ansiblelintdebug : ansible-galaxy collection install -vvv --force .
INFO     Set ANSIBLE_LIBRARY=/home/evgeni/.cache/ansible-compat/f633fc/modules:/home/evgeni/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
INFO     Set ANSIBLE_COLLECTIONS_PATH=/home/evgeni/.cache/ansible-compat/f633fc/collections:/home/evgeni/.ansible/collections:/usr/share/ansible/collections
INFO     Set ANSIBLE_LIBRARY=/home/evgeni/.cache/ansible-compat/f633fc/modules:/home/evgeni/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
INFO     Set ANSIBLE_ROLES_PATH=/home/evgeni/.cache/ansible-compat/f633fc/roles:roles:/home/evgeni/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles
INFO     Set ANSIBLE_LIBRARY=/home/evgeni/.cache/ansible-compat/f633fc/modules:/home/evgeni/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
INFO     Set ANSIBLE_COLLECTIONS_PATH=/home/evgeni/.cache/ansible-compat/f633fc/collections:/home/evgeni/.ansible/collections:/usr/share/ansible/collections
INFO     Set ANSIBLE_LIBRARY=/home/evgeni/.cache/ansible-compat/f633fc/modules:/home/evgeni/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
INFO     Set ANSIBLE_COLLECTIONS_PATH=/home/evgeni/.cache/ansible-compat/f633fc/collections:/home/evgeni/.ansible/collections:/usr/share/ansible/collections
INFO     Set ANSIBLE_ROLES_PATH=/home/evgeni/.cache/ansible-compat/f633fc/roles:roles:/home/evgeni/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles
INFO     Set ANSIBLE_LIBRARY=/home/evgeni/.cache/ansible-compat/f633fc/modules:/home/evgeni/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
INFO     Running from /tmp/evgeni.ansiblelintdebug : ansible-galaxy collection install -vvv --force .
INFO     Set ANSIBLE_COLLECTIONS_PATH=/home/evgeni/.cache/ansible-compat/f633fc/collections:/home/evgeni/.ansible/collections:/usr/share/ansible/collections
INFO     Set ANSIBLE_ROLES_PATH=/home/evgeni/.cache/ansible-compat/f633fc/roles:roles:/home/evgeni/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles
INFO     Set ANSIBLE_COLLECTIONS_PATH=/home/evgeni/.cache/ansible-compat/f633fc/collections:/home/evgeni/.ansible/collections:/usr/share/ansible/collections
INFO     Set ANSIBLE_ROLES_PATH=/home/evgeni/.cache/ansible-compat/f633fc/roles:roles:/home/evgeni/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles
INFO     Running from /tmp/evgeni.ansiblelintdebug : ansible-galaxy collection install -vvv --force .
INFO     Set ANSIBLE_ROLES_PATH=/home/evgeni/.cache/ansible-compat/f633fc/roles:roles:/home/evgeni/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles
INFO     Running from /tmp/evgeni.ansiblelintdebug : ansible-galaxy collection install -vvv --force .
INFO     Running from /tmp/evgeni.ansiblelintdebug : ansible-galaxy collection install -vvv --force .
INFO     Running from /tmp/evgeni.ansiblelintdebug : ansible-galaxy collection install -vvv --force .
INFO     Set ANSIBLE_LIBRARY=/home/evgeni/.cache/ansible-compat/f633fc/modules:/home/evgeni/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
INFO     Set ANSIBLE_COLLECTIONS_PATH=/home/evgeni/.cache/ansible-compat/f633fc/collections:/home/evgeni/.ansible/collections:/usr/share/ansible/collections
INFO     Set ANSIBLE_ROLES_PATH=/home/evgeni/.cache/ansible-compat/f633fc/roles:roles:/home/evgeni/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles
INFO     Running from /tmp/evgeni.ansiblelintdebug : ansible-galaxy collection install -vvv --force .
WARNING  Retrying execution failure 250 of: ansible-galaxy collection install -vvv --force .
ERROR    Command returned 250 code:
ansible-galaxy 
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/evgeni/.cache/ansible-compat/f633fc/modules', '/home/evgeni/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible
  ansible collection location = /home/evgeni/.cache/ansible-compat/f633fc/collections:/home/evgeni/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/evgeni/Devel/ansible/ansible-lint/venv/bin/ansible-galaxy
  python version = 3.11.3 (main, May 24 2023, 00:00:00) [GCC 13.1.1 20230511 (Red Hat 13.1.1-2)] (/home/evgeni/Devel/ansible/ansible-lint/venv/bin/python)
  jinja version = 3.1.2
  libyaml = True
Using /etc/ansible/ansible.cfg as config file
Starting galaxy collection install process
Found installed collection evgeni.ansiblelintdebug:1.0.0 at '/home/evgeni/.cache/ansible-compat/f633fc/collections/ansible_collections/evgeni/ansiblelintdebug'
Process install dependency map
Starting collection install process
Installing 'evgeni.ansiblelintdebug:1.0.0' to '/home/evgeni/.cache/ansible-compat/f633fc/collections/ansible_collections/evgeni/ansiblelintdebug'
the full traceback was:

Traceback (most recent call last):
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/cli/__init__.py", line 647, in cli_executor
    exit_code = cli.run()
                ^^^^^^^^^
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/cli/galaxy.py", line 714, in run
    return context.CLIARGS['func']()
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/cli/galaxy.py", line 115, in method_wrapper
    return wrapped_method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/cli/galaxy.py", line 1363, in execute_install
    self._execute_install_collection(
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/cli/galaxy.py", line 1400, in _execute_install_collection
    install_collections(
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/galaxy/collection/__init__.py", line 771, in install_collections
    install(concrete_coll_pin, output_path, artifacts_manager)
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/galaxy/collection/__init__.py", line 1443, in install
    shutil.rmtree(b_collection_path)
  File "/usr/lib64/python3.11/shutil.py", line 732, in rmtree
    _rmtree_safe_fd(fd, path, onerror)
  File "/usr/lib64/python3.11/shutil.py", line 660, in _rmtree_safe_fd
    _rmtree_safe_fd(dirfd, fullname, onerror)
  File "/usr/lib64/python3.11/shutil.py", line 660, in _rmtree_safe_fd
    _rmtree_safe_fd(dirfd, fullname, onerror)
  File "/usr/lib64/python3.11/shutil.py", line 666, in _rmtree_safe_fd
    onerror(os.rmdir, fullname, sys.exc_info())
  File "/usr/lib64/python3.11/shutil.py", line 664, in _rmtree_safe_fd
    os.rmdir(entry.name, dir_fd=topfd)
FileNotFoundError: [Errno 2] No such file or directory: 'tasks'

ERROR! Unexpected Exception, this is probably a bug: [Errno 2] No such file or directory: 'tasks'

INFO     Executing syntax check on role roles/lol7 (1.62s)
WARNING  Retrying execution failure 250 of: ansible-galaxy collection install -vvv --force .
ERROR    Command returned 250 code:
ansible-galaxy 
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/evgeni/.cache/ansible-compat/f633fc/modules', '/home/evgeni/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible
  ansible collection location = /home/evgeni/.cache/ansible-compat/f633fc/collections:/home/evgeni/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/evgeni/Devel/ansible/ansible-lint/venv/bin/ansible-galaxy
  python version = 3.11.3 (main, May 24 2023, 00:00:00) [GCC 13.1.1 20230511 (Red Hat 13.1.1-2)] (/home/evgeni/Devel/ansible/ansible-lint/venv/bin/python)
  jinja version = 3.1.2
  libyaml = True
Using /etc/ansible/ansible.cfg as config file
Starting galaxy collection install process
Found installed collection evgeni.ansiblelintdebug:1.0.0 at '/home/evgeni/.cache/ansible-compat/f633fc/collections/ansible_collections/evgeni/ansiblelintdebug'
Process install dependency map
Starting collection install process
Installing 'evgeni.ansiblelintdebug:1.0.0' to '/home/evgeni/.cache/ansible-compat/f633fc/collections/ansible_collections/evgeni/ansiblelintdebug'
Skipping './galaxy.yml' for collection build
Skipping './.git' for collection build
the full traceback was:

Traceback (most recent call last):
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/cli/__init__.py", line 647, in cli_executor
    exit_code = cli.run()
                ^^^^^^^^^
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/cli/galaxy.py", line 714, in run
    return context.CLIARGS['func']()
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/cli/galaxy.py", line 115, in method_wrapper
    return wrapped_method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/cli/galaxy.py", line 1363, in execute_install
    self._execute_install_collection(
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/cli/galaxy.py", line 1400, in _execute_install_collection
    install_collections(
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/galaxy/collection/__init__.py", line 771, in install_collections
    install(concrete_coll_pin, output_path, artifacts_manager)
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/galaxy/collection/__init__.py", line 1446, in install
    install_src(collection, b_artifact_path, b_collection_path, artifacts_manager)
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/galaxy/collection/__init__.py", line 1582, in install_src
    collection_output_path = _build_collection_dir(
                             ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/galaxy/collection/__init__.py", line 1362, in _build_collection_dir
    with open(b_path, 'wb') as file_obj, BytesIO(b) as b_io:
         ^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: b'/home/evgeni/.cache/ansible-compat/f633fc/collections/ansible_collections/evgeni/ansiblelintdebug/MANIFEST.json'

ERROR! Unexpected Exception, this is probably a bug: [Errno 2] No such file or directory: b'/home/evgeni/.cache/ansible-compat/f633fc/collections/ansible_collections/evgeni/ansiblelintdebug/MANIFEST.json'

WARNING  Retrying execution failure 250 of: ansible-galaxy collection install -vvv --force .
ERROR    Command returned 250 code:
ansible-galaxy 
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/evgeni/.cache/ansible-compat/f633fc/modules', '/home/evgeni/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible
  ansible collection location = /home/evgeni/.cache/ansible-compat/f633fc/collections:/home/evgeni/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/evgeni/Devel/ansible/ansible-lint/venv/bin/ansible-galaxy
  python version = 3.11.3 (main, May 24 2023, 00:00:00) [GCC 13.1.1 20230511 (Red Hat 13.1.1-2)] (/home/evgeni/Devel/ansible/ansible-lint/venv/bin/python)
  jinja version = 3.1.2
  libyaml = True
Using /etc/ansible/ansible.cfg as config file
Starting galaxy collection install process
Found installed collection evgeni.ansiblelintdebug:* at '/home/evgeni/.cache/ansible-compat/f633fc/collections/ansible_collections/evgeni/ansiblelintdebug'
Process install dependency map
Starting collection install process
Installing 'evgeni.ansiblelintdebug:1.0.0' to '/home/evgeni/.cache/ansible-compat/f633fc/collections/ansible_collections/evgeni/ansiblelintdebug'
Skipping './galaxy.yml' for collection build
Skipping './.git' for collection build
the full traceback was:

Traceback (most recent call last):
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/cli/__init__.py", line 647, in cli_executor
    exit_code = cli.run()
                ^^^^^^^^^
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/cli/galaxy.py", line 714, in run
    return context.CLIARGS['func']()
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/cli/galaxy.py", line 115, in method_wrapper
    return wrapped_method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/cli/galaxy.py", line 1363, in execute_install
    self._execute_install_collection(
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/cli/galaxy.py", line 1400, in _execute_install_collection
    install_collections(
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/galaxy/collection/__init__.py", line 771, in install_collections
    install(concrete_coll_pin, output_path, artifacts_manager)
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/galaxy/collection/__init__.py", line 1446, in install
    install_src(collection, b_artifact_path, b_collection_path, artifacts_manager)
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/galaxy/collection/__init__.py", line 1582, in install_src
    collection_output_path = _build_collection_dir(
                             ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/galaxy/collection/__init__.py", line 1353, in _build_collection_dir
    os.makedirs(b_collection_output, mode=0o0755)
  File "<frozen os>", line 225, in makedirs
FileExistsError: [Errno 17] File exists: b'/home/evgeni/.cache/ansible-compat/f633fc/collections/ansible_collections/evgeni/ansiblelintdebug'

[WARNING]: Collection at '/home/evgeni/.cache/ansible-
compat/f633fc/collections/ansible_collections/evgeni/ansiblelintdebug' does not
have a MANIFEST.json file, nor has it galaxy.yml: cannot detect version.
ERROR! Unexpected Exception, this is probably a bug: [Errno 17] File exists: b'/home/evgeni/.cache/ansible-compat/f633fc/collections/ansible_collections/evgeni/ansiblelintdebug'

INFO     Executing syntax check on role roles/lol8 (1.63s)
WARNING  Retrying execution failure 250 of: ansible-galaxy collection install -vvv --force .
ERROR    Command returned 250 code:
ansible-galaxy 
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/evgeni/.cache/ansible-compat/f633fc/modules', '/home/evgeni/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible
  ansible collection location = /home/evgeni/.cache/ansible-compat/f633fc/collections:/home/evgeni/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/evgeni/Devel/ansible/ansible-lint/venv/bin/ansible-galaxy
  python version = 3.11.3 (main, May 24 2023, 00:00:00) [GCC 13.1.1 20230511 (Red Hat 13.1.1-2)] (/home/evgeni/Devel/ansible/ansible-lint/venv/bin/python)
  jinja version = 3.1.2
  libyaml = True
Using /etc/ansible/ansible.cfg as config file
Starting galaxy collection install process
Process install dependency map
Starting collection install process
Installing 'evgeni.ansiblelintdebug:1.0.0' to '/home/evgeni/.cache/ansible-compat/f633fc/collections/ansible_collections/evgeni/ansiblelintdebug'
Skipping './galaxy.yml' for collection build
Skipping './.git' for collection build
the full traceback was:

Traceback (most recent call last):
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/cli/__init__.py", line 647, in cli_executor
    exit_code = cli.run()
                ^^^^^^^^^
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/cli/galaxy.py", line 714, in run
    return context.CLIARGS['func']()
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/cli/galaxy.py", line 115, in method_wrapper
    return wrapped_method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/cli/galaxy.py", line 1363, in execute_install
    self._execute_install_collection(
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/cli/galaxy.py", line 1400, in _execute_install_collection
    install_collections(
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/galaxy/collection/__init__.py", line 771, in install_collections
    install(concrete_coll_pin, output_path, artifacts_manager)
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/galaxy/collection/__init__.py", line 1446, in install
    install_src(collection, b_artifact_path, b_collection_path, artifacts_manager)
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/galaxy/collection/__init__.py", line 1582, in install_src
    collection_output_path = _build_collection_dir(
                             ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/galaxy/collection/__init__.py", line 1353, in _build_collection_dir
    os.makedirs(b_collection_output, mode=0o0755)
  File "<frozen os>", line 225, in makedirs
FileExistsError: [Errno 17] File exists: b'/home/evgeni/.cache/ansible-compat/f633fc/collections/ansible_collections/evgeni/ansiblelintdebug'

ERROR! Unexpected Exception, this is probably a bug: [Errno 17] File exists: b'/home/evgeni/.cache/ansible-compat/f633fc/collections/ansible_collections/evgeni/ansiblelintdebug'

INFO     Executing syntax check on role roles/lol1 (1.63s)
INFO     Executing syntax check on role roles/domains (1.64s)
WARNING  Retrying execution failure 250 of: ansible-galaxy collection install -vvv --force .
ERROR    Command returned 250 code:
ansible-galaxy 
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/evgeni/.cache/ansible-compat/f633fc/modules', '/home/evgeni/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible
  ansible collection location = /home/evgeni/.cache/ansible-compat/f633fc/collections:/home/evgeni/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/evgeni/Devel/ansible/ansible-lint/venv/bin/ansible-galaxy
  python version = 3.11.3 (main, May 24 2023, 00:00:00) [GCC 13.1.1 20230511 (Red Hat 13.1.1-2)] (/home/evgeni/Devel/ansible/ansible-lint/venv/bin/python)
  jinja version = 3.1.2
  libyaml = True
Using /etc/ansible/ansible.cfg as config file
Starting galaxy collection install process
Found installed collection evgeni.ansiblelintdebug:1.0.0 at '/home/evgeni/.cache/ansible-compat/f633fc/collections/ansible_collections/evgeni/ansiblelintdebug'
Process install dependency map
Starting collection install process
Installing 'evgeni.ansiblelintdebug:1.0.0' to '/home/evgeni/.cache/ansible-compat/f633fc/collections/ansible_collections/evgeni/ansiblelintdebug'
the full traceback was:

Traceback (most recent call last):
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/cli/__init__.py", line 647, in cli_executor
    exit_code = cli.run()
                ^^^^^^^^^
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/cli/galaxy.py", line 714, in run
    return context.CLIARGS['func']()
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/cli/galaxy.py", line 115, in method_wrapper
    return wrapped_method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/cli/galaxy.py", line 1363, in execute_install
    self._execute_install_collection(
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/cli/galaxy.py", line 1400, in _execute_install_collection
    install_collections(
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/galaxy/collection/__init__.py", line 771, in install_collections
    install(concrete_coll_pin, output_path, artifacts_manager)
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/galaxy/collection/__init__.py", line 1443, in install
    shutil.rmtree(b_collection_path)
  File "/usr/lib64/python3.11/shutil.py", line 732, in rmtree
    _rmtree_safe_fd(fd, path, onerror)
  File "/usr/lib64/python3.11/shutil.py", line 660, in _rmtree_safe_fd
    _rmtree_safe_fd(dirfd, fullname, onerror)
  File "/usr/lib64/python3.11/shutil.py", line 649, in _rmtree_safe_fd
    onerror(os.lstat, fullname, sys.exc_info())
  File "/usr/lib64/python3.11/shutil.py", line 646, in _rmtree_safe_fd
    orig_st = entry.stat(follow_symlinks=False)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'lol8'

ERROR! Unexpected Exception, this is probably a bug: [Errno 2] No such file or directory: 'lol8'

INFO     Executing syntax check on role roles/lol5 (1.64s)
INFO     Set ANSIBLE_LIBRARY=/home/evgeni/.cache/ansible-compat/f633fc/modules:/home/evgeni/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
INFO     Set ANSIBLE_COLLECTIONS_PATH=/home/evgeni/.cache/ansible-compat/f633fc/collections:/home/evgeni/.ansible/collections:/usr/share/ansible/collections
INFO     Set ANSIBLE_ROLES_PATH=/home/evgeni/.cache/ansible-compat/f633fc/roles:roles:/home/evgeni/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles
INFO     Running from /tmp/evgeni.ansiblelintdebug : ansible-galaxy collection install -vvv --force .
INFO     Set ANSIBLE_LIBRARY=/home/evgeni/.cache/ansible-compat/f633fc/modules:/home/evgeni/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
INFO     Set ANSIBLE_COLLECTIONS_PATH=/home/evgeni/.cache/ansible-compat/f633fc/collections:/home/evgeni/.ansible/collections:/usr/share/ansible/collections
INFO     Set ANSIBLE_ROLES_PATH=/home/evgeni/.cache/ansible-compat/f633fc/roles:roles:/home/evgeni/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles
INFO     Running from /tmp/evgeni.ansiblelintdebug : ansible-galaxy collection install -vvv --force .
INFO     Set ANSIBLE_LIBRARY=/home/evgeni/.cache/ansible-compat/f633fc/modules:/home/evgeni/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
INFO     Set ANSIBLE_COLLECTIONS_PATH=/home/evgeni/.cache/ansible-compat/f633fc/collections:/home/evgeni/.ansible/collections:/usr/share/ansible/collections
INFO     Set ANSIBLE_ROLES_PATH=/home/evgeni/.cache/ansible-compat/f633fc/roles:roles:/home/evgeni/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles
INFO     Running from /tmp/evgeni.ansiblelintdebug : ansible-galaxy collection install -vvv --force .
INFO     Executing syntax check on role roles/lol6 (4.61s)
INFO     Executing syntax check on role roles/lol10 (4.70s)
INFO     Executing syntax check on role roles/lol4 (4.78s)
INFO     Executing syntax check on role roles/lol2 (5.87s)
INFO     Executing syntax check on role roles/lol3 (6.04s)
INFO     Executing syntax check on role roles/lol9 (6.17s)
Command returned 250 code:
ansible-galaxy [core 2.14.4]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/evgeni/.cache/ansible-compat/f633fc/modules', '/home/evgeni/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible
  ansible collection location = /home/evgeni/.cache/ansible-compat/f633fc/collections:/home/evgeni/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/evgeni/Devel/ansible/ansible-lint/venv/bin/ansible-galaxy
  python version = 3.11.3 (main, May 24 2023, 00:00:00) [GCC 13.1.1 20230511 (Red Hat 13.1.1-2)] (/home/evgeni/Devel/ansible/ansible-lint/venv/bin/python)
  jinja version = 3.1.2
  libyaml = True
Using /etc/ansible/ansible.cfg as config file
Starting galaxy collection install process
Found installed collection evgeni.ansiblelintdebug:1.0.0 at '/home/evgeni/.cache/ansible-compat/f633fc/collections/ansible_collections/evgeni/ansiblelintdebug'
Process install dependency map
Starting collection install process
Installing 'evgeni.ansiblelintdebug:1.0.0' to '/home/evgeni/.cache/ansible-compat/f633fc/collections/ansible_collections/evgeni/ansiblelintdebug'
the full traceback was:

Traceback (most recent call last):
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/cli/__init__.py", line 647, in cli_executor
    exit_code = cli.run()
                ^^^^^^^^^
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/cli/galaxy.py", line 714, in run
    return context.CLIARGS['func']()
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/cli/galaxy.py", line 115, in method_wrapper
    return wrapped_method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/cli/galaxy.py", line 1363, in execute_install
    self._execute_install_collection(
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/cli/galaxy.py", line 1400, in _execute_install_collection
    install_collections(
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/galaxy/collection/__init__.py", line 771, in install_collections
    install(concrete_coll_pin, output_path, artifacts_manager)
  File "/home/evgeni/Devel/ansible/ansible-lint/venv/lib64/python3.11/site-packages/ansible/galaxy/collection/__init__.py", line 1443, in install
    shutil.rmtree(b_collection_path)
  File "/usr/lib64/python3.11/shutil.py", line 732, in rmtree
    _rmtree_safe_fd(fd, path, onerror)
  File "/usr/lib64/python3.11/shutil.py", line 660, in _rmtree_safe_fd
    _rmtree_safe_fd(dirfd, fullname, onerror)
  File "/usr/lib64/python3.11/shutil.py", line 660, in _rmtree_safe_fd
    _rmtree_safe_fd(dirfd, fullname, onerror)
  File "/usr/lib64/python3.11/shutil.py", line 666, in _rmtree_safe_fd
    onerror(os.rmdir, fullname, sys.exc_info())
  File "/usr/lib64/python3.11/shutil.py", line 664, in _rmtree_safe_fd
    os.rmdir(entry.name, dir_fd=topfd)
FileNotFoundError: [Errno 2] No such file or directory: 'tasks'

ERROR! Unexpected Exception, this is probably a bug: [Errno 2] No such file or directory: 'tasks'

ansible-lint -v roles/*  36.88s user 3.18s system 402% cpu 9.960 total
@evgeni evgeni added bug new Triage required labels Jun 14, 2023
evgeni added a commit to evgeni/foreman-ansible-modules that referenced this issue Jun 14, 2023
@gone-for-coding
Copy link

I can confirm the issue. --offline is working fine.

evgeni added a commit to evgeni/foreman-ansible-modules that referenced this issue Jun 14, 2023
evgeni added a commit to theforeman/foreman-ansible-modules that referenced this issue Jun 14, 2023
@ssbarnea ssbarnea self-assigned this Jun 14, 2023
@ssbarnea
Copy link
Member

That bug is likely caused by a reinitialization of the application due to wrong use of get_app() with different parameters. I will work on fixing it as that bit of code really needs rework.

@ssbarnea
Copy link
Member

If one of those affected can test #3563 on their repo and report if it fixes it, it would be quite useful, especially as I did not know how to write a test for this bug.

@sean-m-sullivan
Copy link

sean-m-sullivan commented Jun 14, 2023

ssbarnea added a commit that referenced this issue Jun 15, 2023
@gone-for-coding
Copy link

If one of those affected can test #3563 on their repo and report if it fixes it, it would be quite useful, especially as I did not know how to write a test for this bug.

I just ran the test. There are no more exceptions, but it fells like running slower.

Running the new version. Looks like the install process happens twice?

root@188c3d0695e6:/code# ansible-lint -vvv
DEBUG    Logging initialized to level 10
INFO     Identified /code as project root due .git directory.
DEBUG    Options: Options(cache_dir=PosixPath('/root/.cache/ansible-compat/5694d0'), colored=True, configured=True, cwd=PosixPath('/code'), display_relative_path=True, exclude_paths=['.cache/', 'ewert.yml', 'inventories/az'], format=None, lintables=[], list_rules=False, list_tags=False, write_list=[], parseable=False, quiet=False, rulesdirs=[PosixPath('/usr/local/lib/python3.11/site-packages/ansiblelint/rules')], skip_list=['var-naming', 'key-order', 'galaxy', 'name'], tags=[], verbosity=3, warn_list=['experimental', 'jinja', 'fqcn'], mock_filters=[], mock_modules=[], mock_roles=[], loop_var_prefix=None, only_builtins_allow_collections=[], only_builtins_allow_modules=[], var_naming_pattern=None, offline=False, project_dir='.', extra_vars=None, enable_list=[], skip_action_validation=True, strict=False, rules={}, profile=None, task_name_prefix='{stem} | ', sarif_file=None, config_file='/code/.ansible-lint', generate_ignore=False, rulesdir=[], cache_dir_lock=<filelock._unix.UnixFileLock object at 0x7fbcd1b4b150>, use_default_rules=False, version=False, list_profiles=False, ignore_file=None)
DEBUG    CWD: /code
INFO     Provisioning collection ansible.windows:>=1.9.0 from galaxy.yml
INFO     Running from /code : ansible-galaxy collection install -vvv ansible.windows:>=1.9.0
INFO     Provisioning collection community.windows:>=1.9.0 from galaxy.yml
INFO     Running from /code : ansible-galaxy collection install -vvv community.windows:>=1.9.0
INFO     Provisioning collection community.general:>=4.3.0 from galaxy.yml
INFO     Running from /code : ansible-galaxy collection install -vvv community.general:>=4.3.0
INFO     Set ANSIBLE_LIBRARY=/root/.cache/ansible-compat/5694d0/modules:plugins/modules:/root/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
INFO     Set ANSIBLE_COLLECTIONS_PATH=/root/.cache/ansible-compat/5694d0/collections:/root/.ansible/collections:/usr/share/ansible/collections
INFO     Set ANSIBLE_ROLES_PATH=/root/.cache/ansible-compat/5694d0/roles:roles:/root/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles
DEBUG    Effective yamllint rules used: {'anchors': {'level': 'error', 'forbid-undeclared-aliases': True, 'forbid-duplicated-anchors': False, 'forbid-unused-anchors': False}, 'braces': {'level': 'error', 'forbid': False, 'min-spaces-inside': 0, 'max-spaces-inside': 1, 'min-spaces-inside-empty': -1, 'max-spaces-inside-empty': -1}, 'brackets': {'level': 'error', 'forbid': False, 'min-spaces-inside': 0, 'max-spaces-inside': 0, 'min-spaces-inside-empty': -1, 'max-spaces-inside-empty': -1}, 'colons': {'level': 'error', 'max-spaces-before': 0, 'max-spaces-after': 1}, 'commas': {'level': 'error', 'max-spaces-before': 0, 'min-spaces-after': 1, 'max-spaces-after': 1}, 'comments': {'level': 'warning', 'require-starting-space': True, 'ignore-shebangs': True, 'min-spaces-from-content': 1}, 'comments-indentation': False, 'document-end': False, 'document-start': False, 'empty-lines': {'level': 'error', 'max': 2, 'max-start': 0, 'max-end': 0}, 'empty-values': False, 'float-values': False, 'hyphens': {'level': 'error', 'max-spaces-after': 1}, 'indentation': {'level': 'error', 'spaces': 'consistent', 'indent-sequences': True, 'check-multi-line-strings': False}, 'key-duplicates': {'level': 'error'}, 'key-ordering': False, 'line-length': {'level': 'error', 'max': 160, 'allow-non-breakable-words': True, 'allow-non-breakable-inline-mappings': False}, 'new-line-at-end-of-file': {'level': 'error'}, 'new-lines': {'level': 'error', 'type': 'unix'}, 'octal-values': {'forbid-implicit-octal': True, 'forbid-explicit-octal': True, 'level': 'error'}, 'quoted-strings': False, 'trailing-spaces': {'level': 'error'}, 'truthy': {'level': 'warning', 'allowed-values': ['true', 'false'], 'check-keys': True}}
INFO     Provisioning collection ansible.windows:>=1.9.0 from galaxy.yml
INFO     Running from /code : ansible-galaxy collection install -vvv ansible.windows:>=1.9.0
INFO     Provisioning collection community.windows:>=1.9.0 from galaxy.yml
INFO     Running from /code : ansible-galaxy collection install -vvv community.windows:>=1.9.0
INFO     Provisioning collection community.general:>=4.3.0 from galaxy.yml
INFO     Running from /code : ansible-galaxy collection install -vvv community.general:>=4.3.0
INFO     Set ANSIBLE_LIBRARY=/root/.cache/ansible-compat/5694d0/modules:plugins/modules:/root/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
INFO     Set ANSIBLE_COLLECTIONS_PATH=/root/.cache/ansible-compat/5694d0/collections:/root/.ansible/collections:/usr/share/ansible/collections
INFO     Set ANSIBLE_ROLES_PATH=/root/.cache/ansible-compat/5694d0/roles:roles:/root/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles
INFO     Running from /code : ansible-galaxy collection install -vvv --force .
INFO     Loading ignores from .gitignore
INFO     Excluded: .git
INFO     Excluded: ansible.cfg
DEBUG    Passed '.gitlab-ci.yml' positional argument was identified as generic 'yaml' file kind.
DEBUG    Passed '.pre-commit-config.yaml' positional argument was identified as generic 'yaml' file kind.
...

Compared to running 6.15 it feels a bit slower though:

6.15

root@49293032de4d:/code# time ansible-lint
Passed with production profile: 0 failure(s), 0 warning(s) on 242 files.
A new release of ansible-lint is available: 6.15.0 → 6.17.1

real    0m10.378s
user    0m33.067s
sys     0m2.312s

fix/offline

root@188c3d0695e6:/code# time ansible-lint
Passed: 0 failure(s), 0 warning(s) on 243 files. Last profile that met the validation criteria was 'production'.
You are using a pre-release version of ansible-lint.

real    0m17.639s
user    0m32.838s
sys     0m2.044s

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