Why does Automation Hub fail to start with "UniqueViolation: duplicate key value violates unique constraint core_role_name_key" after a pod or container restart?

Solution Verified - Updated -

Issue

  • Automation Hub pods or containers are unable to start and report the following error message:

    sh-5.1$ PULP_SETTINGS=/etc/pulp/settings.py pulpcore-manager migrate
    Operations to perform:
    Apply all migrations: ansible, auth, authtoken, certguard, container, contenttypes, core, dab_feature_flags, dab_rbac, dab_resource_registry, file, flags, galaxy, sessions, social_django
    Running migrations:
    No migrations to apply.
    Traceback (most recent call last):
    File "/usr/lib/python3.12/site-packages/django/db/models/query.py", line 948, in get_or_create
      return self.get(**kwargs), False
            ^^^^^^^^^^^^^^^^^^
    File "/usr/lib/python3.12/site-packages/django/db/models/query.py", line 635, in get
      raise self.model.DoesNotExist(
    __fake__.Role.DoesNotExist: Role matching query does not exist.
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
    File "/usr/lib/python3.12/site-packages/django/db/backends/utils.py", line 105, in _execute
      return self.cursor.execute(sql, params)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib/python3.12/site-packages/psycopg/cursor.py", line 97, in execute
      raise ex.with_traceback(None)
    psycopg.errors.UniqueViolation: duplicate key value violates unique constraint "core_role_name_key"
    DETAIL:  Key (name)=(ansible.ansiblerepository_creator) already exists.
    

    NOTE: The error may also reference galaxy.content_admin or other role names depending on which role triggers the collision first.

Environment

  • Red Hat Ansible Automation Platform 2.6
  • Deployment type: Operator on OpenShift or Containerized (podman-based)
  • Multiple Automation Hub instances
  • Automation Hub components:
    • pulpcore 3.49.x
    • pulp_ansible 0.25.x
    • pulp_container 2.19.x
    • python-galaxy-ng

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content