Project

General

Profile

Actions

Bug #39392

closed

Organization destroy fails with 'Couldn't find Katello::Repository' after PR #11762

Added by Zach Huntington-Meath about 1 month ago. Updated about 1 month ago.

Status:
Closed
Priority:
Normal
Category:
-
Target version:
Difficulty:
Triaged:
Yes
Fixed in Releases:
Found in Releases:

Description

Description

After PR #11762 (Fixes #39346) changed DeleteDistributions from a synchronous action (Pulp3::Abstract) to an async one (Pulp3::AbstractAsyncTask), the finalize method calls Katello::Repository.find(input[:repository_id]) to clean up the distribution reference. However, by the time finalize runs (after the async Pulp task completes), the repository record has already been destroyed by Repository::Destroy#finalize, which calls repository.destroy!.

This causes hammer organization delete to fail with:

Error: Couldn't find Katello::Repository with 'id'=14

Steps to Reproduce

  1. Install Katello nightly (packages including PR #11762)
  2. Create an organization with products, repositories, and content views
  3. Sync content and promote to lifecycle environments
  4. Run: hammer organization delete --name="<org_name>"
  5. Observe the task fails at ~56% with the Repository not found error

Expected Result

Organization is deleted successfully.

Actual Result

The Dynflow task errors with Couldn't find Katello::Repository with 'id'=<N>. The task progresses to ~31%, stalls, then errors at ~56%.

Root Cause

The execution order during org destroy:

  1. DeleteDistributions#invoke_external_task runs — finds the repo, starts async Pulp distribution delete
  2. Repository::Destroy#finalize runs — calls repository.destroy!, deleting the DB record
  3. DeleteDistributions#finalize runs — calls Repository.find(id) — FAILS because the record is gone

Suggested Fix

Use find_by with a guard clause in DeleteDistributions#finalize, or store the distribution reference ID in the action output during invoke_external_task so finalize doesn't need the repository record.

Affected Versions

Katello nightly (2026-06-02 onwards, after PR #11762 merged)

CI Evidence

foreman-pipeline-katello-rpm-nightly #1134 — all 4 scenarios (almalinux9/centos9-stream x install/upgrade) fail on fb-destroy-organization.bats tests 1 and 3.

Actions #1

Updated by The Foreman Bot about 1 month ago

  • Status changed from New to Ready For Testing
  • Assignee set to Zach Huntington-Meath
  • Pull request https://github.com/Katello/katello/pull/11772 added
Actions #2

Updated by Ondřej Gajdušek about 1 month ago

  • Red Hat JIRA set to SAT-45939
Actions #3

Updated by The Foreman Bot about 1 month ago

  • Fixed in Releases Katello 5.0.0 added
Actions #4

Updated by Zach Huntington-Meath about 1 month ago

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

Updated by Samir Jha about 1 month ago

  • Target version set to Katello 4.21.0
  • Triaged changed from No to Yes
Actions #6

Updated by The Foreman Bot about 1 month ago

  • Fixed in Releases Katello 4.21.0 added
Actions

Also available in: Atom PDF