Project

General

Profile

Bug #31322

repository update immediately after repository creation fails due to race condition {"base_path":["This field must be unique."]}

Added by Justin Sherrill about 1 year ago. Updated 9 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Repositories
Target version:

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

Associated revisions

Revision 62a79f9c (diff)
Added by Ian Ballou 11 months ago

Fixes #31322 - repo update fails immediately after repo create (#9193)

History

#1 Updated by Justin Sherrill about 1 year 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) }}" 

#2 Updated by Evgeni Golov about 1 year 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

#3 Updated by Justin Sherrill about 1 year ago

  • Triaged changed from No to Yes

#4 Updated by Justin Sherrill about 1 year 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.

#5 Updated by Justin Sherrill about 1 year ago

  • Bugzilla link set to 1918507

#6 Updated by Justin Sherrill 12 months ago

  • Target version changed from Katello 4.0.0 to Katello 4.0.1

#7 Updated by Ian Ballou 11 months ago

  • Assignee set to Ian Ballou

#8 Updated by The Foreman Bot 11 months ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/Katello/katello/pull/9193 added

#9 Updated by Ian Ballou 11 months 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.

#10 Updated by The Foreman Bot 11 months ago

  • Fixed in Releases Katello 4.1.0 added

#11 Updated by Anonymous 11 months ago

  • Status changed from Ready For Testing to Closed

#12 Updated by The Foreman Bot 9 months ago

  • Pull request https://github.com/Katello/katello/pull/9301 added

Also available in: Atom PDF