Deleting repository fails with "Repository cannot be deleted since it has already been included in a published Content View" in Red Hat Satellite 6
Environment
- Red Hat Satellite 6
Issue
-
Unable to delete repository, as it fails with below error:
Repository cannot be deleted since it has already been included in a published Content View. Please delete all Content View versions containing this repository before attempting to delete it. -
Deleting repository using
hammercommand fails with below error:# hammer repository delete --id 226 Could not delete the Repository: Repository cannot be deleted since it has already been included in a published Content View. Please delete all Content View versions containing this repository before attempting to delete it.
Resolution
Generic manual resolution :
-
Identify the ID of the concerned repository using any of the following approaches:
- The
hammer repository listcommand. - Navigate to WebUI to the repository, and copy the trailing number from the Web URI (i.e. for URI
products/290/repositories/52, the repository ID is52).
- The
-
Run the following command to check which content_views and it's versions are using the repository. Here the id
52has been used as an example.# cat << EOF | foreman-rake console conf.echo = false Katello::Repository.find(52).clones.each { |repo| puts "Repo => #{repo.name} | CV => #{repo.content_view.name} | Version => #{repo.content_view_version.version} | Version_ID => #{repo.content_view_version.id} | Lifecycle => #{repo.content_view_version.environments.map(&:name).join(',')}"} ; nil EOFExample Output: ( Which shows the Content-View name, Content-View version, the ID of the Version and the Lifecycles in that version )
Repo => Red Hat Satellite Tools 6.10 for RHEL 8 x86_64 RPMs | CV => RH8_CV | Version => 1.0 | Version_ID => 2 | Lifecycle => Library Repo => Red Hat Satellite Tools 6.10 for RHEL 8 x86_64 RPMs | CV => Test_CV | Version => 1.0 | Version_ID => 7 | Lifecycle => Prod Repo => Red Hat Satellite Tools 6.10 for RHEL 8 x86_64 RPMs | CV => RH_CCV | Version => 1.0 | Version_ID => 10 | Lifecycle => Prod -
If ID is unknown but the Root ID of the same repository is known then the following command will provide the exact same information.
Example with
root_id3:# cat << EOF | foreman-rake console conf.echo = false Katello::Repository.where(:root_id => 3).each().map{|repo| puts "Repo => #{repo.name} | CV => #{repo.content_view.name} | Version => #{repo.content_view_version.version} | Version_ID => #{repo.content_view_version.id} | Lifecycle => #{repo.content_view_version.environments.map(&:name).join(',')}" if repo.content_view.id > 1} EOF -
Once, The content-view specific information is known for the repository ( to be removed ), Then follow these mentioned steps:
-
Remove the repository from the published content-view and re-publish a new version of the content-view.
-
Promote the applicable lifecycles on the latest published version of the content-view.
-
Delete the previous version of the content-view.
-
If the affected content-views were part of any composite content-views, then
- Ensure to select the latest published version of the content-view in the composite content-view.
- Republish a new version of the composite content-view and promote the applicable lifecycles on the latest published version.
- Delete the previous version of the composite content-view.
-
Delete any other versions of the content-view or composite content-view that were highlighted by the
foreman-rakecommand earlier.
-
-
Completion of these steps will ensure that the concerned repository is no longer associated with any component or composite content-views.
-
Now, to remove the repository:
- If it's a Red Hat provided repository, Then disable the repository from the
Satellite WebUi --> Content --> Red Hat Repositoriespage. - If it's a custom\manually created repository, then delete the repository from the
Satellite WebUi --> Content --> Products --> <Product Name> --> <Repo Name>page.
- If it's a Red Hat provided repository, Then disable the repository from the
For Red Hat Satellite 6.11 and above :
-
All steps mentioned above will work here as well but The obvious disadvantage of those steps is the fact that Content-Views have to be republished or Content-View versions have to be deleted.
-
To avoid those complications, Satellite 6.11+ has introduced an option called Allow deleting repositories in published content views and its value is set to Yes by default.
# hammer --output=yaml settings list --search "name = delete_repo_across_cv" \--- - Name: delete_repo_across_cv Full name: Allow deleting repositories in published content views Value: 'true' Description: If this is enabled, repositories can be deleted even when they belong to published content views. The deleted repository will be removed from all content view versions. -
The value of this setting can be changed using two ways:
-
Either from
Satellite WebUI --> Administer --> Settings --> Content --> "Allow deleting repositories in published content views" --> Select Yes\No -
Or using the hammer command i.e.
hammer settings set --name delete_repo_across_cv --value no
-
-
Now, When this option is enabled, Repository deletion is much easier whether it's a RedHat-provided repository or Custom created.
-
Go to the Satellite WebUI --> Content --> Products --> Click open the product --> Click open the repository --> From Select Action dropdown click on Remove Repository.
-
This action will do the following steps.
- Remove the repository instance from every content-view version ( where it might have been included ).
- Update the content count of those content-view versions after the repository removal.
- Then delete the repository completely from the Satellite itself.
-
-
NOTE: If the repository was also part of any composite content-view, then users are expected to run into the This content is not included.Bug 2123932 and the repository deletion task will go into Paused state.
-
Until the bug is officially fixed, This problem can be handled by identifying the
IDof the repository and executing the following command using thatID. An example withID 52has been shared below:# cat <<EOF | foreman-rake console repository = ::Katello::Repository.find(52) library_instances_inverse = repository.library_instances_inverse affected_cvv_ids = library_instances_inverse.pluck(:content_view_version_id).uniq ForemanTasks.sync_task(::Actions::BulkAction, ::Actions::Katello::Repository::Destroy, library_instances_inverse) affected_cvv_ids.each do |cvv_id| ::Katello::ContentViewVersion.find(cvv_id).update_content_counts! end EOF -
Then simply resume the
Pausedtask from earlier and that should complete the repository deletion as well.
-
NOTE: It's very important to identify the right repository ID for every single command suggested in this article to be able to collect accurate data and take necessary actions on the correct repository.
For more KB articles/solutions related to Red Hat Satellite 6.x Repository Issues, please refer to the Red Hat Satellite Consolidated Troubleshooting Article for Red Hat Satellite 6.x Repository Issues.. Reach out to This content is not included.Red Hat Technical Support in case of any further concerns.
Root Cause
- Repository was included and used in a published Content View.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.