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

ansible-test integration: AttributeError docker flag #8683

Closed
1 task done
MatthiasKunnen opened this issue Jul 26, 2024 · 10 comments · Fixed by #8718
Closed
1 task done

ansible-test integration: AttributeError docker flag #8683

MatthiasKunnen opened this issue Jul 26, 2024 · 10 comments · Fixed by #8718
Labels
bug This issue/PR relates to a bug traceback

Comments

@MatthiasKunnen
Copy link
Contributor

MatthiasKunnen commented Jul 26, 2024

Summary

Running ansible-test integration --python 3.12 --docker fedora40 -v locale_gen in the community.general repo results in an error related to the docker flag.

Issue Type

Bug Report

Component Name

ansible-test integration

Ansible Version

ansible [core 2.17.2]
  config file = None
  configured module search path = ['/home/matthias/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.12/site-packages/ansible
  ansible collection location = /home/matthias/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.12.4 (main, Jun  7 2024, 06:33:07) [GCC 14.1.1 20240522] (/usr/bin/python)
  jinja version = 3.1.4
  libyaml = True

Community.general Version

52126b8

Configuration

$ ansible-config dump --only-changed
CONFIG_FILE() = None
PAGER(env: PAGER) = less

OS / Environment

Arch 2024-07-26

Steps to Reproduce

Running ansible-test integration --python 3.12 --docker fedora40 -v locale_gen
Also tried and failed: ubuntu2404.
Works: default.

Sidenote, I also had to specify the python version with --python otherwise I would get FATAL: A Python version was not specified for environment --docker fedora40. Use the --python option to specify a Python version.. I don't know if this is an issue in the first place or a documentation problem.

Expected Results

The documentation at https://docs.ansible.com/ansible/latest/dev_guide/testing_integration.html#id7 states to use this flag with any of the following values:
https://github.com/ansible/ansible/blob/a3a92bcc13d84049fce48ab528aef057246639ff/test/lib/ansible_test/_data/completion/docker.txt

I expect the image to be downloaded and run.

Actual Results

The command fails with:

Configured locale: en_US.UTF-8
RLIMIT_NOFILE: (1024, 524288)
Falling back to tests in "tests/integration/targets/" because "roles/test/" was not found.
Run command: docker -v
Working directory: /home/matthias/projects-3rd/ansible_collections/community/general
Program found: /usr/bin/docker
HOME=/home/matthias
LC_ALL=en_US.UTF-8
PATH=/home/matthias/.local/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin
SSH_AUTH_SOCK=/run/user/1000/gcr/ssh
XDG_RUNTIME_DIR=/run/user/1000
Command exited with status 0 after 0.00677490234375 seconds.
Detected "docker" container runtime version: Docker version 27.1.1, build 63125853e3
Run command: docker info --format '{{ json . }}'
Working directory: /home/matthias/projects-3rd/ansible_collections/community/general
Program found: /usr/bin/docker
HOME=/home/matthias
LC_ALL=en_US.UTF-8
PATH=/home/matthias/.local/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin
SSH_AUTH_SOCK=/run/user/1000/gcr/ssh
XDG_RUNTIME_DIR=/run/user/1000
Command exited with status 0 after 0.023208141326904297 seconds.
Run command: docker version --format '{{ json . }}'
Working directory: /home/matthias/projects-3rd/ansible_collections/community/general
Program found: /usr/bin/docker
HOME=/home/matthias
LC_ALL=en_US.UTF-8
PATH=/home/matthias/.local/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin
SSH_AUTH_SOCK=/run/user/1000/gcr/ssh
XDG_RUNTIME_DIR=/run/user/1000
Command exited with status 0 after 0.009592771530151367 seconds.
Container runtime: docker client=27.1.1 server=27.1.1 cgroup=v2
Assuming Docker is available on localhost.
Skipping pull of image without tag or digest: fedora40
Run command: docker image inspect fedora40
Working directory: /home/matthias/projects-3rd/ansible_collections/community/general
Program found: /usr/bin/docker
HOME=/home/matthias
LC_ALL=en_US.UTF-8
PATH=/home/matthias/.local/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin
SSH_AUTH_SOCK=/run/user/1000/gcr/ssh
XDG_RUNTIME_DIR=/run/user/1000
Command exited with status 1 after 0.006680727005004883 seconds.
Run command: docker image inspect fedora40
Working directory: /home/matthias/projects-3rd/ansible_collections/community/general
Program found: /usr/bin/docker
HOME=/home/matthias
LC_ALL=en_US.UTF-8
PATH=/home/matthias/.local/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin
SSH_AUTH_SOCK=/run/user/1000/gcr/ssh
XDG_RUNTIME_DIR=/run/user/1000
Command exited with status 1 after 0.0064542293548583984 seconds.
ERROR: Host DockerConfig(python=NativePythonConfig(version='3.12', path='/usr/bin/python3.12'), name='fedora40', image='fedora40', memory=None, privileged=False, seccomp='default', cgroup=CGroupVersion.V1_V2, audit=AuditMode.REQUIRED) job failed:
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/ansible_test/_internal/provisioning.py", line 200, in dispatch_jobs
    thread.wait_for_result()
  File "/usr/lib/python3.12/site-packages/ansible_test/_internal/thread.py", line 44, in wait_for_result
    raise exception[1].with_traceback(exception[2])
  File "/usr/lib/python3.12/site-packages/ansible_test/_internal/thread.py", line 34, in run
    self._result.put((self.action(), None))
                      ^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/ansible_test/_internal/provisioning.py", line 134, in provision
    profile.provision()
  File "/usr/lib/python3.12/site-packages/ansible_test/_internal/host_profiles.py", line 465, in provision
    cmd=self.build_init_command(init_config, init_probe),
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/ansible_test/_internal/host_profiles.py", line 825, in build_init_command
    command += f'exec {shlex.join(inspect.cmd)}'
                                  ^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'cmd'
FATAL: Host job(s) failed. See previous error(s) for details.

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibullbot
Copy link
Collaborator

Files identified in the description:
None

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot ansibullbot added bug This issue/PR relates to a bug traceback labels Jul 26, 2024
@Akasurde
Copy link
Member

@MatthiasKunnen I think this will solve your issue.

@Akasurde
Copy link
Member

cc @mattclay

@Akasurde
Copy link
Member

tl;dr -

For 2.17 - Valid images are -

  base (3.12, 3.7, 3.8, 3.9, 3.10, 3.11)
  default (3.12, 3.7, 3.8, 3.9, 3.10, 3.11)
  alpine319 (3.11)
  fedora39 (3.12)
  ubuntu2004 (3.8)
  ubuntu2204 (3.10)

@Akasurde
Copy link
Member

resolved_by_pr ansible/ansible#83677

@MatthiasKunnen
Copy link
Contributor Author

ahhh, yes it does.

I had a look at the PR. It would seem to me like there is still room for improvement. If people see the error and go to https://github.com/ansible/ansible/blob/devel/test/lib/ansible_test/_data/completion/docker.txt as instructed by the documentation, they will end up where I ended up, scratching their head because they are giving one of the options that should work.

Instead, what if the ansible-test command could get a list-images/list-environments flag/command that would print the supported images for the installed version. That way, everything remains in sync. The change in the PR you mentioned could then mention this flag/option.

@felixfontein
Copy link
Collaborator

Generally ansible-test integration --help shows you a lot of information, among them target docker images and supported python version (choose one):. There's no need to consult https://github.com/ansible/ansible/blob/devel/test/lib/ansible_test/_data/completion/docker.txt for the correct branch. (You only need that if you want to see the supported Docker images for an ansible-core version you don't have installed, or if you don't find the information in the very long ansible-test integration --help output :) )

@MatthiasKunnen
Copy link
Contributor Author

MatthiasKunnen commented Jul 26, 2024

Then shouldn't https://docs.ansible.com/ansible/latest/dev_guide/testing_integration.html#id7 be updated to refer to the --help flag? It is that documentation that misinformed me.

Additionally, can't a reference to the --help flag be added to the new error message added in the referenced PRs?

@mattclay
Copy link

That documentation is out-of-date and should instruct the user to use ansible-test integration --help instead of linking to the devel version of the completion file. It was originally written before the available docker images were reported in the help output, and was never updated to reflect the new help behavior introduced in ansible-core 2.12.

@Akasurde
Copy link
Member

You can install argcomplete and do activation then you will be presented with all options like -

Screenshot 2024-07-29 at 10 35 06

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug traceback
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants