ansible / ansible-builder

An Ansible execution environment builder
Other
289 stars 93 forks source link

unexpected error when getting available versions of collection... community.general #638

Closed ryeleo closed 8 months ago

ryeleo commented 8 months ago

Thanks y'all for this ansible-builder project!

I'm guessing I may have done some something quirky now that I've ended up with the following error as I try to build a pretty simple project: [WARNING]: Skipping Galaxy server https://galaxy.ansible.com/api/. Got an unexpected error when getting available versions of collection....

β„Ή I'm actually seen this error for each/both of the following collections (depending on which one I have commented out):

  • comminty.general
  • junipernetworks.junos

ansible.posix seems to be working great though!

My execution-environment.yml file:

---
version: 3

dependencies:
  galaxy: requirements.yml

additional_build_steps:
  prepend: |
    RUN pip3 install --upgrade pip setuptools

My requirements.yml file:

---
collections:
  - name: ansible.posix
  - name: community.general
    version: "7.5.3"  # Quoted to ensure a string (and not a float)
  # - name: junipernetworks.junos
  #   version: "<6"

My full command with output:

[Pipeline] sh
+ ansible-builder build -v3 -t ntsjenkins/junos-ansible-ansible-execution-env:b3ce96c7a596aa5a918573662e97885e32b5d526 -t ntsjenkins/junos-ansible-ansible-execution-env:latest -t ntsjenkins/junos-ansible-ansible-execution-env:0 -t ntsjenkins/junos-ansible-ansible-execution-env:0.1 -t ntsjenkins/junos-ansible-ansible-execution-env:0.1.2
Ansible Builder is building your execution environment image. Tags: ntsjenkins/junos-ansible-ansible-execution-env:b3ce96c7a596aa5a918573662e97885e32b5d526, ntsjenkins/junos-ansible-ansible-execution-env:latest, ntsjenkins/junos-ansible-ansible-execution-env:0, ntsjenkins/junos-ansible-ansible-execution-env:0.1, ntsjenkins/junos-ansible-ansible-execution-env:0.1.2
File context/_build/requirements.yml will be created.
File context/_build/requirements.txt will be created.
Rewriting Containerfile to capture collection requirements
Running command:
  docker build -f context/Dockerfile -t ntsjenkins/junos-ansible-ansible-execution-env:b3ce96c7a596aa5a918573662e97885e32b5d526 -t ntsjenkins/junos-ansible-ansible-execution-env:latest -t ntsjenkins/junos-ansible-ansible-execution-env:0 -t ntsjenkins/junos-ansible-ansible-execution-env:0.1 -t ntsjenkins/junos-ansible-ansible-execution-env:0.1.2 context
#0 building with "default" instance using docker driver

#1 [internal] load .dockerignore
#1 transferring context: 2B done
#1 DONE 0.0s

#2 [internal] load build definition from Dockerfile
#2 transferring dockerfile: 1.23kB done
#2 DONE 0.0s

#3 [internal] load metadata for quay.io/ansible/ansible-runner:latest
#3 DONE 0.4s

#4 [internal] load metadata for quay.io/ansible/ansible-builder:latest
#4 DONE 0.3s

#5 [builder 1/5] FROM quay.io/ansible/ansible-builder:latest@sha256:75c4e4b5be6aab3386381b1e202ad382002f6830fd4b524bcd5ddc718e4f6a89
#5 DONE 0.0s

#6 [stage-2 1/5] FROM quay.io/ansible/ansible-runner:latest@sha256:001a4bde411be863d54c1d293f3d2e7b0ff0e67ef5d7b2f9f7fb56b61694f4e8
#6 DONE 0.0s

#7 [internal] load build context
#7 transferring context: 510B done
#7 DONE 0.0s

#8 [galaxy 2/5] ADD _build /build
#8 CACHED

#9 [galaxy 3/5] WORKDIR /build
#9 CACHED

#10 [galaxy 4/5] RUN ansible-galaxy role install  -r requirements.yml --roles-path "/usr/share/ansible/roles"
#10 CACHED

