Project

General

Profile

Actions

Bug #39433

closed

Deleting an organization fails when its Content Credentials are referenced by an Alternate Content Source

Added by Vladimir Sedmik 3 months ago. Updated about 1 month ago.

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

Description

Description:

After the fix introduced in #39309, deleting an organization that owns Content Credentials (of cert type) used by an Alternate Content Source (ACS) as CA cert, client cert, or client key fails with an ActiveRecord::DeleteRestrictionError.

Root cause:

#39309 changed the dependent: strategy on the three ACS associations of ContentCredential from :nullify to :restrict_with_exception. This correctly prevents standalone deletion of a
Content Credential while it is in use by an ACS. However, it also breaks organization deletion: when an organization is destroyed, Rails attempts to destroy its gpg_keys (Content
Credentials) before the ACS records have had their SSL cert references cleared. Since AlternateContentSource has no organization_id and is not directly owned by the organization, it is not destroyed as part of the cascade, and the restrict_with_exception fires.

Steps to reproduce:
1. Create a Content Credential of cert type.
2. Create an ACS using that credential as CA cert, client cert, or client key.
3. Attempt to delete the organization that owns the Content Credential.
4. The deletion fails with: Cannot delete record because of dependent ssl_ca_alternate_content_sources.

Expected behavior:
Deleting an organization destroys all its owned Content Credentials without error, nullifying any ACS SSL cert references in the process (since ACS is a global object not scoped to the organization).

Fix:
Add a before_destroy callback in OrganizationExtensions, placed before the has_many :gpg_keys, dependent: :destroy declaration, that nullifies ssl_ca_cert_id, ssl_client_cert_id, and ssl_client_key_id on any ACS records referencing the organization's Content Credentials. This preserves the protection against standalone CC deletion introduced in #39309 while allowing organization deletion to proceed cleanly.

Actions #1

Updated by The Foreman Bot 3 months ago

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

Updated by Ian Ballou 2 months ago

  • Triaged changed from No to Yes
Actions #3

Updated by The Foreman Bot 2 months ago

  • Fixed in Releases Katello 5.0.0 added
Actions #4

Updated by Vladimir Sedmik 2 months ago

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

Updated by The Foreman Bot about 1 month ago

  • Fixed in Releases Katello 4.21.1 added
Actions

Also available in: Atom PDF