Project

General

Profile

Actions

Bug #31322

closed

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

Added by Justin Sherrill over 3 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Repositories
Target version:
Fixed in Releases:
Found in Releases:

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
Actions #1

Updated by Justin Sherrill over 3 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) }}" 

Actions #2

Updated by Evgeni Golov over 3 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

Actions #3

Updated by Justin Sherrill over 3 years ago

  • Triaged changed from No to Yes
Actions #4

Updated by Justin Sherrill over 3 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.

Actions #5

Updated by Justin Sherrill over 3 years ago

  • Bugzilla link set to 1918507
Actions #6

Updated by Justin Sherrill about 3 years ago

  • Target version changed from Katello 4.0.0 to Katello 4.0.1
Actions #7

Updated by Ian Ballou about 3 years ago

  • Assignee set to Ian Ballou
Actions #8

Updated by The Foreman Bot about 3 years ago

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

Updated by Ian Ballou about 3 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.

Actions #10

Updated by The Foreman Bot about 3 years ago

  • Fixed in Releases Katello 4.1.0 added
Actions #11

Updated by Anonymous about 3 years ago

  • Status changed from Ready For Testing to Closed
Actions #12

Updated by The Foreman Bot about 3 years ago

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

Also available in: Atom PDF