#11 [galaxy 5/5] RUN ANSIBLE_GALAXY_DISABLE_GPG_VERIFY=1 ansible-galaxy collection install  -r requirements.yml --collections-path "/usr/share/ansible/collections"
#11 1.375 Starting galaxy collection install process
#11 1.375 Process install dependency map
#11 4.114 [WARNING]: Skipping Galaxy server https://galaxy.ansible.com/api/. Got an
#11 4.114 unexpected error when getting available versions of collection
#11 4.114 community.general: '/api/v3/plugin/ansible/content/published/collections/index/
#11 4.114 community/general/versions/'
#11 4.114 ERROR! Unexpected Exception, this is probably a bug: '/api/v3/plugin/ansible/content/published/collections/index/community/general/versions/'
#11 4.114 to see the full traceback, use -vvv
#11 ERROR: process "/bin/sh -c ANSIBLE_GALAXY_DISABLE_GPG_VERIFY=1 ansible-galaxy collection install $ANSIBLE_GALAXY_CLI_COLLECTION_OPTS -r requirements.yml --collections-path \"/usr/share/ansible/collections\"" did not complete successfully: exit code: 250
------
 > [galaxy 5/5] RUN ANSIBLE_GALAXY_DISABLE_GPG_VERIFY=1 ansible-galaxy collection install  -r requirements.yml --collections-path "/usr/share/ansible/collections":
1.375 Starting galaxy collection install process
1.375 Process install dependency map
4.114 [WARNING]: Skipping Galaxy server https://galaxy.ansible.com/api/. Got an
4.114 unexpected error when getting available versions of collection
4.114 community.general: '/api/v3/plugin/ansible/content/published/collections/index/
4.114 community/general/versions/'
4.114 ERROR! Unexpected Exception, this is probably a bug: '/api/v3/plugin/ansible/content/published/collections/index/community/general/versions/'
4.114 to see the full traceback, use -vvv
------
Dockerfile:13
--------------------
  11 |     
  12 |     RUN ansible-galaxy role install $ANSIBLE_GALAXY_CLI_ROLE_OPTS -r requirements.yml --roles-path "/usr/share/ansible/roles"
  13 | >>> RUN ANSIBLE_GALAXY_DISABLE_GPG_VERIFY=1 ansible-galaxy collection install $ANSIBLE_GALAXY_CLI_COLLECTION_OPTS -r requirements.yml --collections-path "/usr/share/ansible/collections"
  14 |     
  15 |     FROM $EE_BUILDER_IMAGE as builder
--------------------
ERROR: failed to solve: process "/bin/sh -c ANSIBLE_GALAXY_DISABLE_GPG_VERIFY=1 ansible-galaxy collection install $ANSIBLE_GALAXY_CLI_COLLECTION_OPTS -r requirements.yml --collections-path \"/usr/share/ansible/collections\"" did not complete successfully: exit code: 250

An error occured (rc=1), see output line(s) above for details.
ryeleo commented 8 months ago

I was seeing this on my RHEL7 Jenkins build agent... I'm going to try and see if I can replicate this issue on my local workstation as well.

ryeleo commented 8 months ago

Reproduced on my local development box:

$ ansible-builder build -v3
Ansible Builder is building your execution environment image. Tags: ansible-execution-env:latest
File context/_build/requirements.yml is already up-to-date.
File context/_build/requirements.txt is already up-to-date.
Rewriting Containerfile to capture collection requirements
Running command:
  docker build -f context/Dockerfile -t ansible-execution-env:latest context
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 1.23kB done
#1 DONE 0.0s

#2 [internal] load .dockerignore
#2 transferring context: 2B done
#2 DONE 0.0s

#3 [internal] load metadata for quay.io/ansible/ansible-runner:latest
#3 DONE 0.5s

#4 [internal] load metadata for quay.io/ansible/ansible-builder:latest
#4 DONE 0.5s

#5 [galaxy 1/5] FROM quay.io/ansible/ansible-runner:latest@sha256:001a4bde411be863d54c1d293f3d2e7b0ff0e67ef5d7b2f9f7fb56b61694f4e8
#5 DONE 0.0s

#6 [builder 1/5] FROM quay.io/ansible/ansible-builder:latest@sha256:75c4e4b5be6aab3386381b1e202ad382002f6830fd4b524bcd5ddc718e4f6a89
#6 CACHED

#7 [stage-2 2/5] RUN pip3 install --upgrade pip setuptools
#7 CACHED

#8 [internal] load build context
#8 transferring context: 113B done
#8 DONE 0.0s

#9 [galaxy 2/5] ADD _build /build
#9 CACHED

#10 [galaxy 3/5] WORKDIR /build
#10 CACHED

#11 [galaxy 4/5] RUN ansible-galaxy role install  -r requirements.yml --roles-path "/usr/share/ansible/roles"
#11 CACHED

