Bug #31322
closedrepository update immediately after repository creation fails due to race condition {"base_path":["This field must be unique."]}
Description
Repository creation is a syncronous task, but spawns an async task to generate metadata. With pulp3 as part of the metadata generation it create a distribution, but this is spawned as an async task that runs even after the 'creation' response is returned to the user. If the user immediately requests an update to the repo (which also triggers a metadata generate), and the timing is just right, the app will attempt to create the distribution twice, resulting in: {"base_path":["This field must be unique."]}
A couple options to resolve this:
- pre-create the distribution (not sure if we can do this without a publication, need to investigate)
- change the creation/update apis to be async and let the user 'wait'
- better handle this race condition within the distribution creation code
Updated by Justin Sherrill about 4 years ago
this playbook should recreate the issue:
--- - hosts: localhost collections: - theforeman.foreman gather_facts: false vars: foreman_username: admin foreman_password: "changeme" foreman_server_url: "https://centos7-katello-3-17.yatsu.example.com" foreman_validate_certs: false organization_name: "Test Organization" product_name: "Test Product" repository_name: "Test Repository Justin" repository_content_type: "yum" repository_label: "just_a_test_repo_justin" repository_mirror_on_sync: false repository_url: "https://repos.fedorapeople.org/pulp/pulp/demo_repos/zoo/" repository_state: present tasks: - name: create repo repository: username: "{{ foreman_username }}" password: "{{ foreman_password }}" server_url: "{{ foreman_server_url }}" validate_certs: "{{ foreman_validate_certs }}" organization: "{{ organization_name }}" name: "{{ repository_name }}" label: "{{ repository_label | default(omit) }}" mirror_on_sync: False state: "{{ repository_state }}" product: "{{ product_name }}" content_type: "{{ repository_content_type }}" url: "{{ repository_url | default(omit) }}" - name: update repo repository: username: "{{ foreman_username }}" password: "{{ foreman_password }}" server_url: "{{ foreman_server_url }}" validate_certs: "{{ foreman_validate_certs }}" organization: "{{ organization_name }}" name: "{{ repository_name }}" label: "{{ repository_label | default(omit) }}" mirror_on_sync: True state: "{{ repository_state }}" product: "{{ product_name }}" content_type: "{{ repository_content_type }}" url: "{{ repository_url | default(omit) }}"
Updated by Evgeni Golov about 4 years ago
- Found in Releases Katello 3.16.0, Katello 3.17.0 added
FWIW, this works fine on 3.15 (as it uses pulp2 for RPM?) and is broken since 3.16
Updated by Justin Sherrill almost 4 years ago
We should also handle this more gracefully to try to handle the situation where the distribution reference doesn't exist, but the distribution does exist in pulp3. Today, this will always error.
Updated by Justin Sherrill almost 4 years ago
- Target version changed from Katello 4.0.0 to Katello 4.0.1
Updated by The Foreman Bot almost 4 years ago
- Status changed from New to Ready For Testing
- Pull request https://github.com/Katello/katello/pull/9193 added
Updated by Ian Ballou almost 4 years ago
The best path forward would be to make the create/update apis async and handle the race condition by trying to look up the distribution in pulp by the base path.
Edit: on second thought, this would still require pre-creating an empty distribution. Another solution could be to edit RefreshDistribution to lookup the distribution in Pulp first to check if it was created, and go from there.
Updated by The Foreman Bot almost 4 years ago
- Fixed in Releases Katello 4.1.0 added
Updated by Anonymous almost 4 years ago
- Status changed from Ready For Testing to Closed
Applied in changeset katello|62a79f9ca909c073d285f5775a4f3c97c44cbb00.
Updated by The Foreman Bot over 3 years ago
- Pull request https://github.com/Katello/katello/pull/9301 added