Could not upload a new collection version to Ansible Galaxy

Hey there,

i have tried to upload a new version of my Ansible Collection but iam getting the following error message:

Status: 
Failed
Approval status: waiting for import to finish
Version: 1.1.0
Error message:
duplicate key value violates unique constraint "unique_is_highest"
DETAIL:  Key (collection_id, is_highest)=(018ae852-5831-78a0-b19f-d2d6a4e41174, t) already exists.
  File "/venv/lib64/python3.11/site-packages/pulpcore/tasking/tasks.py", line 66, in _execute_task
    result = func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^
  File "/app/galaxy_ng/app/tasks/publishing.py", line 115, in import_and_auto_approve
    repo = _upload_collection(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/galaxy_ng/app/tasks/publishing.py", line 65, in _upload_collection
    general_create(*general_args, **kwargs)
  File "/venv/lib64/python3.11/site-packages/pulpcore/app/tasks/base.py", line 38, in general_create
    instance = serializer.save()
               ^^^^^^^^^^^^^^^^^
  File "/venv/lib64/python3.11/site-packages/rest_framework/serializers.py", line 212, in save
    self.instance = self.create(validated_data)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib64/python3.11/site-packages/pulp_ansible/app/serializers.py", line 530, in create
    finish_collection_upload(content, tags=tags, origin_repository=origin_repository)
  File "/venv/lib64/python3.11/site-packages/pulp_ansible/app/tasks/upload.py", line 84, in finish_collection_upload
    _update_highest_version(collection_version)
  File "/venv/lib64/python3.11/site-packages/pulp_ansible/app/tasks/collections.py", line 439, in _update_highest_version
    update_qs.update(is_highest=F("new_is_highest"))
  File "/venv/lib64/python3.11/site-packages/django/db/models/query.py", line 1206, in update
    rows = query.get_compiler(self.db).execute_sql(CURSOR)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib64/python3.11/site-packages/django/db/models/sql/compiler.py", line 1984, in execute_sql
    cursor = super().execute_sql(result_type)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib64/python3.11/site-packages/django/db/models/sql/compiler.py", line 1562, in execute_sql
    cursor.execute(sql, params)
  File "/venv/lib64/python3.11/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib64/python3.11/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib64/python3.11/site-packages/django/db/backends/utils.py", line 84, in _execute
    with self.db.wrap_database_errors:
  File "/venv/lib64/python3.11/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/venv/lib64/python3.11/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib64/python3.11/site-packages/psycopg/cursor.py", line 723, in execute
    raise ex.with_traceback(None)

But the Log shows:
Importing with galaxy-importer 0.4.14
Getting doc strings via ansible-doc
Finding content inside collection
Loading module entry
Loading module group
Collection loading complete

Failed

I dont understand the error. It seems that it doesn’t have anything todo with my code. I have created the collection with ansible-galaxy collection build and tried to upload it via webinterface. When i try to upload this file again it says

ERROR! Error when publishing collection to cmd_arg (https://galaxy.ansible.com/api/) (HTTP Code: 400, Message: Collection torie_coding.keepass-1.1.0 already exists Code: invalid)

Thank you for your help.

1 Like

Hello,

I have same situation:

ERROR! Galaxy import process failed: duplicate key value violates unique constraint "unique_is_highest"
DETAIL:  Key (collection_id, is_highest)=(e201c1cf-1413-4f3b-9e57-2bac1ef184e5, t) already exists. (Code: UNKNOWN)

Also found this issue in Red Hat’s KB: On Red Hat Automation Hub, Sync of collection fails with error "duplicate key value violates unique constraint \"unique_is_highest\"\" - Red Hat Customer Portal

So seems like there is no existing solution yet.
Thank you for your reply i i didn‘t find this article.

Same problem here. Any help on this? It looks like a global problem affecting Galaxy. No solution so far.

We believe this will be addressed by Fix update_highest_version when versions were uploaded out-of-order by gerrod3 · Pull Request #1624 · pulp/pulp_ansible · GitHub

Hit this issue too. Looking forward to the fix being deployed. Thank you

A few hours ago the Fix update_highest_version when versions were uploaded out-of-order (… · pulp/pulp_ansible@55f02c6 · GitHub was pushed into Master. So i belive that the Fix live now ? I tried to upload a new version again but i get the same error.

Same as @Torie-Coding, still unable to upload a new version

Also, If we retry to push the same collection version, we are getting error as “Artifact already exists” but there is no new collection version uploaded. To whom we can contact in galaxy team to delete this artifact, which was failed to upload and we can retry to push the same collection version.

2 Likes

Hi folks, we’re still in the process of getting the patch out to production. Here’s a list things we typically have to do to get a patch deployed:

  1. get the pulp_ansible PR merged Fix update_highest_version when versions were uploaded out-of-order by gerrod3 · Pull Request #1624 · pulp/pulp_ansible · GitHub
  2. make a backport for pulp_ansible [PR #1624/55f02c62 backport][0.20] Fix update_highest_version when versions were uploaded out-of-order by patchback[bot] · Pull Request #1625 · pulp/pulp_ansible · GitHub
  3. bump the pulp_ansible version in galaxy_ng update pulp_ansible to 0.20.2 by jctanner · Pull Request #1950 · ansible/galaxy_ng · GitHub
  4. wait for the CI/CD setup to deploy galaxy_ng’s master branch to galaxy-dev.ansible.com
  5. do QA/QE on dev
  6. trigger a deploy to galaxy-stage.ansible.com and do QA/QE there again
  7. trigger a deploy to galaxy.ansible.com

We’re on step 4 right now and will get through the rest as quick as we can.

UPDATE: the fix is in production now

6 Likes

Thanks for the detailed process. Do you know what we can do regarding the error “Artifact already exists” when the fix is deployed ?

@tannerjc Thanks for the fix, I am able to deploy the latest collection to galaxy and did not face any issue.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.