#12 [galaxy 5/5] RUN ANSIBLE_GALAXY_DISABLE_GPG_VERIFY=1 ansible-galaxy collection install  -r requirements.yml --collections-path "/usr/share/ansible/collections"
#12 0.835 Starting galaxy collection install process
#12 0.835 Process install dependency map
#12 4.230 [WARNING]: Skipping Galaxy server https://galaxy.ansible.com/api/. Got an
#12 4.230 unexpected error when getting available versions of collection
#12 4.230 community.general: '/api/v3/plugin/ansible/content/published/collections/index/
#12 4.230 community/general/versions/'
#12 4.231 ERROR! Unexpected Exception, this is probably a bug: '/api/v3/plugin/ansible/content/published/collections/index/community/general/versions/'
#12 4.231 to see the full traceback, use -vvv
#12 ERROR: process "/bin/sh -c ANSIBLE_GALAXY_DISABLE_GPG_VERIFY=1 ansible-galaxy collection install $ANSIBLE_GALAXY_CLI_COLLECTION_OPTS -r requirements.yml --collections-path \"/usr/share/ansible/collections\"" did not complete successfully: exit code: 250
------
 > [galaxy 5/5] RUN ANSIBLE_GALAXY_DISABLE_GPG_VERIFY=1 ansible-galaxy collection install  -r requirements.yml --collections-path "/usr/share/ansible/collections":
#12 0.835 Starting galaxy collection install process
#12 0.835 Process install dependency map
#12 4.230 [WARNING]: Skipping Galaxy server https://galaxy.ansible.com/api/. Got an
#12 4.230 unexpected error when getting available versions of collection
#12 4.230 community.general: '/api/v3/plugin/ansible/content/published/collections/index/
#12 4.230 community/general/versions/'
#12 4.231 ERROR! Unexpected Exception, this is probably a bug: '/api/v3/plugin/ansible/content/published/collections/index/community/general/versions/'
#12 4.231 to see the full traceback, use -vvv
------
Dockerfile:13
--------------------
  11 |     
  12 |     RUN ansible-galaxy role install $ANSIBLE_GALAXY_CLI_ROLE_OPTS -r requirements.yml --roles-path "/usr/share/ansible/roles"
  13 | >>> RUN ANSIBLE_GALAXY_DISABLE_GPG_VERIFY=1 ansible-galaxy collection install $ANSIBLE_GALAXY_CLI_COLLECTION_OPTS -r requirements.yml --collections-path "/usr/share/ansible/collections"
  14 |     
  15 |     FROM $EE_BUILDER_IMAGE as builder
--------------------
ERROR: failed to solve: process "/bin/sh -c ANSIBLE_GALAXY_DISABLE_GPG_VERIFY=1 ansible-galaxy collection install $ANSIBLE_GALAXY_CLI_COLLECTION_OPTS -r requirements.yml --collections-path \"/usr/share/ansible/collections\"" did not complete successfully: exit code: 250
ryeleo commented 8 months ago

Tried making a venv with pip install "ansible-builder<=3", still seeing the same behavior...

β„ΉπŸ€” Given all these failures, I'm really hoping this is a simple Docker networking issue on my end (even though it happened on two of my workstations). Hopefully this is going to make sense to me in the morning (otherwise I might try to spin up a new VM somewhere to try this build again with a totally untainted environment). πŸ€žπŸ˜…πŸ€ž

$ ansible-builder --version
1.2.0

I also updated my "execution-environment.yml" to use version 1:

---
version: 1

dependencies:
  galaxy: requirements.yml

additional_build_steps:
  prepend: |
    RUN pip3 install --upgrade pip setuptools

The output using ansible-builder 1.2.0 seems the same as for v3.0.0.

$ ansible-builder build -v3
Ansible Builder is building your execution environment image. Tags: ansible-execution-env:latest
File context/_build/requirements.yml is already up-to-date.
File context/_build/requirements.txt is already up-to-date.
Rewriting Containerfile to capture collection requirements
Running command:
  docker build -f context/Dockerfile -t ansible-execution-env:latest context
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 1.23kB done
#1 DONE 0.0s

#2 [internal] load .dockerignore
#2 transferring context: 2B done
#2 DONE 0.0s

#3 [internal] load metadata for quay.io/ansible/ansible-runner:latest
#3 DONE 0.1s

#4 [internal] load metadata for quay.io/ansible/ansible-builder:latest
#4 DONE 0.2s

#5 [galaxy 1/5] FROM quay.io/ansible/ansible-runner:latest@sha256:001a4bde411be863d54c1d293f3d2e7b0ff0e67ef5d7b2f9f7fb56b61694f4e8
#5 DONE 0.0s

#6 [builder 1/5] FROM quay.io/ansible/ansible-builder:latest@sha256:75c4e4b5be6aab3386381b1e202ad382002f6830fd4b524bcd5ddc718e4f6a89
#6 CACHED

#7 [stage-2 2/5] RUN pip3 install --upgrade pip setuptools
#7 CACHED

