Bug #39392
closedOrganization destroy fails with 'Couldn't find Katello::Repository' after PR #11762
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¶
- Install Katello nightly (packages including PR #11762)
- Create an organization with products, repositories, and content views
- Sync content and promote to lifecycle environments
- Run:
hammer organization delete --name="<org_name>" - 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:
DeleteDistributions#invoke_external_taskruns — finds the repo, starts async Pulp distribution deleteRepository::Destroy#finalizeruns — callsrepository.destroy!, deleting the DB recordDeleteDistributions#finalizeruns — callsRepository.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.
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
Updated by The Foreman Bot about 1 month ago
- Fixed in Releases Katello 5.0.0 added
Updated by Zach Huntington-Meath about 1 month ago
- Status changed from Ready For Testing to Closed
Applied in changeset katello|2f4f8b152560081b2f77782d936371b58fcf85d3.
Updated by Samir Jha about 1 month ago
- Target version set to Katello 4.21.0
- Triaged changed from No to Yes
Updated by The Foreman Bot about 1 month ago
- Fixed in Releases Katello 4.21.0 added