#8 [internal] load build context
#8 transferring context: 113B done
#8 DONE 0.0s

#9 [galaxy 2/5] ADD _build /build
#9 CACHED

#10 [galaxy 3/5] WORKDIR /build
#10 CACHED

#11 [galaxy 4/5] RUN ansible-galaxy role install  -r requirements.yml --roles-path "/usr/share/ansible/roles"
#11 CACHED

#12 [galaxy 5/5] RUN ANSIBLE_GALAXY_DISABLE_GPG_VERIFY=1 ansible-galaxy collection install  -r requirements.yml --collections-path "/usr/share/ansible/collections"
#12 0.785 Starting galaxy collection install process
#12 0.785 Process install dependency map
#12 3.717 [WARNING]: Skipping Galaxy server https://galaxy.ansible.com/api/. Got an
#12 3.717 unexpected error when getting available versions of collection
#12 3.717 community.general: '/api/v3/plugin/ansible/content/published/collections/index/
#12 3.717 community/general/versions/'
#12 3.724 ERROR! Unexpected Exception, this is probably a bug: '/api/v3/plugin/ansible/content/published/collections/index/community/general/versions/'
#12 3.725 to see the full traceback, use -vvv
#12 ERROR: process "/bin/sh -c ANSIBLE_GALAXY_DISABLE_GPG_VERIFY=1 ansible-galaxy collection install $ANSIBLE_GALAXY_CLI_COLLECTION_OPTS -r requirements.yml --collections-path \"/usr/share/ansible/collections\"" did not complete successfully: exit code: 250
------
 > [galaxy 5/5] RUN ANSIBLE_GALAXY_DISABLE_GPG_VERIFY=1 ansible-galaxy collection install  -r requirements.yml --collections-path "/usr/share/ansible/collections":
#12 0.785 Starting galaxy collection install process
#12 0.785 Process install dependency map
#12 3.717 [WARNING]: Skipping Galaxy server https://galaxy.ansible.com/api/. Got an
#12 3.717 unexpected error when getting available versions of collection
#12 3.717 community.general: '/api/v3/plugin/ansible/content/published/collections/index/
#12 3.717 community/general/versions/'
#12 3.724 ERROR! Unexpected Exception, this is probably a bug: '/api/v3/plugin/ansible/content/published/collections/index/community/general/versions/'
#12 3.725 to see the full traceback, use -vvv
------
Dockerfile:13
--------------------
  11 |     
  12 |     RUN ansible-galaxy role install $ANSIBLE_GALAXY_CLI_ROLE_OPTS -r requirements.yml --roles-path "/usr/share/ansible/roles"
  13 | >>> RUN ANSIBLE_GALAXY_DISABLE_GPG_VERIFY=1 ansible-galaxy collection install $ANSIBLE_GALAXY_CLI_COLLECTION_OPTS -r requirements.yml --collections-path "/usr/share/ansible/collections"
  14 |     
  15 |     FROM $EE_BUILDER_IMAGE as builder
--------------------
ERROR: failed to solve: process "/bin/sh -c ANSIBLE_GALAXY_DISABLE_GPG_VERIFY=1 ansible-galaxy collection install $ANSIBLE_GALAXY_CLI_COLLECTION_OPTS -r requirements.yml --collections-path \"/usr/share/ansible/collections\"" did not complete successfully: exit code: 250

An error occured (rc=1), see output line(s) above for details.
ryeleo commented 8 months ago

WHOOPS, I am just now realizing that I am using python3.8, and the latest ansible-builder (3.0.0) doesn't support python 3.8. πŸ€¦β€β™‚οΈ

I will go switch to a newer version of python for my venv and see what happens.

kurokobo commented 8 months ago

@ryeleo Hi, this is due to Ansible being out of date and not being able to support recent changes on the Galaxy side. As your execution-environment.yml if no base image is specified, quay.io/ansible/ansible-runner:latest is used by default, which is no longer maintained and can't be work with recent Galaxy. You should explicitly specify base image like this for v3;

images:
  base_image:
    name: ghcr.io/ansible-community/community-ee-minimal:latest

or for v1:

build_arg_defaults:
  EE_BASE_IMAGE: ghcr.io/ansible-community/community-ee-minimal:latest

Here are another helpful examples:

ryeleo commented 8 months ago

@kurokobo, I am very grateful for your advice! You are correct, this did fix the issue!

I do feel a fool for not having thought to look more into the ansible-builder documentation, which chats about the 'base image', and has a nice 'sample' showing how it can be done.

I just glanced over the "Breaking Changes" in the release notes and assumed that 'it is the same project, I doubt anything I'm using broke.' πŸ‘πŸ˜…πŸ‘

Thanks again!